From 79abdde6121759b5364236db8125b29a60afcc49 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Sun, 22 Dec 2024 16:40:11 +0800 Subject: [PATCH] Update Rust-VMM dependencies and re-vendor Signed-off-by: Ruoqing He --- .cargo/config | 1 - Cargo.lock | 51 +- address_space/Cargo.toml | 2 +- block_backend/Cargo.toml | 2 +- boot_loader/Cargo.toml | 2 +- chardev_backend/Cargo.toml | 2 +- cpu/Cargo.toml | 4 +- devices/Cargo.toml | 2 +- hypervisor/Cargo.toml | 6 +- machine/Cargo.toml | 2 +- machine_manager/Cargo.toml | 2 +- migration/Cargo.toml | 2 +- tests/mod_test/Cargo.toml | 2 +- trace/Cargo.toml | 2 +- ui/Cargo.toml | 2 +- util/Cargo.toml | 4 +- vendor/bitflags-1.3.2/.cargo-checksum.json | 1 + vendor/bitflags-1.3.2/CHANGELOG.md | 206 + vendor/bitflags-1.3.2/CODE_OF_CONDUCT.md | 73 + vendor/bitflags-1.3.2/Cargo.toml | 58 + vendor/bitflags-1.3.2/LICENSE-APACHE | 201 + vendor/bitflags-1.3.2/LICENSE-MIT | 25 + vendor/bitflags-1.3.2/README.md | 32 + .../bitflags-1.3.2/src/example_generated.rs | 14 + vendor/bitflags-1.3.2/src/lib.rs | 1729 +++ .../tests/basic.rs | 0 .../tests/compile-fail/impls/copy.rs | 0 .../tests/compile-fail/impls/copy.stderr.beta | 0 .../tests/compile-fail/impls/eq.rs | 0 .../tests/compile-fail/impls/eq.stderr.beta | 0 .../non_integer_base/all_defined.rs | 0 .../non_integer_base/all_defined.stderr.beta | 0 .../non_integer_base/all_missing.rs | 0 .../non_integer_base/all_missing.stderr.beta | 0 .../compile-fail/visibility/private_field.rs | 0 .../visibility/private_field.stderr.beta | 0 .../compile-fail/visibility/private_flags.rs | 0 .../visibility/private_flags.stderr.beta | 0 .../compile-fail/visibility/pub_const.rs | 0 .../visibility/pub_const.stderr.beta | 0 .../tests/compile-pass/impls/convert.rs | 0 .../tests/compile-pass/impls/default.rs | 0 .../compile-pass/impls/inherent_methods.rs | 0 .../tests/compile-pass/redefinition/core.rs | 0 .../compile-pass/redefinition/stringify.rs | 0 .../tests/compile-pass/repr/c.rs | 0 .../tests/compile-pass/repr/transparent.rs | 0 .../compile-pass/visibility/bits_field.rs | 0 .../tests/compile-pass/visibility/pub_in.rs | 0 .../tests/compile.rs | 0 vendor/bitflags/.cargo-checksum.json | 2 +- vendor/bitflags/CHANGELOG.md | 349 +- vendor/bitflags/CONTRIBUTING.md | 9 + vendor/bitflags/Cargo.lock | 383 + vendor/bitflags/Cargo.toml | 76 +- vendor/bitflags/README.md | 53 +- vendor/bitflags/SECURITY.md | 13 + vendor/bitflags/benches/parse.rs | 96 + vendor/bitflags/examples/custom_bits_type.rs | 97 + vendor/bitflags/examples/custom_derive.rs | 23 + vendor/bitflags/examples/fmt.rs | 49 + vendor/bitflags/examples/macro_free.rs | 61 + vendor/bitflags/examples/serde.rs | 36 + vendor/bitflags/spec.md | 552 + vendor/bitflags/src/example_generated.rs | 57 +- vendor/bitflags/src/external.rs | 262 + vendor/bitflags/src/external/arbitrary.rs | 33 + vendor/bitflags/src/external/bytemuck.rs | 19 + vendor/bitflags/src/external/serde.rs | 93 + vendor/bitflags/src/internal.rs | 125 + vendor/bitflags/src/iter.rs | 145 + vendor/bitflags/src/lib.rs | 2308 ++-- vendor/bitflags/src/parser.rs | 332 + vendor/bitflags/src/public.rs | 578 + vendor/bitflags/src/tests.rs | 131 + vendor/bitflags/src/tests/all.rs | 23 + vendor/bitflags/src/tests/bits.rs | 36 + vendor/bitflags/src/tests/complement.rs | 53 + vendor/bitflags/src/tests/contains.rs | 108 + vendor/bitflags/src/tests/difference.rs | 92 + vendor/bitflags/src/tests/empty.rs | 23 + vendor/bitflags/src/tests/eq.rs | 10 + vendor/bitflags/src/tests/extend.rs | 42 + vendor/bitflags/src/tests/flags.rs | 46 + vendor/bitflags/src/tests/fmt.rs | 97 + vendor/bitflags/src/tests/from_bits.rs | 45 + vendor/bitflags/src/tests/from_bits_retain.rs | 38 + .../bitflags/src/tests/from_bits_truncate.rs | 42 + vendor/bitflags/src/tests/from_name.rs | 42 + vendor/bitflags/src/tests/insert.rs | 91 + vendor/bitflags/src/tests/intersection.rs | 79 + vendor/bitflags/src/tests/intersects.rs | 91 + vendor/bitflags/src/tests/is_all.rs | 32 + vendor/bitflags/src/tests/is_empty.rs | 31 + vendor/bitflags/src/tests/iter.rs | 209 + vendor/bitflags/src/tests/parser.rs | 332 + vendor/bitflags/src/tests/remove.rs | 100 + .../src/tests/symmetric_difference.rs | 110 + vendor/bitflags/src/tests/union.rs | 71 + vendor/bitflags/src/traits.rs | 431 + vendor/kvm-bindings/.cargo-checksum.json | 2 +- vendor/kvm-bindings/CHANGELOG.md | 64 + vendor/kvm-bindings/CONTRIBUTING.md | 76 +- vendor/kvm-bindings/Cargo.toml | 41 +- vendor/kvm-bindings/README.md | 20 +- .../kvm-bindings/coverage_config_aarch64.json | 2 +- .../kvm-bindings/coverage_config_x86_64.json | 6 +- vendor/kvm-bindings/src/arm64/bindings.rs | 8704 +++++------- vendor/kvm-bindings/src/arm64/mod.rs | 5 +- vendor/kvm-bindings/src/arm64/serialize.rs | 79 + vendor/kvm-bindings/src/lib.rs | 30 +- vendor/kvm-bindings/src/riscv64/bindings.rs | 8307 ++++++++++++ .../kvm-bindings/src/riscv64/fam_wrappers.rs | 49 + .../kvm-bindings/src/{x86 => riscv64}/mod.rs | 9 +- vendor/kvm-bindings/src/riscv64/serialize.rs | 96 + vendor/kvm-bindings/src/serialize.rs | 66 + .../src/{x86 => x86_64}/bindings.rs | 11173 ++++++++-------- .../src/{x86 => x86_64}/fam_wrappers.rs | 90 +- vendor/kvm-bindings/src/x86_64/mod.rs | 14 + vendor/kvm-bindings/src/x86_64/serialize.rs | 156 + vendor/kvm-ioctls/.cargo-checksum.json | 2 +- vendor/kvm-ioctls/CHANGELOG.md | 157 +- vendor/kvm-ioctls/CODEOWNERS | 2 +- vendor/kvm-ioctls/Cargo.toml | 19 +- vendor/kvm-ioctls/README.md | 11 +- vendor/kvm-ioctls/build.rs | 2 + vendor/kvm-ioctls/coverage_config_x86_64.json | 2 +- vendor/kvm-ioctls/src/cap.rs | 39 +- vendor/kvm-ioctls/src/ioctls/device.rs | 195 +- vendor/kvm-ioctls/src/ioctls/mod.rs | 133 +- vendor/kvm-ioctls/src/ioctls/system.rs | 68 +- vendor/kvm-ioctls/src/ioctls/vcpu.rs | 1448 +- vendor/kvm-ioctls/src/ioctls/vm.rs | 898 +- vendor/kvm-ioctls/src/kvm_ioctls.rs | 175 +- vendor/kvm-ioctls/src/lib.rs | 45 +- vendor/vmm-sys-util/.cargo-checksum.json | 2 +- vendor/vmm-sys-util/CHANGELOG.md | 23 + vendor/vmm-sys-util/CODEOWNERS | 2 +- vendor/vmm-sys-util/Cargo.toml | 21 +- .../vmm-sys-util/coverage_config_x86_64.json | 2 +- vendor/vmm-sys-util/src/fam.rs | 240 +- vendor/vmm-sys-util/src/lib.rs | 3 +- vendor/vmm-sys-util/src/linux/aio.rs | 2 +- vendor/vmm-sys-util/src/linux/epoll.rs | 35 +- vendor/vmm-sys-util/src/linux/fallocate.rs | 1 + vendor/vmm-sys-util/src/linux/poll.rs | 44 +- vendor/vmm-sys-util/src/linux/seek_hole.rs | 26 +- .../vmm-sys-util/src/linux/sock_ctrl_msg.rs | 16 +- vendor/vmm-sys-util/src/linux/timerfd.rs | 1 + vendor/vmm-sys-util/src/linux/write_zeroes.rs | 24 +- vendor/vmm-sys-util/src/rand.rs | 26 +- vendor/vmm-sys-util/src/syscall.rs | 18 +- vendor/vmm-sys-util/src/tempfile.rs | 28 +- vendor/vmm-sys-util/src/unix/tempdir.rs | 1 + vfio/Cargo.toml | 6 +- virtio/Cargo.toml | 2 +- 156 files changed, 29944 insertions(+), 13347 deletions(-) create mode 100644 vendor/bitflags-1.3.2/.cargo-checksum.json create mode 100644 vendor/bitflags-1.3.2/CHANGELOG.md create mode 100644 vendor/bitflags-1.3.2/CODE_OF_CONDUCT.md create mode 100644 vendor/bitflags-1.3.2/Cargo.toml create mode 100644 vendor/bitflags-1.3.2/LICENSE-APACHE create mode 100644 vendor/bitflags-1.3.2/LICENSE-MIT create mode 100644 vendor/bitflags-1.3.2/README.md create mode 100644 vendor/bitflags-1.3.2/src/example_generated.rs create mode 100644 vendor/bitflags-1.3.2/src/lib.rs rename vendor/{bitflags => bitflags-1.3.2}/tests/basic.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/impls/copy.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/impls/copy.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/impls/eq.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/impls/eq.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/non_integer_base/all_defined.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/non_integer_base/all_defined.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/non_integer_base/all_missing.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/non_integer_base/all_missing.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/visibility/private_field.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/visibility/private_field.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/visibility/private_flags.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/visibility/private_flags.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/visibility/pub_const.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-fail/visibility/pub_const.stderr.beta (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/impls/convert.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/impls/default.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/impls/inherent_methods.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/redefinition/core.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/redefinition/stringify.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/repr/c.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/repr/transparent.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/visibility/bits_field.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile-pass/visibility/pub_in.rs (100%) rename vendor/{bitflags => bitflags-1.3.2}/tests/compile.rs (100%) create mode 100644 vendor/bitflags/CONTRIBUTING.md create mode 100644 vendor/bitflags/Cargo.lock create mode 100644 vendor/bitflags/SECURITY.md create mode 100644 vendor/bitflags/benches/parse.rs create mode 100644 vendor/bitflags/examples/custom_bits_type.rs create mode 100644 vendor/bitflags/examples/custom_derive.rs create mode 100644 vendor/bitflags/examples/fmt.rs create mode 100644 vendor/bitflags/examples/macro_free.rs create mode 100644 vendor/bitflags/examples/serde.rs create mode 100644 vendor/bitflags/spec.md create mode 100644 vendor/bitflags/src/external.rs create mode 100644 vendor/bitflags/src/external/arbitrary.rs create mode 100644 vendor/bitflags/src/external/bytemuck.rs create mode 100644 vendor/bitflags/src/external/serde.rs create mode 100644 vendor/bitflags/src/internal.rs create mode 100644 vendor/bitflags/src/iter.rs create mode 100644 vendor/bitflags/src/parser.rs create mode 100644 vendor/bitflags/src/public.rs create mode 100644 vendor/bitflags/src/tests.rs create mode 100644 vendor/bitflags/src/tests/all.rs create mode 100644 vendor/bitflags/src/tests/bits.rs create mode 100644 vendor/bitflags/src/tests/complement.rs create mode 100644 vendor/bitflags/src/tests/contains.rs create mode 100644 vendor/bitflags/src/tests/difference.rs create mode 100644 vendor/bitflags/src/tests/empty.rs create mode 100644 vendor/bitflags/src/tests/eq.rs create mode 100644 vendor/bitflags/src/tests/extend.rs create mode 100644 vendor/bitflags/src/tests/flags.rs create mode 100644 vendor/bitflags/src/tests/fmt.rs create mode 100644 vendor/bitflags/src/tests/from_bits.rs create mode 100644 vendor/bitflags/src/tests/from_bits_retain.rs create mode 100644 vendor/bitflags/src/tests/from_bits_truncate.rs create mode 100644 vendor/bitflags/src/tests/from_name.rs create mode 100644 vendor/bitflags/src/tests/insert.rs create mode 100644 vendor/bitflags/src/tests/intersection.rs create mode 100644 vendor/bitflags/src/tests/intersects.rs create mode 100644 vendor/bitflags/src/tests/is_all.rs create mode 100644 vendor/bitflags/src/tests/is_empty.rs create mode 100644 vendor/bitflags/src/tests/iter.rs create mode 100644 vendor/bitflags/src/tests/parser.rs create mode 100644 vendor/bitflags/src/tests/remove.rs create mode 100644 vendor/bitflags/src/tests/symmetric_difference.rs create mode 100644 vendor/bitflags/src/tests/union.rs create mode 100644 vendor/bitflags/src/traits.rs create mode 100644 vendor/kvm-bindings/src/arm64/serialize.rs create mode 100644 vendor/kvm-bindings/src/riscv64/bindings.rs create mode 100644 vendor/kvm-bindings/src/riscv64/fam_wrappers.rs rename vendor/kvm-bindings/src/{x86 => riscv64}/mod.rs (73%) create mode 100644 vendor/kvm-bindings/src/riscv64/serialize.rs create mode 100644 vendor/kvm-bindings/src/serialize.rs rename vendor/kvm-bindings/src/{x86 => x86_64}/bindings.rs (66%) rename vendor/kvm-bindings/src/{x86 => x86_64}/fam_wrappers.rs (60%) create mode 100644 vendor/kvm-bindings/src/x86_64/mod.rs create mode 100644 vendor/kvm-bindings/src/x86_64/serialize.rs diff --git a/.cargo/config b/.cargo/config index 31ec474..1f84b46 100644 --- a/.cargo/config +++ b/.cargo/config @@ -11,7 +11,6 @@ # See the Mulan PSL v2 for more details. [build] - [target.'cfg(target_arch = "aarch64", not(target_env = "ohos"))'] rustflags = [ "-C", "link-arg=-lgcc", diff --git a/Cargo.lock b/Cargo.lock index fba3e56..99a1e19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8512c9117059663fb5606788fbca3619e2a91dac0e3fe516242eab1fa6be5e44" dependencies = [ "alsa-sys", - "bitflags", + "bitflags 1.3.2", "libc", "nix 0.24.3", ] @@ -82,7 +82,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba16453d10c712284061a05f6510f75abeb92b56ba88dfeb48c74775020cc22" dependencies = [ "atk-sys", - "bitflags", + "bitflags 1.3.2", "glib", "libc", ] @@ -117,7 +117,7 @@ version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", @@ -140,6 +140,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "bitintr" version = "0.3.0" @@ -199,7 +205,7 @@ version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab3603c4028a5e368d09b51c8b624b9a46edcd7c3778284077a6125af73c9f0a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cairo-sys-rs", "glib", "libc", @@ -279,7 +285,7 @@ version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "once_cell", @@ -493,7 +499,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1df5ea52cccd7e3a0897338b5564968274b52f5fd12601e0afa44f454c74d3" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk-sys", @@ -509,7 +515,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b023fbe0c6b407bd3d9805d107d9800da3829dc5a676653210f1d5f16d7f59bf" dependencies = [ - "bitflags", + "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", "glib", @@ -584,7 +590,7 @@ version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d14522e56c6bcb6f7a3aebc25cbcfb06776af4c0c25232b601b4383252d7cb92" dependencies = [ - "bitflags", + "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", @@ -617,7 +623,7 @@ version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f1de7cbde31ea4f0a919453a2dcece5d54d5b70e08f8ad254dc4840f5f09b6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "futures-channel", "futures-core", "futures-executor", @@ -683,7 +689,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c4222ab92b08d4d0bab90ddb6185b4e575ceeea8b8cdf00b938d7b6661d966" dependencies = [ "atk", - "bitflags", + "bitflags 1.3.2", "cairo-rs", "field-offset", "futures-channel", @@ -786,7 +792,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7b36074613a723279637061b40db993208908a94f10ccb14436ce735bc0f57" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] @@ -807,19 +813,20 @@ dependencies = [ [[package]] name = "kvm-bindings" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efe70e65a5b092161d17f5005b66e5eefe7a94a70c332e755036fc4af78c4e79" +checksum = "fa4933174d0cc4b77b958578cd45784071cc5ae212c2d78fbd755aaaa6dfa71a" dependencies = [ "vmm-sys-util", ] [[package]] name = "kvm-ioctls" -version = "0.15.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bdde2b46ee7b6587ef79f751019c4726c4f2d3e4628df5d69f3f9c5cb6c6bd4" +checksum = "e013ae7fcd2c6a8f384104d16afe7ea02969301ea2bb2a56e44b011ebc907cab" dependencies = [ + "bitflags 2.6.0", "kvm-bindings", "libc", "vmm-sys-util", @@ -859,7 +866,7 @@ version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1745b20bfc194ac12ef828f144f0ec2d4a7fe993281fa3567a0bd4969aee6890" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "libpulse-sys", "num-derive", @@ -1073,7 +1080,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", ] @@ -1084,7 +1091,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -1190,7 +1197,7 @@ version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52c280b82a881e4208afb3359a8e7fde27a1b272280981f1f34610bed5770d37" dependencies = [ - "bitflags", + "bitflags 1.3.2", "gio", "glib", "libc", @@ -1902,11 +1909,11 @@ dependencies = [ [[package]] name = "vmm-sys-util" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd64fe09d8e880e600c324e7d664760a17f56e9672b7495a86381b49e4f72f46" +checksum = "1d1435039746e20da4f8d507a72ee1b916f7b4b05af7a91c093d2c6561934ede" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] diff --git a/address_space/Cargo.toml b/address_space/Cargo.toml index 7ff4088..b9e7b1d 100644 --- a/address_space/Cargo.toml +++ b/address_space/Cargo.toml @@ -10,7 +10,7 @@ description = "provide memory management for VM" libc = "0.2" log = "0.4" nix = { version = "0.26.2", default-features = false, features = ["fs", "feature"] } -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" arc-swap = "1.6.0" thiserror = "1.0" anyhow = "1.0" diff --git a/block_backend/Cargo.toml b/block_backend/Cargo.toml index 6f7c45b..d052bd0 100644 --- a/block_backend/Cargo.toml +++ b/block_backend/Cargo.toml @@ -7,7 +7,7 @@ license = "Mulan PSL v2" [dependencies] thiserror = "1.0" -vmm-sys-util = "0.11.0" +vmm-sys-util = "0.12.1" anyhow = "1.0" log = "0.4" byteorder = "1.4.3" diff --git a/boot_loader/Cargo.toml b/boot_loader/Cargo.toml index d04c4ce..cbd2287 100644 --- a/boot_loader/Cargo.toml +++ b/boot_loader/Cargo.toml @@ -8,7 +8,7 @@ license = "Mulan PSL v2" [dependencies] thiserror = "1.0" anyhow = "1.0" -kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] } +kvm-bindings = { version = "0.10.0", features = ["fam-wrappers"] } log = "0.4" address_space = { path = "../address_space" } devices = { path = "../devices" } diff --git a/chardev_backend/Cargo.toml b/chardev_backend/Cargo.toml index 83b47b3..8a1b153 100644 --- a/chardev_backend/Cargo.toml +++ b/chardev_backend/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" license = "Mulan PSL v2" [dependencies] -vmm-sys-util = "0.11.0" +vmm-sys-util = "0.12.1" anyhow = "1.0" log = "0.4" libc = "0.2" diff --git a/cpu/Cargo.toml b/cpu/Cargo.toml index a665ede..1be3d7b 100644 --- a/cpu/Cargo.toml +++ b/cpu/Cargo.toml @@ -9,11 +9,11 @@ description = "CPU emulation" [dependencies] thiserror = "1.0" anyhow = "1.0" -kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] } +kvm-bindings = { version = "0.10.0", features = ["fam-wrappers"] } nix = { version = "0.26.2", default-features = false, features = ["fs", "feature"] } log = "0.4" libc = "0.2" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" machine_manager = { path = "../machine_manager" } migration = { path = "../migration" } migration_derive = { path = "../migration/migration_derive" } diff --git a/devices/Cargo.toml b/devices/Cargo.toml index 316752a..2e6574e 100644 --- a/devices/Cargo.toml +++ b/devices/Cargo.toml @@ -12,7 +12,7 @@ anyhow = "1.0" libc = "0.2" log = "0.4" serde = { version = "1.0", features = ["derive"] } -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" byteorder = "1.4.3" drm-fourcc = ">=2.2.0" once_cell = "1.18.0" diff --git a/hypervisor/Cargo.toml b/hypervisor/Cargo.toml index df70a5b..97f4190 100644 --- a/hypervisor/Cargo.toml +++ b/hypervisor/Cargo.toml @@ -8,11 +8,11 @@ license = "Mulan PSL v2" [dependencies] anyhow = "1.0" thiserror = "1.0" -kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] } -kvm-ioctls = "0.15.0" +kvm-bindings = { version = "0.10.0", features = ["fam-wrappers"] } +kvm-ioctls = "0.19.1" libc = "0.2" log = "0.4" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" address_space = { path = "../address_space" } cpu = { path = "../cpu" } devices = { path = "../devices" } diff --git a/machine/Cargo.toml b/machine/Cargo.toml index 2f677f8..e5d9253 100644 --- a/machine/Cargo.toml +++ b/machine/Cargo.toml @@ -10,7 +10,7 @@ description = "Emulation machines" log = "0.4" libc = "0.2" serde_json = "1.0" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" thiserror = "1.0" anyhow = "1.0" acpi = { path = "../acpi" } diff --git a/machine_manager/Cargo.toml b/machine_manager/Cargo.toml index 29e151b..ec787bc 100644 --- a/machine_manager/Cargo.toml +++ b/machine_manager/Cargo.toml @@ -12,7 +12,7 @@ regex = "1" log = "0.4" libc = "0.2" serde_json = "1.0" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" hex = "0.4.3" serde = { version = "1.0", features = ["derive"] } strum = "0.24.1" diff --git a/migration/Cargo.toml b/migration/Cargo.toml index e1469d9..25769c8 100644 --- a/migration/Cargo.toml +++ b/migration/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Huawei StratoVirt Team"] edition = "2021" [dependencies] -kvm-ioctls = "0.15.0" +kvm-ioctls = "0.19.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" once_cell = "1.18.0" diff --git a/tests/mod_test/Cargo.toml b/tests/mod_test/Cargo.toml index 9ccebc0..9b144af 100644 --- a/tests/mod_test/Cargo.toml +++ b/tests/mod_test/Cargo.toml @@ -8,7 +8,7 @@ license = "Mulan PSL v2" [dependencies] rand = "0.8.5" hex = "0.4.3" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" anyhow = "1.0" serde_json = "1.0" libc = "0.2" diff --git a/trace/Cargo.toml b/trace/Cargo.toml index 267a356..ad6cf1b 100644 --- a/trace/Cargo.toml +++ b/trace/Cargo.toml @@ -12,7 +12,7 @@ lazy_static = "1.4.0" regex = "1" anyhow = "1.0" trace_generator = { path = "trace_generator" } -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" [features] trace_to_logger = [] diff --git a/ui/Cargo.toml b/ui/Cargo.toml index 56f2b6f..b7faa42 100644 --- a/ui/Cargo.toml +++ b/ui/Cargo.toml @@ -12,7 +12,7 @@ anyhow = "1.0" libc = "0.2" log = "0.4" serde_json = "1.0" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" once_cell = "1.18.0" sscanf = "0.4.1" bitintr = "0.3.0" diff --git a/util/Cargo.toml b/util/Cargo.toml index 95aefcd..5bf691e 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -11,12 +11,12 @@ license = "Mulan PSL v2" arc-swap = "1.6.0" thiserror = "1.0" anyhow = "1.0" -kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] } +kvm-bindings = { version = "0.10.0", features = ["fam-wrappers"] } nix = { version = "0.26.2", default-features = false, features = ["poll", "term", "time", "signal", "fs", "feature"] } libc = "0.2" libloading = "0.7.4" log = { version = "0.4", features = ["std"]} -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" byteorder = "1.4.3" once_cell = "1.18.0" io-uring = "0.6.0" diff --git a/vendor/bitflags-1.3.2/.cargo-checksum.json b/vendor/bitflags-1.3.2/.cargo-checksum.json new file mode 100644 index 0000000..7e8d470 --- /dev/null +++ b/vendor/bitflags-1.3.2/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"CHANGELOG.md":"d362fc1fccaaf4d421bcf0fe8b80ddb4f625dade0c1ee52d08bd0b95509a49d1","CODE_OF_CONDUCT.md":"42634d0f6d922f49857175af991802822f7f920487aefa2ee250a50d12251a66","Cargo.toml":"87aced7532a7974eb37ab5fe6037f0abafc36d6b2d74891ecd2bf2f14f50d11e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"baa8604f8afb34fd93b9c79729daafb884dedcaf34023e4af8ad037d916061fd","src/example_generated.rs":"e43eb59e90f317f38d436670a6067d2fd9eb35fb319fe716184e4a04e24ed1b2","src/lib.rs":"e6477688535ee326d27238aeedc9cb4320ac35b9d17a4deda09e0587b0ccdbd4","tests/basic.rs":"146f1cbf6279bc609242cd3349f29cb21b41294f5e4921875f5ec95bd83529a2","tests/compile-fail/impls/copy.rs":"b791371237ddc75a7c04d2130e03b462c9c00a80dca08bd45aa97433d9c0d13a","tests/compile-fail/impls/copy.stderr.beta":"77d83484ce221d4b6ff2f7de843929a452d779fcfff428122710dd8218c298e3","tests/compile-fail/impls/eq.rs":"0cee8b9e07d537890e0189710293b53972d0fab63c09366f33c391065afafa99","tests/compile-fail/impls/eq.stderr.beta":"381fc6143d45ce76d7cecc47aa59cb69fe5e79c0b60a4a85d5c6163b400b3cc7","tests/compile-fail/non_integer_base/all_defined.rs":"95e14cad9e94560262f2862c3c01865ac30369b69da1001b0e7285cb55e6cb75","tests/compile-fail/non_integer_base/all_defined.stderr.beta":"1760739a276690903bb03844025587d37939f5dfcbfab309db3c86f32bdbf748","tests/compile-fail/non_integer_base/all_missing.rs":"b3d9da619d23213731ba2581aa7999c796c3c79aaf4f0ee6b11ceec08a11537f","tests/compile-fail/non_integer_base/all_missing.stderr.beta":"37e102290d3867e175b21976be798939f294efb17580d5b51e7b17b590d55132","tests/compile-fail/visibility/private_field.rs":"38e4d3fe6471829360d12c8d09b097f6a21aa93fb51eac3b215d96bdae23316b","tests/compile-fail/visibility/private_field.stderr.beta":"5aa24a3ebb39326f31927721c5017b8beb66c3e501fb865a3fa814c9763bfa0f","tests/compile-fail/visibility/private_flags.rs":"2ce4235802aa4e9c96c4e77d9e31d8401ef58dcda4741325184f0764ab1fe393","tests/compile-fail/visibility/private_flags.stderr.beta":"f3eb9f7baf2689258f3519ff7ee5c6ec3c237264ebcfe63f40c40f2023e5022f","tests/compile-fail/visibility/pub_const.rs":"8f813a97ac518c5ea8ac65b184101912452384afaf7b8d6c5e62f8370eca3c0a","tests/compile-fail/visibility/pub_const.stderr.beta":"823976ae1794d7f5372e2ec9aabba497e7bb88004722904c38da342ed98e8962","tests/compile-pass/impls/convert.rs":"88fe80bfb9cd5779f0e1d92c9ec02a8b6bb67e334c07f2309e9c0ba5ef776eb0","tests/compile-pass/impls/default.rs":"c508f9a461691f44b45142fa5ad599f02326e1de4c0cbca6c0593f4652eba109","tests/compile-pass/impls/inherent_methods.rs":"ecc26388e9a394bfa7a5bb69a5d621ab3d4d1e53f28f657bb8e78fe79f437913","tests/compile-pass/redefinition/core.rs":"ff5b6e72f87acc6ebb12405d3c0f6e3fa62e669933656a454bb63b30ea44179c","tests/compile-pass/redefinition/stringify.rs":"1edbce42b900c14425d7ffa14e83e165ebe452d7dccd8c0a8a821bdec64f5c93","tests/compile-pass/repr/c.rs":"6fda17f7c2edfcd155314579e83d0fc8a16209e400f1f9a5ca77bd9a799041f2","tests/compile-pass/repr/transparent.rs":"6cdc87a2137d8a4e0c8ce9b6cba83c82255f8ea125951bf614418685600489ce","tests/compile-pass/visibility/bits_field.rs":"1f3e5ba5a047440066a9f6bf7b7af33f5b06f6b1da3dd9af6886168199a7ea0a","tests/compile-pass/visibility/pub_in.rs":"e95312ff60966d42ec4bc00225507895a9b8ec24056ce6a9edd9145be35d730f","tests/compile.rs":"f27c67a7dd183ca30efea1b6e0880e3469a6dd63b92b1fd711c082df182c9eec"},"package":"bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"} \ No newline at end of file diff --git a/vendor/bitflags-1.3.2/CHANGELOG.md b/vendor/bitflags-1.3.2/CHANGELOG.md new file mode 100644 index 0000000..12fea16 --- /dev/null +++ b/vendor/bitflags-1.3.2/CHANGELOG.md @@ -0,0 +1,206 @@ +# 1.3.2 + +- Allow `non_snake_case` in generated flags types ([#256]) + +[#252]: https://github.com/bitflags/bitflags/pull/256 + +# 1.3.1 + +- Revert unconditional `#[repr(transparent)]` ([#252]) + +[#252]: https://github.com/bitflags/bitflags/pull/252 + +# 1.3.0 (yanked) + +- Add `#[repr(transparent)]` ([#187]) + +- End `empty` doc comment with full stop ([#202]) + +- Fix typo in crate root docs ([#206]) + +- Document from_bits_unchecked unsafety ([#207]) + +- Let `is_all` ignore extra bits ([#211]) + +- Allows empty flag definition ([#225]) + +- Making crate accessible from std ([#227]) + +- Make `from_bits` a const fn ([#229]) + +- Allow multiple bitflags structs in one macro invocation ([#235]) + +- Add named functions to perform set operations ([#244]) + +- Fix typos in method docs ([#245]) + +- Modernization of the `bitflags` macro to take advantage of newer features and 2018 idioms ([#246]) + +- Fix regression (in an unreleased feature) and simplify tests ([#247]) + +- Use `Self` and fix bug when overriding `stringify!` ([#249]) + +[#187]: https://github.com/bitflags/bitflags/pull/187 +[#202]: https://github.com/bitflags/bitflags/pull/202 +[#206]: https://github.com/bitflags/bitflags/pull/206 +[#207]: https://github.com/bitflags/bitflags/pull/207 +[#211]: https://github.com/bitflags/bitflags/pull/211 +[#225]: https://github.com/bitflags/bitflags/pull/225 +[#227]: https://github.com/bitflags/bitflags/pull/227 +[#229]: https://github.com/bitflags/bitflags/pull/229 +[#235]: https://github.com/bitflags/bitflags/pull/235 +[#244]: https://github.com/bitflags/bitflags/pull/244 +[#245]: https://github.com/bitflags/bitflags/pull/245 +[#246]: https://github.com/bitflags/bitflags/pull/246 +[#247]: https://github.com/bitflags/bitflags/pull/247 +[#249]: https://github.com/bitflags/bitflags/pull/249 + +# 1.2.1 + +- Remove extraneous `#[inline]` attributes ([#194]) + +[#194]: https://github.com/bitflags/bitflags/pull/194 + +# 1.2.0 + +- Fix typo: {Lower, Upper}Exp - {Lower, Upper}Hex ([#183]) + +- Add support for "unknown" bits ([#188]) + +[#183]: https://github.com/rust-lang-nursery/bitflags/pull/183 +[#188]: https://github.com/rust-lang-nursery/bitflags/pull/188 + +# 1.1.0 + +This is a re-release of `1.0.5`, which was yanked due to a bug in the RLS. + +# 1.0.5 + +- Use compiletest_rs flags supported by stable toolchain ([#171]) + +- Put the user provided attributes first ([#173]) + +- Make bitflags methods `const` on newer compilers ([#175]) + +[#171]: https://github.com/rust-lang-nursery/bitflags/pull/171 +[#173]: https://github.com/rust-lang-nursery/bitflags/pull/173 +[#175]: https://github.com/rust-lang-nursery/bitflags/pull/175 + +# 1.0.4 + +- Support Rust 2018 style macro imports ([#165]) + + ```rust + use bitflags::bitflags; + ``` + +[#165]: https://github.com/rust-lang-nursery/bitflags/pull/165 + +# 1.0.3 + +- Improve zero value flag handling and documentation ([#157]) + +[#157]: https://github.com/rust-lang-nursery/bitflags/pull/157 + +# 1.0.2 + +- 30% improvement in compile time of bitflags crate ([#156]) + +- Documentation improvements ([#153]) + +- Implementation cleanup ([#149]) + +[#156]: https://github.com/rust-lang-nursery/bitflags/pull/156 +[#153]: https://github.com/rust-lang-nursery/bitflags/pull/153 +[#149]: https://github.com/rust-lang-nursery/bitflags/pull/149 + +# 1.0.1 +- Add support for `pub(restricted)` specifier on the bitflags struct ([#135]) +- Optimize performance of `all()` when called from a separate crate ([#136]) + +[#135]: https://github.com/rust-lang-nursery/bitflags/pull/135 +[#136]: https://github.com/rust-lang-nursery/bitflags/pull/136 + +# 1.0.0 +- **[breaking change]** Macro now generates [associated constants](https://doc.rust-lang.org/reference/items.html#associated-constants) ([#24]) + +- **[breaking change]** Minimum supported version is Rust **1.20**, due to usage of associated constants + +- After being broken in 0.9, the `#[deprecated]` attribute is now supported again ([#112]) + +- Other improvements to unit tests and documentation ([#106] and [#115]) + +[#24]: https://github.com/rust-lang-nursery/bitflags/pull/24 +[#106]: https://github.com/rust-lang-nursery/bitflags/pull/106 +[#112]: https://github.com/rust-lang-nursery/bitflags/pull/112 +[#115]: https://github.com/rust-lang-nursery/bitflags/pull/115 + +## How to update your code to use associated constants +Assuming the following structure definition: +```rust +bitflags! { + struct Something: u8 { + const FOO = 0b01, + const BAR = 0b10 + } +} +``` +In 0.9 and older you could do: +```rust +let x = FOO.bits | BAR.bits; +``` +Now you must use: +```rust +let x = Something::FOO.bits | Something::BAR.bits; +``` + +# 0.9.1 +- Fix the implementation of `Formatting` traits when other formatting traits were present in scope ([#105]) + +[#105]: https://github.com/rust-lang-nursery/bitflags/pull/105 + +# 0.9.0 +- **[breaking change]** Use struct keyword instead of flags to define bitflag types ([#84]) + +- **[breaking change]** Terminate const items with semicolons instead of commas ([#87]) + +- Implement the `Hex`, `Octal`, and `Binary` formatting traits ([#86]) + +- Printing an empty flag value with the `Debug` trait now prints "(empty)" instead of nothing ([#85]) + +- The `bitflags!` macro can now be used inside of a fn body, to define a type local to that function ([#74]) + +[#74]: https://github.com/rust-lang-nursery/bitflags/pull/74 +[#84]: https://github.com/rust-lang-nursery/bitflags/pull/84 +[#85]: https://github.com/rust-lang-nursery/bitflags/pull/85 +[#86]: https://github.com/rust-lang-nursery/bitflags/pull/86 +[#87]: https://github.com/rust-lang-nursery/bitflags/pull/87 + +# 0.8.2 +- Update feature flag used when building bitflags as a dependency of the Rust toolchain + +# 0.8.1 +- Allow bitflags to be used as a dependency of the Rust toolchain + +# 0.8.0 +- Add support for the experimental `i128` and `u128` integer types ([#57]) +- Add set method: `flags.set(SOME_FLAG, true)` or `flags.set(SOME_FLAG, false)` ([#55]) + This may break code that defines its own set method + +[#55]: https://github.com/rust-lang-nursery/bitflags/pull/55 +[#57]: https://github.com/rust-lang-nursery/bitflags/pull/57 + +# 0.7.1 +*(yanked)* + +# 0.7.0 +- Implement the Extend trait ([#49]) +- Allow definitions inside the `bitflags!` macro to refer to items imported from other modules ([#51]) + +[#49]: https://github.com/rust-lang-nursery/bitflags/pull/49 +[#51]: https://github.com/rust-lang-nursery/bitflags/pull/51 + +# 0.6.0 +- The `no_std` feature was removed as it is now the default +- The `assignment_operators` feature was remove as it is now enabled by default +- Some clippy suggestions have been applied diff --git a/vendor/bitflags-1.3.2/CODE_OF_CONDUCT.md b/vendor/bitflags-1.3.2/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f7add90 --- /dev/null +++ b/vendor/bitflags-1.3.2/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at coc@senaite.org. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org \ No newline at end of file diff --git a/vendor/bitflags-1.3.2/Cargo.toml b/vendor/bitflags-1.3.2/Cargo.toml new file mode 100644 index 0000000..9d54c72 --- /dev/null +++ b/vendor/bitflags-1.3.2/Cargo.toml @@ -0,0 +1,58 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "bitflags" +version = "1.3.2" +authors = ["The Rust Project Developers"] +exclude = ["bors.toml"] +description = "A macro to generate structures which behave like bitflags.\n" +homepage = "https://github.com/bitflags/bitflags" +documentation = "https://docs.rs/bitflags" +readme = "README.md" +keywords = ["bit", "bitmask", "bitflags", "flags"] +categories = ["no-std"] +license = "MIT/Apache-2.0" +repository = "https://github.com/bitflags/bitflags" +[package.metadata.docs.rs] +features = ["example_generated"] +[dependencies.compiler_builtins] +version = "0.1.2" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" +[dev-dependencies.rustversion] +version = "1.0" + +[dev-dependencies.serde] +version = "1.0" + +[dev-dependencies.serde_derive] +version = "1.0" + +[dev-dependencies.serde_json] +version = "1.0" + +[dev-dependencies.trybuild] +version = "1.0" + +[dev-dependencies.walkdir] +version = "2.3" + +[features] +default = [] +example_generated = [] +rustc-dep-of-std = ["core", "compiler_builtins"] diff --git a/vendor/bitflags-1.3.2/LICENSE-APACHE b/vendor/bitflags-1.3.2/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/vendor/bitflags-1.3.2/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/bitflags-1.3.2/LICENSE-MIT b/vendor/bitflags-1.3.2/LICENSE-MIT new file mode 100644 index 0000000..39d4bdb --- /dev/null +++ b/vendor/bitflags-1.3.2/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/vendor/bitflags-1.3.2/README.md b/vendor/bitflags-1.3.2/README.md new file mode 100644 index 0000000..0da0f85 --- /dev/null +++ b/vendor/bitflags-1.3.2/README.md @@ -0,0 +1,32 @@ +bitflags +======== + +[![Rust](https://github.com/bitflags/bitflags/workflows/Rust/badge.svg)](https://github.com/bitflags/bitflags/actions) +[![Join the chat at https://gitter.im/bitflags/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bitflags/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge) +[![Latest version](https://img.shields.io/crates/v/bitflags.svg)](https://crates.io/crates/bitflags) +[![Documentation](https://docs.rs/bitflags/badge.svg)](https://docs.rs/bitflags) +![License](https://img.shields.io/crates/l/bitflags.svg) + +A Rust macro to generate structures which behave like a set of bitflags + +- [Documentation](https://docs.rs/bitflags) +- [Release notes](https://github.com/bitflags/bitflags/releases) + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +bitflags = "1.3" +``` + +and this to your source code: + +```rust +use bitflags::bitflags; +``` + +## Rust Version Support + +The minimum supported Rust version is 1.46 due to use of associated constants and const functions. diff --git a/vendor/bitflags-1.3.2/src/example_generated.rs b/vendor/bitflags-1.3.2/src/example_generated.rs new file mode 100644 index 0000000..cf188d9 --- /dev/null +++ b/vendor/bitflags-1.3.2/src/example_generated.rs @@ -0,0 +1,14 @@ +//! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS +//! CRATE**. + +bitflags! { + /// This is the same `Flags` struct defined in the [crate level example](../index.html#example). + /// Note that this struct is just for documentation purposes only, it must not be used outside + /// this crate. + pub struct Flags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; + const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + } +} diff --git a/vendor/bitflags-1.3.2/src/lib.rs b/vendor/bitflags-1.3.2/src/lib.rs new file mode 100644 index 0000000..935e432 --- /dev/null +++ b/vendor/bitflags-1.3.2/src/lib.rs @@ -0,0 +1,1729 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A typesafe bitmask flag generator useful for sets of C-style bitmask flags. +//! It can be used for creating typesafe wrappers around C APIs. +//! +//! The `bitflags!` macro generates `struct`s that manage a set of flags. The +//! flags should only be defined for integer types, otherwise unexpected type +//! errors may occur at compile time. +//! +//! # Example +//! +//! ``` +//! use bitflags::bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! const ABC = Self::A.bits | Self::B.bits | Self::C.bits; +//! } +//! } +//! +//! fn main() { +//! let e1 = Flags::A | Flags::C; +//! let e2 = Flags::B | Flags::C; +//! assert_eq!((e1 | e2), Flags::ABC); // union +//! assert_eq!((e1 & e2), Flags::C); // intersection +//! assert_eq!((e1 - e2), Flags::A); // set difference +//! assert_eq!(!e2, Flags::A); // set complement +//! } +//! ``` +//! +//! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code +//! generated by the above `bitflags!` expansion. +//! +//! The generated `struct`s can also be extended with type and trait +//! implementations: +//! +//! ``` +//! use std::fmt; +//! +//! use bitflags::bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! } +//! } +//! +//! impl Flags { +//! pub fn clear(&mut self) { +//! self.bits = 0; // The `bits` field can be accessed from within the +//! // same module where the `bitflags!` macro was invoked. +//! } +//! } +//! +//! impl fmt::Display for Flags { +//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +//! write!(f, "hi!") +//! } +//! } +//! +//! fn main() { +//! let mut flags = Flags::A | Flags::B; +//! flags.clear(); +//! assert!(flags.is_empty()); +//! assert_eq!(format!("{}", flags), "hi!"); +//! assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); +//! assert_eq!(format!("{:?}", Flags::B), "B"); +//! } +//! ``` +//! +//! # Visibility +//! +//! The generated structs and their associated flag constants are not exported +//! out of the current module by default. A definition can be exported out of +//! the current module by adding `pub` before `struct`: +//! +//! ``` +//! mod example { +//! use bitflags::bitflags; +//! +//! bitflags! { +//! pub struct Flags1: u32 { +//! const A = 0b00000001; +//! } +//! +//! # pub +//! struct Flags2: u32 { +//! const B = 0b00000010; +//! } +//! } +//! } +//! +//! fn main() { +//! let flag1 = example::Flags1::A; +//! let flag2 = example::Flags2::B; // error: const `B` is private +//! } +//! ``` +//! +//! # Attributes +//! +//! Attributes can be attached to the generated `struct`s by placing them +//! before the `struct` keyword. +//! +//! ## Representations +//! +//! It's valid to add a `#[repr(C)]` or `#[repr(transparent)]` attribute to a type +//! generated by `bitflags!`. In these cases, the type is guaranteed to be a newtype. +//! +//! ``` +//! use bitflags::bitflags; +//! +//! bitflags! { +//! #[repr(transparent)] +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! } +//! } +//! ``` +//! +//! # Trait implementations +//! +//! The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash` +//! traits are automatically derived for the `struct`s using the `derive` attribute. +//! Additional traits can be derived by providing an explicit `derive` +//! attribute on `struct`. +//! +//! The `Extend` and `FromIterator` traits are implemented for the `struct`s, +//! too: `Extend` adds the union of the instances of the `struct` iterated over, +//! while `FromIterator` calculates the union. +//! +//! The `Binary`, `Debug`, `LowerHex`, `Octal` and `UpperHex` traits are also +//! implemented by displaying the bits value of the internal struct. +//! +//! ## Operators +//! +//! The following operator traits are implemented for the generated `struct`s: +//! +//! - `BitOr` and `BitOrAssign`: union +//! - `BitAnd` and `BitAndAssign`: intersection +//! - `BitXor` and `BitXorAssign`: toggle +//! - `Sub` and `SubAssign`: set difference +//! - `Not`: set complement +//! +//! # Methods +//! +//! The following methods are defined for the generated `struct`s: +//! +//! - `empty`: an empty set of flags +//! - `all`: the set of all defined flags +//! - `bits`: the raw value of the flags currently stored +//! - `from_bits`: convert from underlying bit representation, unless that +//! representation contains bits that do not correspond to a +//! defined flag +//! - `from_bits_truncate`: convert from underlying bit representation, dropping +//! any bits that do not correspond to defined flags +//! - `from_bits_unchecked`: convert from underlying bit representation, keeping +//! all bits (even those not corresponding to defined +//! flags) +//! - `is_empty`: `true` if no flags are currently stored +//! - `is_all`: `true` if currently set flags exactly equal all defined flags +//! - `intersects`: `true` if there are flags common to both `self` and `other` +//! - `contains`: `true` if all of the flags in `other` are contained within `self` +//! - `insert`: inserts the specified flags in-place +//! - `remove`: removes the specified flags in-place +//! - `toggle`: the specified flags will be inserted if not present, and removed +//! if they are. +//! - `set`: inserts or removes the specified flags depending on the passed value +//! - `intersection`: returns a new set of flags, containing only the flags present +//! in both `self` and `other` (the argument to the function). +//! - `union`: returns a new set of flags, containing any flags present in +//! either `self` or `other` (the argument to the function). +//! - `difference`: returns a new set of flags, containing all flags present in +//! `self` without any of the flags present in `other` (the +//! argument to the function). +//! - `symmetric_difference`: returns a new set of flags, containing all flags +//! present in either `self` or `other` (the argument +//! to the function), but not both. +//! - `complement`: returns a new set of flags, containing all flags which are +//! not set in `self`, but which are allowed for this type. +//! +//! ## Default +//! +//! The `Default` trait is not automatically implemented for the generated structs. +//! +//! If your default value is equal to `0` (which is the same value as calling `empty()` +//! on the generated struct), you can simply derive `Default`: +//! +//! ``` +//! use bitflags::bitflags; +//! +//! bitflags! { +//! // Results in default value with bits: 0 +//! #[derive(Default)] +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! } +//! } +//! +//! fn main() { +//! let derived_default: Flags = Default::default(); +//! assert_eq!(derived_default.bits(), 0); +//! } +//! ``` +//! +//! If your default value is not equal to `0` you need to implement `Default` yourself: +//! +//! ``` +//! use bitflags::bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const A = 0b00000001; +//! const B = 0b00000010; +//! const C = 0b00000100; +//! } +//! } +//! +//! // explicit `Default` implementation +//! impl Default for Flags { +//! fn default() -> Flags { +//! Flags::A | Flags::C +//! } +//! } +//! +//! fn main() { +//! let implemented_default: Flags = Default::default(); +//! assert_eq!(implemented_default, (Flags::A | Flags::C)); +//! } +//! ``` +//! +//! # Zero Flags +//! +//! Flags with a value equal to zero will have some strange behavior that one should be aware of. +//! +//! ``` +//! use bitflags::bitflags; +//! +//! bitflags! { +//! struct Flags: u32 { +//! const NONE = 0b00000000; +//! const SOME = 0b00000001; +//! } +//! } +//! +//! fn main() { +//! let empty = Flags::empty(); +//! let none = Flags::NONE; +//! let some = Flags::SOME; +//! +//! // Zero flags are treated as always present +//! assert!(empty.contains(Flags::NONE)); +//! assert!(none.contains(Flags::NONE)); +//! assert!(some.contains(Flags::NONE)); +//! +//! // Zero flags will be ignored when testing for emptiness +//! assert!(none.is_empty()); +//! } +//! ``` +//! +//! Users should generally avoid defining a flag with a value of zero. + +#![cfg_attr(not(test), no_std)] +#![doc(html_root_url = "https://docs.rs/bitflags/1.3.2")] + +#[doc(hidden)] +pub extern crate core as _core; + +/// The macro used to generate the flag structures. +/// +/// See the [crate level docs](../bitflags/index.html) for complete documentation. +/// +/// # Example +/// +/// ``` +/// use bitflags::bitflags; +/// +/// bitflags! { +/// struct Flags: u32 { +/// const A = 0b00000001; +/// const B = 0b00000010; +/// const C = 0b00000100; +/// const ABC = Self::A.bits | Self::B.bits | Self::C.bits; +/// } +/// } +/// +/// fn main() { +/// let e1 = Flags::A | Flags::C; +/// let e2 = Flags::B | Flags::C; +/// assert_eq!((e1 | e2), Flags::ABC); // union +/// assert_eq!((e1 & e2), Flags::C); // intersection +/// assert_eq!((e1 - e2), Flags::A); // set difference +/// assert_eq!(!e2, Flags::A); // set complement +/// } +/// ``` +/// +/// The generated `struct`s can also be extended with type and trait +/// implementations: +/// +/// ``` +/// use std::fmt; +/// +/// use bitflags::bitflags; +/// +/// bitflags! { +/// struct Flags: u32 { +/// const A = 0b00000001; +/// const B = 0b00000010; +/// } +/// } +/// +/// impl Flags { +/// pub fn clear(&mut self) { +/// self.bits = 0; // The `bits` field can be accessed from within the +/// // same module where the `bitflags!` macro was invoked. +/// } +/// } +/// +/// impl fmt::Display for Flags { +/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// write!(f, "hi!") +/// } +/// } +/// +/// fn main() { +/// let mut flags = Flags::A | Flags::B; +/// flags.clear(); +/// assert!(flags.is_empty()); +/// assert_eq!(format!("{}", flags), "hi!"); +/// assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); +/// assert_eq!(format!("{:?}", Flags::B), "B"); +/// } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! bitflags { + ( + $(#[$outer:meta])* + $vis:vis struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:ident = $value:expr; + )* + } + + $($t:tt)* + ) => { + $(#[$outer])* + #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] + $vis struct $BitFlags { + bits: $T, + } + + __impl_bitflags! { + $BitFlags: $T { + $( + $(#[$inner $($args)*])* + $Flag = $value; + )* + } + } + + bitflags! { + $($t)* + } + }; + () => {}; +} + +// A helper macro to implement the `all` function. +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! __impl_all_bitflags { + ( + $BitFlags:ident: $T:ty { + $( + $(#[$attr:ident $($args:tt)*])* + $Flag:ident = $value:expr; + )+ + } + ) => { + // See `Debug::fmt` for why this approach is taken. + #[allow(non_snake_case)] + trait __BitFlags { + $( + const $Flag: $T = 0; + )+ + } + #[allow(non_snake_case)] + impl __BitFlags for $BitFlags { + $( + __impl_bitflags! { + #[allow(deprecated)] + $(? #[$attr $($args)*])* + const $Flag: $T = Self::$Flag.bits; + } + )+ + } + Self { bits: $(::$Flag)|+ } + }; + ( + $BitFlags:ident: $T:ty { } + ) => { + Self { bits: 0 } + }; +} + +#[macro_export(local_inner_macros)] +#[doc(hidden)] +macro_rules! __impl_bitflags { + ( + $BitFlags:ident: $T:ty { + $( + $(#[$attr:ident $($args:tt)*])* + $Flag:ident = $value:expr; + )* + } + ) => { + impl $crate::_core::fmt::Debug for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + // This convoluted approach is to handle #[cfg]-based flag + // omission correctly. For example it needs to support: + // + // #[cfg(unix)] const A: Flag = /* ... */; + // #[cfg(windows)] const B: Flag = /* ... */; + + // Unconditionally define a check for every flag, even disabled + // ones. + #[allow(non_snake_case)] + trait __BitFlags { + $( + #[inline] + fn $Flag(&self) -> bool { false } + )* + } + + // Conditionally override the check for just those flags that + // are not #[cfg]ed away. + #[allow(non_snake_case)] + impl __BitFlags for $BitFlags { + $( + __impl_bitflags! { + #[allow(deprecated)] + #[inline] + $(? #[$attr $($args)*])* + fn $Flag(&self) -> bool { + if Self::$Flag.bits == 0 && self.bits != 0 { + false + } else { + self.bits & Self::$Flag.bits == Self::$Flag.bits + } + } + } + )* + } + + let mut first = true; + $( + if ::$Flag(self) { + if !first { + f.write_str(" | ")?; + } + first = false; + f.write_str($crate::_core::stringify!($Flag))?; + } + )* + let extra_bits = self.bits & !Self::all().bits(); + if extra_bits != 0 { + if !first { + f.write_str(" | ")?; + } + first = false; + f.write_str("0x")?; + $crate::_core::fmt::LowerHex::fmt(&extra_bits, f)?; + } + if first { + f.write_str("(empty)")?; + } + Ok(()) + } + } + impl $crate::_core::fmt::Binary for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::Binary::fmt(&self.bits, f) + } + } + impl $crate::_core::fmt::Octal for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::Octal::fmt(&self.bits, f) + } + } + impl $crate::_core::fmt::LowerHex for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::LowerHex::fmt(&self.bits, f) + } + } + impl $crate::_core::fmt::UpperHex for $BitFlags { + fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { + $crate::_core::fmt::UpperHex::fmt(&self.bits, f) + } + } + + #[allow(dead_code)] + impl $BitFlags { + $( + $(#[$attr $($args)*])* + pub const $Flag: Self = Self { bits: $value }; + )* + + /// Returns an empty set of flags. + #[inline] + pub const fn empty() -> Self { + Self { bits: 0 } + } + + /// Returns the set containing all flags. + #[inline] + pub const fn all() -> Self { + __impl_all_bitflags! { + $BitFlags: $T { + $( + $(#[$attr $($args)*])* + $Flag = $value; + )* + } + } + } + + /// Returns the raw value of the flags currently stored. + #[inline] + pub const fn bits(&self) -> $T { + self.bits + } + + /// Convert from underlying bit representation, unless that + /// representation contains bits that do not correspond to a flag. + #[inline] + pub const fn from_bits(bits: $T) -> $crate::_core::option::Option { + if (bits & !Self::all().bits()) == 0 { + $crate::_core::option::Option::Some(Self { bits }) + } else { + $crate::_core::option::Option::None + } + } + + /// Convert from underlying bit representation, dropping any bits + /// that do not correspond to flags. + #[inline] + pub const fn from_bits_truncate(bits: $T) -> Self { + Self { bits: bits & Self::all().bits } + } + + /// Convert from underlying bit representation, preserving all + /// bits (even those not corresponding to a defined flag). + /// + /// # Safety + /// + /// The caller of the `bitflags!` macro can chose to allow or + /// disallow extra bits for their bitflags type. + /// + /// The caller of `from_bits_unchecked()` has to ensure that + /// all bits correspond to a defined flag or that extra bits + /// are valid for this bitflags type. + #[inline] + pub const unsafe fn from_bits_unchecked(bits: $T) -> Self { + Self { bits } + } + + /// Returns `true` if no flags are currently stored. + #[inline] + pub const fn is_empty(&self) -> bool { + self.bits() == Self::empty().bits() + } + + /// Returns `true` if all flags are currently set. + #[inline] + pub const fn is_all(&self) -> bool { + Self::all().bits | self.bits == self.bits + } + + /// Returns `true` if there are flags common to both `self` and `other`. + #[inline] + pub const fn intersects(&self, other: Self) -> bool { + !(Self { bits: self.bits & other.bits}).is_empty() + } + + /// Returns `true` if all of the flags in `other` are contained within `self`. + #[inline] + pub const fn contains(&self, other: Self) -> bool { + (self.bits & other.bits) == other.bits + } + + /// Inserts the specified flags in-place. + #[inline] + pub fn insert(&mut self, other: Self) { + self.bits |= other.bits; + } + + /// Removes the specified flags in-place. + #[inline] + pub fn remove(&mut self, other: Self) { + self.bits &= !other.bits; + } + + /// Toggles the specified flags in-place. + #[inline] + pub fn toggle(&mut self, other: Self) { + self.bits ^= other.bits; + } + + /// Inserts or removes the specified flags depending on the passed value. + #[inline] + pub fn set(&mut self, other: Self, value: bool) { + if value { + self.insert(other); + } else { + self.remove(other); + } + } + + /// Returns the intersection between the flags in `self` and + /// `other`. + /// + /// Specifically, the returned set contains only the flags which are + /// present in *both* `self` *and* `other`. + /// + /// This is equivalent to using the `&` operator (e.g. + /// [`ops::BitAnd`]), as in `flags & other`. + /// + /// [`ops::BitAnd`]: https://doc.rust-lang.org/std/ops/trait.BitAnd.html + #[inline] + #[must_use] + pub const fn intersection(self, other: Self) -> Self { + Self { bits: self.bits & other.bits } + } + + /// Returns the union of between the flags in `self` and `other`. + /// + /// Specifically, the returned set contains all flags which are + /// present in *either* `self` *or* `other`, including any which are + /// present in both (see [`Self::symmetric_difference`] if that + /// is undesirable). + /// + /// This is equivalent to using the `|` operator (e.g. + /// [`ops::BitOr`]), as in `flags | other`. + /// + /// [`ops::BitOr`]: https://doc.rust-lang.org/std/ops/trait.BitOr.html + #[inline] + #[must_use] + pub const fn union(self, other: Self) -> Self { + Self { bits: self.bits | other.bits } + } + + /// Returns the difference between the flags in `self` and `other`. + /// + /// Specifically, the returned set contains all flags present in + /// `self`, except for the ones present in `other`. + /// + /// It is also conceptually equivalent to the "bit-clear" operation: + /// `flags & !other` (and this syntax is also supported). + /// + /// This is equivalent to using the `-` operator (e.g. + /// [`ops::Sub`]), as in `flags - other`. + /// + /// [`ops::Sub`]: https://doc.rust-lang.org/std/ops/trait.Sub.html + #[inline] + #[must_use] + pub const fn difference(self, other: Self) -> Self { + Self { bits: self.bits & !other.bits } + } + + /// Returns the [symmetric difference][sym-diff] between the flags + /// in `self` and `other`. + /// + /// Specifically, the returned set contains the flags present which + /// are present in `self` or `other`, but that are not present in + /// both. Equivalently, it contains the flags present in *exactly + /// one* of the sets `self` and `other`. + /// + /// This is equivalent to using the `^` operator (e.g. + /// [`ops::BitXor`]), as in `flags ^ other`. + /// + /// [sym-diff]: https://en.wikipedia.org/wiki/Symmetric_difference + /// [`ops::BitXor`]: https://doc.rust-lang.org/std/ops/trait.BitXor.html + #[inline] + #[must_use] + pub const fn symmetric_difference(self, other: Self) -> Self { + Self { bits: self.bits ^ other.bits } + } + + /// Returns the complement of this set of flags. + /// + /// Specifically, the returned set contains all the flags which are + /// not set in `self`, but which are allowed for this type. + /// + /// Alternatively, it can be thought of as the set difference + /// between [`Self::all()`] and `self` (e.g. `Self::all() - self`) + /// + /// This is equivalent to using the `!` operator (e.g. + /// [`ops::Not`]), as in `!flags`. + /// + /// [`Self::all()`]: Self::all + /// [`ops::Not`]: https://doc.rust-lang.org/std/ops/trait.Not.html + #[inline] + #[must_use] + pub const fn complement(self) -> Self { + Self::from_bits_truncate(!self.bits) + } + + } + + impl $crate::_core::ops::BitOr for $BitFlags { + type Output = Self; + + /// Returns the union of the two sets of flags. + #[inline] + fn bitor(self, other: $BitFlags) -> Self { + Self { bits: self.bits | other.bits } + } + } + + impl $crate::_core::ops::BitOrAssign for $BitFlags { + /// Adds the set of flags. + #[inline] + fn bitor_assign(&mut self, other: Self) { + self.bits |= other.bits; + } + } + + impl $crate::_core::ops::BitXor for $BitFlags { + type Output = Self; + + /// Returns the left flags, but with all the right flags toggled. + #[inline] + fn bitxor(self, other: Self) -> Self { + Self { bits: self.bits ^ other.bits } + } + } + + impl $crate::_core::ops::BitXorAssign for $BitFlags { + /// Toggles the set of flags. + #[inline] + fn bitxor_assign(&mut self, other: Self) { + self.bits ^= other.bits; + } + } + + impl $crate::_core::ops::BitAnd for $BitFlags { + type Output = Self; + + /// Returns the intersection between the two sets of flags. + #[inline] + fn bitand(self, other: Self) -> Self { + Self { bits: self.bits & other.bits } + } + } + + impl $crate::_core::ops::BitAndAssign for $BitFlags { + /// Disables all flags disabled in the set. + #[inline] + fn bitand_assign(&mut self, other: Self) { + self.bits &= other.bits; + } + } + + impl $crate::_core::ops::Sub for $BitFlags { + type Output = Self; + + /// Returns the set difference of the two sets of flags. + #[inline] + fn sub(self, other: Self) -> Self { + Self { bits: self.bits & !other.bits } + } + } + + impl $crate::_core::ops::SubAssign for $BitFlags { + /// Disables all flags enabled in the set. + #[inline] + fn sub_assign(&mut self, other: Self) { + self.bits &= !other.bits; + } + } + + impl $crate::_core::ops::Not for $BitFlags { + type Output = Self; + + /// Returns the complement of this set of flags. + #[inline] + fn not(self) -> Self { + Self { bits: !self.bits } & Self::all() + } + } + + impl $crate::_core::iter::Extend<$BitFlags> for $BitFlags { + fn extend>(&mut self, iterator: T) { + for item in iterator { + self.insert(item) + } + } + } + + impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags { + fn from_iter>(iterator: T) -> Self { + let mut result = Self::empty(); + result.extend(iterator); + result + } + } + }; + + // Every attribute that the user writes on a const is applied to the + // corresponding const that we generate, but within the implementation of + // Debug and all() we want to ignore everything but #[cfg] attributes. In + // particular, including a #[deprecated] attribute on those items would fail + // to compile. + // https://github.com/bitflags/bitflags/issues/109 + // + // Input: + // + // ? #[cfg(feature = "advanced")] + // ? #[deprecated(note = "Use something else.")] + // ? #[doc = r"High quality documentation."] + // fn f() -> i32 { /* ... */ } + // + // Output: + // + // #[cfg(feature = "advanced")] + // fn f() -> i32 { /* ... */ } + ( + $(#[$filtered:meta])* + ? #[cfg $($cfgargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + fn $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + #[cfg $($cfgargs)*] + $(? #[$rest $($restargs)*])* + fn $($item)* + } + }; + ( + $(#[$filtered:meta])* + // $next != `cfg` + ? #[$next:ident $($nextargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + fn $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + // $next filtered out + $(? #[$rest $($restargs)*])* + fn $($item)* + } + }; + ( + $(#[$filtered:meta])* + fn $($item:tt)* + ) => { + $(#[$filtered])* + fn $($item)* + }; + + // Every attribute that the user writes on a const is applied to the + // corresponding const that we generate, but within the implementation of + // Debug and all() we want to ignore everything but #[cfg] attributes. In + // particular, including a #[deprecated] attribute on those items would fail + // to compile. + // https://github.com/bitflags/bitflags/issues/109 + // + // const version + // + // Input: + // + // ? #[cfg(feature = "advanced")] + // ? #[deprecated(note = "Use something else.")] + // ? #[doc = r"High quality documentation."] + // const f: i32 { /* ... */ } + // + // Output: + // + // #[cfg(feature = "advanced")] + // const f: i32 { /* ... */ } + ( + $(#[$filtered:meta])* + ? #[cfg $($cfgargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + const $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + #[cfg $($cfgargs)*] + $(? #[$rest $($restargs)*])* + const $($item)* + } + }; + ( + $(#[$filtered:meta])* + // $next != `cfg` + ? #[$next:ident $($nextargs:tt)*] + $(? #[$rest:ident $($restargs:tt)*])* + const $($item:tt)* + ) => { + __impl_bitflags! { + $(#[$filtered])* + // $next filtered out + $(? #[$rest $($restargs)*])* + const $($item)* + } + }; + ( + $(#[$filtered:meta])* + const $($item:tt)* + ) => { + $(#[$filtered])* + const $($item)* + }; +} + +#[cfg(feature = "example_generated")] +pub mod example_generated; + +#[cfg(test)] +mod tests { + use std::collections::hash_map::DefaultHasher; + use std::hash::{Hash, Hasher}; + + bitflags! { + #[doc = "> The first principle is that you must not fool yourself — and"] + #[doc = "> you are the easiest person to fool."] + #[doc = "> "] + #[doc = "> - Richard Feynman"] + #[derive(Default)] + struct Flags: u32 { + const A = 0b00000001; + #[doc = " macros are way better at generating code than trans is"] + const B = 0b00000010; + const C = 0b00000100; + #[doc = "* cmr bed"] + #[doc = "* strcat table"] + #[doc = " wait what?"] + const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + } + + struct _CfgFlags: u32 { + #[cfg(unix)] + const _CFG_A = 0b01; + #[cfg(windows)] + const _CFG_B = 0b01; + #[cfg(unix)] + const _CFG_C = Self::_CFG_A.bits | 0b10; + } + + struct AnotherSetOfFlags: i8 { + const ANOTHER_FLAG = -1_i8; + } + + struct LongFlags: u32 { + const LONG_A = 0b1111111111111111; + } + } + + bitflags! { + struct EmptyFlags: u32 { + } + } + + #[test] + fn test_bits() { + assert_eq!(Flags::empty().bits(), 0b00000000); + assert_eq!(Flags::A.bits(), 0b00000001); + assert_eq!(Flags::ABC.bits(), 0b00000111); + + assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00); + assert_eq!(AnotherSetOfFlags::ANOTHER_FLAG.bits(), !0_i8); + + assert_eq!(EmptyFlags::empty().bits(), 0b00000000); + } + + #[test] + fn test_from_bits() { + assert_eq!(Flags::from_bits(0), Some(Flags::empty())); + assert_eq!(Flags::from_bits(0b1), Some(Flags::A)); + assert_eq!(Flags::from_bits(0b10), Some(Flags::B)); + assert_eq!(Flags::from_bits(0b11), Some(Flags::A | Flags::B)); + assert_eq!(Flags::from_bits(0b1000), None); + + assert_eq!( + AnotherSetOfFlags::from_bits(!0_i8), + Some(AnotherSetOfFlags::ANOTHER_FLAG) + ); + + assert_eq!(EmptyFlags::from_bits(0), Some(EmptyFlags::empty())); + assert_eq!(EmptyFlags::from_bits(0b1), None); + } + + #[test] + fn test_from_bits_truncate() { + assert_eq!(Flags::from_bits_truncate(0), Flags::empty()); + assert_eq!(Flags::from_bits_truncate(0b1), Flags::A); + assert_eq!(Flags::from_bits_truncate(0b10), Flags::B); + assert_eq!(Flags::from_bits_truncate(0b11), (Flags::A | Flags::B)); + assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty()); + assert_eq!(Flags::from_bits_truncate(0b1001), Flags::A); + + assert_eq!( + AnotherSetOfFlags::from_bits_truncate(0_i8), + AnotherSetOfFlags::empty() + ); + + assert_eq!(EmptyFlags::from_bits_truncate(0), EmptyFlags::empty()); + assert_eq!(EmptyFlags::from_bits_truncate(0b1), EmptyFlags::empty()); + } + + #[test] + fn test_from_bits_unchecked() { + let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; + assert_eq!(unsafe { Flags::from_bits_unchecked(0) }, Flags::empty()); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b1) }, Flags::A); + assert_eq!(unsafe { Flags::from_bits_unchecked(0b10) }, Flags::B); + + assert_eq!( + unsafe { Flags::from_bits_unchecked(0b11) }, + (Flags::A | Flags::B) + ); + assert_eq!( + unsafe { Flags::from_bits_unchecked(0b1000) }, + (extra | Flags::empty()) + ); + assert_eq!( + unsafe { Flags::from_bits_unchecked(0b1001) }, + (extra | Flags::A) + ); + + let extra = unsafe { EmptyFlags::from_bits_unchecked(0b1000) }; + assert_eq!( + unsafe { EmptyFlags::from_bits_unchecked(0b1000) }, + (extra | EmptyFlags::empty()) + ); + } + + #[test] + fn test_is_empty() { + assert!(Flags::empty().is_empty()); + assert!(!Flags::A.is_empty()); + assert!(!Flags::ABC.is_empty()); + + assert!(!AnotherSetOfFlags::ANOTHER_FLAG.is_empty()); + + assert!(EmptyFlags::empty().is_empty()); + assert!(EmptyFlags::all().is_empty()); + } + + #[test] + fn test_is_all() { + assert!(Flags::all().is_all()); + assert!(!Flags::A.is_all()); + assert!(Flags::ABC.is_all()); + + let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; + assert!(!extra.is_all()); + assert!(!(Flags::A | extra).is_all()); + assert!((Flags::ABC | extra).is_all()); + + assert!(AnotherSetOfFlags::ANOTHER_FLAG.is_all()); + + assert!(EmptyFlags::all().is_all()); + assert!(EmptyFlags::empty().is_all()); + } + + #[test] + fn test_two_empties_do_not_intersect() { + let e1 = Flags::empty(); + let e2 = Flags::empty(); + assert!(!e1.intersects(e2)); + + assert!(AnotherSetOfFlags::ANOTHER_FLAG.intersects(AnotherSetOfFlags::ANOTHER_FLAG)); + } + + #[test] + fn test_empty_does_not_intersect_with_full() { + let e1 = Flags::empty(); + let e2 = Flags::ABC; + assert!(!e1.intersects(e2)); + } + + #[test] + fn test_disjoint_intersects() { + let e1 = Flags::A; + let e2 = Flags::B; + assert!(!e1.intersects(e2)); + } + + #[test] + fn test_overlapping_intersects() { + let e1 = Flags::A; + let e2 = Flags::A | Flags::B; + assert!(e1.intersects(e2)); + } + + #[test] + fn test_contains() { + let e1 = Flags::A; + let e2 = Flags::A | Flags::B; + assert!(!e1.contains(e2)); + assert!(e2.contains(e1)); + assert!(Flags::ABC.contains(e2)); + + assert!(AnotherSetOfFlags::ANOTHER_FLAG.contains(AnotherSetOfFlags::ANOTHER_FLAG)); + + assert!(EmptyFlags::empty().contains(EmptyFlags::empty())); + } + + #[test] + fn test_insert() { + let mut e1 = Flags::A; + let e2 = Flags::A | Flags::B; + e1.insert(e2); + assert_eq!(e1, e2); + + let mut e3 = AnotherSetOfFlags::empty(); + e3.insert(AnotherSetOfFlags::ANOTHER_FLAG); + assert_eq!(e3, AnotherSetOfFlags::ANOTHER_FLAG); + } + + #[test] + fn test_remove() { + let mut e1 = Flags::A | Flags::B; + let e2 = Flags::A | Flags::C; + e1.remove(e2); + assert_eq!(e1, Flags::B); + + let mut e3 = AnotherSetOfFlags::ANOTHER_FLAG; + e3.remove(AnotherSetOfFlags::ANOTHER_FLAG); + assert_eq!(e3, AnotherSetOfFlags::empty()); + } + + #[test] + fn test_operators() { + let e1 = Flags::A | Flags::C; + let e2 = Flags::B | Flags::C; + assert_eq!((e1 | e2), Flags::ABC); // union + assert_eq!((e1 & e2), Flags::C); // intersection + assert_eq!((e1 - e2), Flags::A); // set difference + assert_eq!(!e2, Flags::A); // set complement + assert_eq!(e1 ^ e2, Flags::A | Flags::B); // toggle + let mut e3 = e1; + e3.toggle(e2); + assert_eq!(e3, Flags::A | Flags::B); + + let mut m4 = AnotherSetOfFlags::empty(); + m4.toggle(AnotherSetOfFlags::empty()); + assert_eq!(m4, AnotherSetOfFlags::empty()); + } + + #[test] + fn test_operators_unchecked() { + let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; + let e1 = Flags::A | Flags::C | extra; + let e2 = Flags::B | Flags::C; + assert_eq!((e1 | e2), (Flags::ABC | extra)); // union + assert_eq!((e1 & e2), Flags::C); // intersection + assert_eq!((e1 - e2), (Flags::A | extra)); // set difference + assert_eq!(!e2, Flags::A); // set complement + assert_eq!(!e1, Flags::B); // set complement + assert_eq!(e1 ^ e2, Flags::A | Flags::B | extra); // toggle + let mut e3 = e1; + e3.toggle(e2); + assert_eq!(e3, Flags::A | Flags::B | extra); + } + + #[test] + fn test_set_ops_basic() { + let ab = Flags::A.union(Flags::B); + let ac = Flags::A.union(Flags::C); + let bc = Flags::B.union(Flags::C); + assert_eq!(ab.bits, 0b011); + assert_eq!(bc.bits, 0b110); + assert_eq!(ac.bits, 0b101); + + assert_eq!(ab, Flags::B.union(Flags::A)); + assert_eq!(ac, Flags::C.union(Flags::A)); + assert_eq!(bc, Flags::C.union(Flags::B)); + + assert_eq!(ac, Flags::A | Flags::C); + assert_eq!(bc, Flags::B | Flags::C); + assert_eq!(ab.union(bc), Flags::ABC); + + assert_eq!(ac, Flags::A | Flags::C); + assert_eq!(bc, Flags::B | Flags::C); + + assert_eq!(ac.union(bc), ac | bc); + assert_eq!(ac.union(bc), Flags::ABC); + assert_eq!(bc.union(ac), Flags::ABC); + + assert_eq!(ac.intersection(bc), ac & bc); + assert_eq!(ac.intersection(bc), Flags::C); + assert_eq!(bc.intersection(ac), Flags::C); + + assert_eq!(ac.difference(bc), ac - bc); + assert_eq!(bc.difference(ac), bc - ac); + assert_eq!(ac.difference(bc), Flags::A); + assert_eq!(bc.difference(ac), Flags::B); + + assert_eq!(bc.complement(), !bc); + assert_eq!(bc.complement(), Flags::A); + assert_eq!(ac.symmetric_difference(bc), Flags::A.union(Flags::B)); + assert_eq!(bc.symmetric_difference(ac), Flags::A.union(Flags::B)); + } + + #[test] + fn test_set_ops_const() { + // These just test that these compile and don't cause use-site panics + // (would be possible if we had some sort of UB) + const INTERSECT: Flags = Flags::all().intersection(Flags::C); + const UNION: Flags = Flags::A.union(Flags::C); + const DIFFERENCE: Flags = Flags::all().difference(Flags::A); + const COMPLEMENT: Flags = Flags::C.complement(); + const SYM_DIFFERENCE: Flags = UNION.symmetric_difference(DIFFERENCE); + assert_eq!(INTERSECT, Flags::C); + assert_eq!(UNION, Flags::A | Flags::C); + assert_eq!(DIFFERENCE, Flags::all() - Flags::A); + assert_eq!(COMPLEMENT, !Flags::C); + assert_eq!(SYM_DIFFERENCE, (Flags::A | Flags::C) ^ (Flags::all() - Flags::A)); + } + + #[test] + fn test_set_ops_unchecked() { + let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; + let e1 = Flags::A.union(Flags::C).union(extra); + let e2 = Flags::B.union(Flags::C); + assert_eq!(e1.bits, 0b1101); + assert_eq!(e1.union(e2), (Flags::ABC | extra)); + assert_eq!(e1.intersection(e2), Flags::C); + assert_eq!(e1.difference(e2), Flags::A | extra); + assert_eq!(e2.difference(e1), Flags::B); + assert_eq!(e2.complement(), Flags::A); + assert_eq!(e1.complement(), Flags::B); + assert_eq!(e1.symmetric_difference(e2), Flags::A | Flags::B | extra); // toggle + } + + #[test] + fn test_set_ops_exhaustive() { + // Define a flag that contains gaps to help exercise edge-cases, + // especially around "unknown" flags (e.g. ones outside of `all()` + // `from_bits_unchecked`). + // - when lhs and rhs both have different sets of unknown flags. + // - unknown flags at both ends, and in the middle + // - cases with "gaps". + bitflags! { + struct Test: u16 { + // Intentionally no `A` + const B = 0b000000010; + // Intentionally no `C` + const D = 0b000001000; + const E = 0b000010000; + const F = 0b000100000; + const G = 0b001000000; + // Intentionally no `H` + const I = 0b100000000; + } + } + let iter_test_flags = + || (0..=0b111_1111_1111).map(|bits| unsafe { Test::from_bits_unchecked(bits) }); + + for a in iter_test_flags() { + assert_eq!( + a.complement(), + Test::from_bits_truncate(!a.bits), + "wrong result: !({:?})", + a, + ); + assert_eq!(a.complement(), !a, "named != op: !({:?})", a); + for b in iter_test_flags() { + // Check that the named operations produce the expected bitwise + // values. + assert_eq!( + a.union(b).bits, + a.bits | b.bits, + "wrong result: `{:?}` | `{:?}`", + a, + b, + ); + assert_eq!( + a.intersection(b).bits, + a.bits & b.bits, + "wrong result: `{:?}` & `{:?}`", + a, + b, + ); + assert_eq!( + a.symmetric_difference(b).bits, + a.bits ^ b.bits, + "wrong result: `{:?}` ^ `{:?}`", + a, + b, + ); + assert_eq!( + a.difference(b).bits, + a.bits & !b.bits, + "wrong result: `{:?}` - `{:?}`", + a, + b, + ); + // Note: Difference is checked as both `a - b` and `b - a` + assert_eq!( + b.difference(a).bits, + b.bits & !a.bits, + "wrong result: `{:?}` - `{:?}`", + b, + a, + ); + // Check that the named set operations are equivalent to the + // bitwise equivalents + assert_eq!(a.union(b), a | b, "named != op: `{:?}` | `{:?}`", a, b,); + assert_eq!( + a.intersection(b), + a & b, + "named != op: `{:?}` & `{:?}`", + a, + b, + ); + assert_eq!( + a.symmetric_difference(b), + a ^ b, + "named != op: `{:?}` ^ `{:?}`", + a, + b, + ); + assert_eq!(a.difference(b), a - b, "named != op: `{:?}` - `{:?}`", a, b,); + // Note: Difference is checked as both `a - b` and `b - a` + assert_eq!(b.difference(a), b - a, "named != op: `{:?}` - `{:?}`", b, a,); + // Verify that the operations which should be symmetric are + // actually symmetric. + assert_eq!(a.union(b), b.union(a), "asymmetry: `{:?}` | `{:?}`", a, b,); + assert_eq!( + a.intersection(b), + b.intersection(a), + "asymmetry: `{:?}` & `{:?}`", + a, + b, + ); + assert_eq!( + a.symmetric_difference(b), + b.symmetric_difference(a), + "asymmetry: `{:?}` ^ `{:?}`", + a, + b, + ); + } + } + } + + #[test] + fn test_set() { + let mut e1 = Flags::A | Flags::C; + e1.set(Flags::B, true); + e1.set(Flags::C, false); + + assert_eq!(e1, Flags::A | Flags::B); + } + + #[test] + fn test_assignment_operators() { + let mut m1 = Flags::empty(); + let e1 = Flags::A | Flags::C; + // union + m1 |= Flags::A; + assert_eq!(m1, Flags::A); + // intersection + m1 &= e1; + assert_eq!(m1, Flags::A); + // set difference + m1 -= m1; + assert_eq!(m1, Flags::empty()); + // toggle + m1 ^= e1; + assert_eq!(m1, e1); + } + + #[test] + fn test_const_fn() { + const _M1: Flags = Flags::empty(); + + const M2: Flags = Flags::A; + assert_eq!(M2, Flags::A); + + const M3: Flags = Flags::C; + assert_eq!(M3, Flags::C); + } + + #[test] + fn test_extend() { + let mut flags; + + flags = Flags::empty(); + flags.extend([].iter().cloned()); + assert_eq!(flags, Flags::empty()); + + flags = Flags::empty(); + flags.extend([Flags::A, Flags::B].iter().cloned()); + assert_eq!(flags, Flags::A | Flags::B); + + flags = Flags::A; + flags.extend([Flags::A, Flags::B].iter().cloned()); + assert_eq!(flags, Flags::A | Flags::B); + + flags = Flags::B; + flags.extend([Flags::A, Flags::ABC].iter().cloned()); + assert_eq!(flags, Flags::ABC); + } + + #[test] + fn test_from_iterator() { + assert_eq!([].iter().cloned().collect::(), Flags::empty()); + assert_eq!( + [Flags::A, Flags::B].iter().cloned().collect::(), + Flags::A | Flags::B + ); + assert_eq!( + [Flags::A, Flags::ABC].iter().cloned().collect::(), + Flags::ABC + ); + } + + #[test] + fn test_lt() { + let mut a = Flags::empty(); + let mut b = Flags::empty(); + + assert!(!(a < b) && !(b < a)); + b = Flags::B; + assert!(a < b); + a = Flags::C; + assert!(!(a < b) && b < a); + b = Flags::C | Flags::B; + assert!(a < b); + } + + #[test] + fn test_ord() { + let mut a = Flags::empty(); + let mut b = Flags::empty(); + + assert!(a <= b && a >= b); + a = Flags::A; + assert!(a > b && a >= b); + assert!(b < a && b <= a); + b = Flags::B; + assert!(b > a && b >= a); + assert!(a < b && a <= b); + } + + fn hash(t: &T) -> u64 { + let mut s = DefaultHasher::new(); + t.hash(&mut s); + s.finish() + } + + #[test] + fn test_hash() { + let mut x = Flags::empty(); + let mut y = Flags::empty(); + assert_eq!(hash(&x), hash(&y)); + x = Flags::all(); + y = Flags::ABC; + assert_eq!(hash(&x), hash(&y)); + } + + #[test] + fn test_default() { + assert_eq!(Flags::empty(), Flags::default()); + } + + #[test] + fn test_debug() { + assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); + assert_eq!(format!("{:?}", Flags::empty()), "(empty)"); + assert_eq!(format!("{:?}", Flags::ABC), "A | B | C | ABC"); + let extra = unsafe { Flags::from_bits_unchecked(0xb8) }; + assert_eq!(format!("{:?}", extra), "0xb8"); + assert_eq!(format!("{:?}", Flags::A | extra), "A | 0xb8"); + + assert_eq!( + format!("{:?}", Flags::ABC | extra), + "A | B | C | ABC | 0xb8" + ); + + assert_eq!(format!("{:?}", EmptyFlags::empty()), "(empty)"); + } + + #[test] + fn test_binary() { + assert_eq!(format!("{:b}", Flags::ABC), "111"); + assert_eq!(format!("{:#b}", Flags::ABC), "0b111"); + let extra = unsafe { Flags::from_bits_unchecked(0b1010000) }; + assert_eq!(format!("{:b}", Flags::ABC | extra), "1010111"); + assert_eq!(format!("{:#b}", Flags::ABC | extra), "0b1010111"); + } + + #[test] + fn test_octal() { + assert_eq!(format!("{:o}", LongFlags::LONG_A), "177777"); + assert_eq!(format!("{:#o}", LongFlags::LONG_A), "0o177777"); + let extra = unsafe { LongFlags::from_bits_unchecked(0o5000000) }; + assert_eq!(format!("{:o}", LongFlags::LONG_A | extra), "5177777"); + assert_eq!(format!("{:#o}", LongFlags::LONG_A | extra), "0o5177777"); + } + + #[test] + fn test_lowerhex() { + assert_eq!(format!("{:x}", LongFlags::LONG_A), "ffff"); + assert_eq!(format!("{:#x}", LongFlags::LONG_A), "0xffff"); + let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) }; + assert_eq!(format!("{:x}", LongFlags::LONG_A | extra), "e0ffff"); + assert_eq!(format!("{:#x}", LongFlags::LONG_A | extra), "0xe0ffff"); + } + + #[test] + fn test_upperhex() { + assert_eq!(format!("{:X}", LongFlags::LONG_A), "FFFF"); + assert_eq!(format!("{:#X}", LongFlags::LONG_A), "0xFFFF"); + let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) }; + assert_eq!(format!("{:X}", LongFlags::LONG_A | extra), "E0FFFF"); + assert_eq!(format!("{:#X}", LongFlags::LONG_A | extra), "0xE0FFFF"); + } + + mod submodule { + bitflags! { + pub struct PublicFlags: i8 { + const X = 0; + } + + struct PrivateFlags: i8 { + const Y = 0; + } + } + + #[test] + fn test_private() { + let _ = PrivateFlags::Y; + } + } + + #[test] + fn test_public() { + let _ = submodule::PublicFlags::X; + } + + mod t1 { + mod foo { + pub type Bar = i32; + } + + bitflags! { + /// baz + struct Flags: foo::Bar { + const A = 0b00000001; + #[cfg(foo)] + const B = 0b00000010; + #[cfg(foo)] + const C = 0b00000010; + } + } + } + + #[test] + fn test_in_function() { + bitflags! { + struct Flags: u8 { + const A = 1; + #[cfg(any())] // false + const B = 2; + } + } + assert_eq!(Flags::all(), Flags::A); + assert_eq!(format!("{:?}", Flags::A), "A"); + } + + #[test] + fn test_deprecated() { + bitflags! { + pub struct TestFlags: u32 { + #[deprecated(note = "Use something else.")] + const ONE = 1; + } + } + } + + #[test] + fn test_pub_crate() { + mod module { + bitflags! { + pub (crate) struct Test: u8 { + const FOO = 1; + } + } + } + + assert_eq!(module::Test::FOO.bits(), 1); + } + + #[test] + fn test_pub_in_module() { + mod module { + mod submodule { + bitflags! { + // `pub (in super)` means only the module `module` will + // be able to access this. + pub (in super) struct Test: u8 { + const FOO = 1; + } + } + } + + mod test { + // Note: due to `pub (in super)`, + // this cannot be accessed directly by the testing code. + pub(super) fn value() -> u8 { + super::submodule::Test::FOO.bits() + } + } + + pub fn value() -> u8 { + test::value() + } + } + + assert_eq!(module::value(), 1) + } + + #[test] + fn test_zero_value_flags() { + bitflags! { + struct Flags: u32 { + const NONE = 0b0; + const SOME = 0b1; + } + } + + assert!(Flags::empty().contains(Flags::NONE)); + assert!(Flags::SOME.contains(Flags::NONE)); + assert!(Flags::NONE.is_empty()); + + assert_eq!(format!("{:?}", Flags::empty()), "NONE"); + assert_eq!(format!("{:?}", Flags::SOME), "SOME"); + } + + #[test] + fn test_empty_bitflags() { + bitflags! {} + } + + #[test] + fn test_u128_bitflags() { + bitflags! { + struct Flags128: u128 { + const A = 0x0000_0000_0000_0000_0000_0000_0000_0001; + const B = 0x0000_0000_0000_1000_0000_0000_0000_0000; + const C = 0x8000_0000_0000_0000_0000_0000_0000_0000; + const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + } + } + + assert_eq!(Flags128::ABC, Flags128::A | Flags128::B | Flags128::C); + assert_eq!(Flags128::A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001); + assert_eq!(Flags128::B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000); + assert_eq!(Flags128::C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000); + assert_eq!( + Flags128::ABC.bits, + 0x8000_0000_0000_1000_0000_0000_0000_0001 + ); + assert_eq!(format!("{:?}", Flags128::A), "A"); + assert_eq!(format!("{:?}", Flags128::B), "B"); + assert_eq!(format!("{:?}", Flags128::C), "C"); + assert_eq!(format!("{:?}", Flags128::ABC), "A | B | C | ABC"); + } + + #[test] + fn test_serde_bitflags_serialize() { + let flags = SerdeFlags::A | SerdeFlags::B; + + let serialized = serde_json::to_string(&flags).unwrap(); + + assert_eq!(serialized, r#"{"bits":3}"#); + } + + #[test] + fn test_serde_bitflags_deserialize() { + let deserialized: SerdeFlags = serde_json::from_str(r#"{"bits":12}"#).unwrap(); + + let expected = SerdeFlags::C | SerdeFlags::D; + + assert_eq!(deserialized.bits, expected.bits); + } + + #[test] + fn test_serde_bitflags_roundtrip() { + let flags = SerdeFlags::A | SerdeFlags::B; + + let deserialized: SerdeFlags = serde_json::from_str(&serde_json::to_string(&flags).unwrap()).unwrap(); + + assert_eq!(deserialized.bits, flags.bits); + } + + bitflags! { + #[derive(serde::Serialize, serde::Deserialize)] + struct SerdeFlags: u32 { + const A = 1; + const B = 2; + const C = 4; + const D = 8; + } + } +} diff --git a/vendor/bitflags/tests/basic.rs b/vendor/bitflags-1.3.2/tests/basic.rs similarity index 100% rename from vendor/bitflags/tests/basic.rs rename to vendor/bitflags-1.3.2/tests/basic.rs diff --git a/vendor/bitflags/tests/compile-fail/impls/copy.rs b/vendor/bitflags-1.3.2/tests/compile-fail/impls/copy.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/impls/copy.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/impls/copy.rs diff --git a/vendor/bitflags/tests/compile-fail/impls/copy.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/impls/copy.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/impls/copy.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/impls/copy.stderr.beta diff --git a/vendor/bitflags/tests/compile-fail/impls/eq.rs b/vendor/bitflags-1.3.2/tests/compile-fail/impls/eq.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/impls/eq.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/impls/eq.rs diff --git a/vendor/bitflags/tests/compile-fail/impls/eq.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/impls/eq.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/impls/eq.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/impls/eq.stderr.beta diff --git a/vendor/bitflags/tests/compile-fail/non_integer_base/all_defined.rs b/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/non_integer_base/all_defined.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.rs diff --git a/vendor/bitflags/tests/compile-fail/non_integer_base/all_defined.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/non_integer_base/all_defined.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_defined.stderr.beta diff --git a/vendor/bitflags/tests/compile-fail/non_integer_base/all_missing.rs b/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_missing.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/non_integer_base/all_missing.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_missing.rs diff --git a/vendor/bitflags/tests/compile-fail/non_integer_base/all_missing.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_missing.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/non_integer_base/all_missing.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/non_integer_base/all_missing.stderr.beta diff --git a/vendor/bitflags/tests/compile-fail/visibility/private_field.rs b/vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_field.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/visibility/private_field.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_field.rs diff --git a/vendor/bitflags/tests/compile-fail/visibility/private_field.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_field.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/visibility/private_field.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_field.stderr.beta diff --git a/vendor/bitflags/tests/compile-fail/visibility/private_flags.rs b/vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_flags.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/visibility/private_flags.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_flags.rs diff --git a/vendor/bitflags/tests/compile-fail/visibility/private_flags.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_flags.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/visibility/private_flags.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/visibility/private_flags.stderr.beta diff --git a/vendor/bitflags/tests/compile-fail/visibility/pub_const.rs b/vendor/bitflags-1.3.2/tests/compile-fail/visibility/pub_const.rs similarity index 100% rename from vendor/bitflags/tests/compile-fail/visibility/pub_const.rs rename to vendor/bitflags-1.3.2/tests/compile-fail/visibility/pub_const.rs diff --git a/vendor/bitflags/tests/compile-fail/visibility/pub_const.stderr.beta b/vendor/bitflags-1.3.2/tests/compile-fail/visibility/pub_const.stderr.beta similarity index 100% rename from vendor/bitflags/tests/compile-fail/visibility/pub_const.stderr.beta rename to vendor/bitflags-1.3.2/tests/compile-fail/visibility/pub_const.stderr.beta diff --git a/vendor/bitflags/tests/compile-pass/impls/convert.rs b/vendor/bitflags-1.3.2/tests/compile-pass/impls/convert.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/impls/convert.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/impls/convert.rs diff --git a/vendor/bitflags/tests/compile-pass/impls/default.rs b/vendor/bitflags-1.3.2/tests/compile-pass/impls/default.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/impls/default.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/impls/default.rs diff --git a/vendor/bitflags/tests/compile-pass/impls/inherent_methods.rs b/vendor/bitflags-1.3.2/tests/compile-pass/impls/inherent_methods.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/impls/inherent_methods.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/impls/inherent_methods.rs diff --git a/vendor/bitflags/tests/compile-pass/redefinition/core.rs b/vendor/bitflags-1.3.2/tests/compile-pass/redefinition/core.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/redefinition/core.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/redefinition/core.rs diff --git a/vendor/bitflags/tests/compile-pass/redefinition/stringify.rs b/vendor/bitflags-1.3.2/tests/compile-pass/redefinition/stringify.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/redefinition/stringify.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/redefinition/stringify.rs diff --git a/vendor/bitflags/tests/compile-pass/repr/c.rs b/vendor/bitflags-1.3.2/tests/compile-pass/repr/c.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/repr/c.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/repr/c.rs diff --git a/vendor/bitflags/tests/compile-pass/repr/transparent.rs b/vendor/bitflags-1.3.2/tests/compile-pass/repr/transparent.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/repr/transparent.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/repr/transparent.rs diff --git a/vendor/bitflags/tests/compile-pass/visibility/bits_field.rs b/vendor/bitflags-1.3.2/tests/compile-pass/visibility/bits_field.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/visibility/bits_field.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/visibility/bits_field.rs diff --git a/vendor/bitflags/tests/compile-pass/visibility/pub_in.rs b/vendor/bitflags-1.3.2/tests/compile-pass/visibility/pub_in.rs similarity index 100% rename from vendor/bitflags/tests/compile-pass/visibility/pub_in.rs rename to vendor/bitflags-1.3.2/tests/compile-pass/visibility/pub_in.rs diff --git a/vendor/bitflags/tests/compile.rs b/vendor/bitflags-1.3.2/tests/compile.rs similarity index 100% rename from vendor/bitflags/tests/compile.rs rename to vendor/bitflags-1.3.2/tests/compile.rs diff --git a/vendor/bitflags/.cargo-checksum.json b/vendor/bitflags/.cargo-checksum.json index 7e8d470..9ed6cb2 100644 --- a/vendor/bitflags/.cargo-checksum.json +++ b/vendor/bitflags/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"d362fc1fccaaf4d421bcf0fe8b80ddb4f625dade0c1ee52d08bd0b95509a49d1","CODE_OF_CONDUCT.md":"42634d0f6d922f49857175af991802822f7f920487aefa2ee250a50d12251a66","Cargo.toml":"87aced7532a7974eb37ab5fe6037f0abafc36d6b2d74891ecd2bf2f14f50d11e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"baa8604f8afb34fd93b9c79729daafb884dedcaf34023e4af8ad037d916061fd","src/example_generated.rs":"e43eb59e90f317f38d436670a6067d2fd9eb35fb319fe716184e4a04e24ed1b2","src/lib.rs":"e6477688535ee326d27238aeedc9cb4320ac35b9d17a4deda09e0587b0ccdbd4","tests/basic.rs":"146f1cbf6279bc609242cd3349f29cb21b41294f5e4921875f5ec95bd83529a2","tests/compile-fail/impls/copy.rs":"b791371237ddc75a7c04d2130e03b462c9c00a80dca08bd45aa97433d9c0d13a","tests/compile-fail/impls/copy.stderr.beta":"77d83484ce221d4b6ff2f7de843929a452d779fcfff428122710dd8218c298e3","tests/compile-fail/impls/eq.rs":"0cee8b9e07d537890e0189710293b53972d0fab63c09366f33c391065afafa99","tests/compile-fail/impls/eq.stderr.beta":"381fc6143d45ce76d7cecc47aa59cb69fe5e79c0b60a4a85d5c6163b400b3cc7","tests/compile-fail/non_integer_base/all_defined.rs":"95e14cad9e94560262f2862c3c01865ac30369b69da1001b0e7285cb55e6cb75","tests/compile-fail/non_integer_base/all_defined.stderr.beta":"1760739a276690903bb03844025587d37939f5dfcbfab309db3c86f32bdbf748","tests/compile-fail/non_integer_base/all_missing.rs":"b3d9da619d23213731ba2581aa7999c796c3c79aaf4f0ee6b11ceec08a11537f","tests/compile-fail/non_integer_base/all_missing.stderr.beta":"37e102290d3867e175b21976be798939f294efb17580d5b51e7b17b590d55132","tests/compile-fail/visibility/private_field.rs":"38e4d3fe6471829360d12c8d09b097f6a21aa93fb51eac3b215d96bdae23316b","tests/compile-fail/visibility/private_field.stderr.beta":"5aa24a3ebb39326f31927721c5017b8beb66c3e501fb865a3fa814c9763bfa0f","tests/compile-fail/visibility/private_flags.rs":"2ce4235802aa4e9c96c4e77d9e31d8401ef58dcda4741325184f0764ab1fe393","tests/compile-fail/visibility/private_flags.stderr.beta":"f3eb9f7baf2689258f3519ff7ee5c6ec3c237264ebcfe63f40c40f2023e5022f","tests/compile-fail/visibility/pub_const.rs":"8f813a97ac518c5ea8ac65b184101912452384afaf7b8d6c5e62f8370eca3c0a","tests/compile-fail/visibility/pub_const.stderr.beta":"823976ae1794d7f5372e2ec9aabba497e7bb88004722904c38da342ed98e8962","tests/compile-pass/impls/convert.rs":"88fe80bfb9cd5779f0e1d92c9ec02a8b6bb67e334c07f2309e9c0ba5ef776eb0","tests/compile-pass/impls/default.rs":"c508f9a461691f44b45142fa5ad599f02326e1de4c0cbca6c0593f4652eba109","tests/compile-pass/impls/inherent_methods.rs":"ecc26388e9a394bfa7a5bb69a5d621ab3d4d1e53f28f657bb8e78fe79f437913","tests/compile-pass/redefinition/core.rs":"ff5b6e72f87acc6ebb12405d3c0f6e3fa62e669933656a454bb63b30ea44179c","tests/compile-pass/redefinition/stringify.rs":"1edbce42b900c14425d7ffa14e83e165ebe452d7dccd8c0a8a821bdec64f5c93","tests/compile-pass/repr/c.rs":"6fda17f7c2edfcd155314579e83d0fc8a16209e400f1f9a5ca77bd9a799041f2","tests/compile-pass/repr/transparent.rs":"6cdc87a2137d8a4e0c8ce9b6cba83c82255f8ea125951bf614418685600489ce","tests/compile-pass/visibility/bits_field.rs":"1f3e5ba5a047440066a9f6bf7b7af33f5b06f6b1da3dd9af6886168199a7ea0a","tests/compile-pass/visibility/pub_in.rs":"e95312ff60966d42ec4bc00225507895a9b8ec24056ce6a9edd9145be35d730f","tests/compile.rs":"f27c67a7dd183ca30efea1b6e0880e3469a6dd63b92b1fd711c082df182c9eec"},"package":"bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"} \ No newline at end of file +{"files":{"CHANGELOG.md":"c98723b209ac4c66625e034b113a55a43a5c1c9e49c0e3b86123d0cd62bae573","CODE_OF_CONDUCT.md":"42634d0f6d922f49857175af991802822f7f920487aefa2ee250a50d12251a66","CONTRIBUTING.md":"6c9f96eacb20af877ae2d16f024904f3038b93448a8488e9dbcac0df7f6439a5","Cargo.lock":"d3e3bce47b94298f2de893a7d91035f2b73a887905a7ffd4ddb668efdd0aee20","Cargo.toml":"92e110c36340bda13f3b329a2aa24aede8bdcb7fa035806926f7ce438dde87f2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"e9b1329fee85868f1aa674d0505cd95b86a259e2a1762347e5af4a5abedd61d4","SECURITY.md":"68704c8128fa2e776ed7cbda741fbf61ad52f998a96350ee7ee4dbf64c6573bc","benches/parse.rs":"f1390d62322c6880d65bd931e183d49b313f287879a6bfaa36b1cb1921090b51","examples/custom_bits_type.rs":"e53b32051adc5d97860e0b48c8f3a301a041d73b4939c0d7caa5f0cfcc0b9739","examples/custom_derive.rs":"a404e8f606efdd1b43e0c365e4142ccc3dc3ba230127ddeea89cd8784bb55a1e","examples/fmt.rs":"87ba37a1fb8528570c74ea26d8e8948e1179c3d867b928bea1080880258e0a99","examples/macro_free.rs":"69e7f284b53b5214d51228a686e87f127b52a3b74711e45537ebfa5583a180e5","examples/serde.rs":"08b21b35d5c10fdca132fe0f36c8067bb44f559e96617a9257ab6316a20cbc75","spec.md":"fcdd939df30c59b0643be09027df664b71cbea9b9989185441482c5576160fed","src/example_generated.rs":"d018caf059f6ffc4c2403b771a6d76679fa5af03c329a91bd9252957df695e7f","src/external.rs":"734d3f470e6a669297d2df421ce3976fe613d8aa9c071d5ce6fe3ca890e5b815","src/external/arbitrary.rs":"fa8c9187028b9bc54856977b0914676f62101010e7a9450abd577fd78c89552f","src/external/bytemuck.rs":"3afcef382122867040fddd5e4153d633d1ed5596fe5d7dfac66a8e61c2513df5","src/external/serde.rs":"4a09db12534a20fe554a08dc5f1c8124b379292d41fa75628abcd2ca21587573","src/internal.rs":"645b13af0c7302258df61239073a4b8203d09f27b6c17f8a6f1f8c3e427f5334","src/iter.rs":"dbaa6437c1c044f689185ce3fafe43df8796bed19bbdd2c20334a52de5eeee73","src/lib.rs":"1feb0eea02f88491c99c7962b0ce6e66bdedea0ab0cac375d4c9c2d879248dc7","src/parser.rs":"4e788b29f5d0542c409a8b43c703bcb4a6c2a57c181cadd17f565f0abb39681e","src/public.rs":"78ba06e1a5830b36960adf9bd79aaf47d783b9b8a0f1fa33b0d7a340c15fd1d1","src/tests.rs":"b120c27ff0c67a819527de9d8171f1f4c5d37ba4009c54abeb869c70e6035f14","src/tests/all.rs":"e99a865cd4271a524c2fe95503e96d851b35990570aed6fb2e9dac7a14da31b6","src/tests/bits.rs":"3840c34b2ea5d1802404b9ce5bcc1d3fa6ccd8dfba2e29e6d07c605f817d90df","src/tests/complement.rs":"d0e6d4c3daf49e0a7438c9f1c1ac91fad1b37f258c03593f6cd6a695ee626f5e","src/tests/contains.rs":"58bb3cb8c86550e775d11134da1d4aca85c83f943ea454e3a5f222772c674a24","src/tests/difference.rs":"d0d2b96bb52658b8ac019210da74ca75a53e76622f668855142ea6e97c28cb0e","src/tests/empty.rs":"817d6e93ced7cb7576ff0e334aa1a44703f3f96871ff2c6bdcb8f207e6551f67","src/tests/eq.rs":"b816767680a029e9c163e37af074dd4e604c4a3e4936f829f0ca3774fd5f0e37","src/tests/extend.rs":"5fabb9fd0254c64da019149c24063fceff72da3eb4ad73b57c1cc4c04b008364","src/tests/flags.rs":"2f48d3a25db1cf66fe98c9959abc70875deb9f7b38b2c278dc70c46e0d4ec277","src/tests/fmt.rs":"a2d4148491f3202f030f63633eee941b741e3be29a68cf376f008dbe5cb11e5c","src/tests/from_bits.rs":"d94c65b88bf89961d0cfc1b3152a7f1acc285bae160a1628438effda11b8e2c1","src/tests/from_bits_retain.rs":"980591dfaf91e940f42d9a1ce890f237514dd59d458fc264abcf9ceabbc40677","src/tests/from_bits_truncate.rs":"d3406b5e107ebb6449b98a59eee6cc5d84f947d4aaee1ee7e80dc7202de179f0","src/tests/from_name.rs":"f4a055d1f3c86decef70ef8f3020cef5c4e229718c20b3d59d5a3abc3a8b1298","src/tests/insert.rs":"3fab5da800a6fc0654dfb5f859f95da65a507eb9fda8695083c2712266dff0b9","src/tests/intersection.rs":"baf1454c9e4eba552264870a556ee0032d9f2bb8cac361833d571235e0b52221","src/tests/intersects.rs":"c55e36179fd8bc636f04ea9bbce346dcaafe57915d13f1df28c5b83117dbd08e","src/tests/is_all.rs":"b2f11faa7c954bd85c8fb39999e0c37d983cf7895152bc13c7ddde106aa33b6d","src/tests/is_empty.rs":"11f21323cdca7ff92dd89e09de667dba69e8dce88e2d3e27ea68ace91d15d070","src/tests/iter.rs":"4ba121932b527e787b82745405c7c65c1084c242e2dda3290d475ec160d265e4","src/tests/parser.rs":"fa2fb8dedcf16601af609a5e21d9c5840c7f96a1e3a587f7f2ea3dc8387f7628","src/tests/remove.rs":"6e75f8508d2dc1a2cba89ef691f4387a665a4fd13853bb1dd0fd80c783b89947","src/tests/symmetric_difference.rs":"0a89f084f9de1dd5b1932fe72c3b10a3c93cbaa16832b3a31b6a85e3bbd3ba6e","src/tests/union.rs":"88f398ee4600bb1e59bf6d02d1f6ff33f5f853eab5a6c700bd8a683c6ee4651a","src/traits.rs":"b79d008daec546136fae4497966fc85a33663d86ea2d9213fd23b412d4d77b66"},"package":"b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"} \ No newline at end of file diff --git a/vendor/bitflags/CHANGELOG.md b/vendor/bitflags/CHANGELOG.md index 12fea16..f17d469 100644 --- a/vendor/bitflags/CHANGELOG.md +++ b/vendor/bitflags/CHANGELOG.md @@ -1,8 +1,353 @@ +# 2.6.0 + +## What's Changed +* Sync CHANGELOG.md with github release notes by @dextero in https://github.com/bitflags/bitflags/pull/402 +* Update error messages and zerocopy by @KodrAus in https://github.com/bitflags/bitflags/pull/403 +* Bump minimum declared versions of dependencies by @dextero in https://github.com/bitflags/bitflags/pull/404 +* chore(deps): bump serde_derive and bytemuck versions by @joshka in https://github.com/bitflags/bitflags/pull/405 +* add OSFF Scorecard workflow by @KodrAus in https://github.com/bitflags/bitflags/pull/396 +* Update stderr messages by @KodrAus in https://github.com/bitflags/bitflags/pull/408 +* Fix typo by @waywardmonkeys in https://github.com/bitflags/bitflags/pull/410 +* Allow specifying outer attributes in impl mode by @KodrAus in https://github.com/bitflags/bitflags/pull/411 + +## New Contributors +* @dextero made their first contribution in https://github.com/bitflags/bitflags/pull/402 +* @joshka made their first contribution in https://github.com/bitflags/bitflags/pull/405 +* @waywardmonkeys made their first contribution in https://github.com/bitflags/bitflags/pull/410 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.5.0...2.6.0 + +# 2.5.0 + +## What's Changed +* Derive `Debug` for `Flag` by @tgross35 in https://github.com/bitflags/bitflags/pull/398 +* Support truncating or strict-named variants of parsing and formatting by @KodrAus in https://github.com/bitflags/bitflags/pull/400 + +## New Contributors +* @tgross35 made their first contribution in https://github.com/bitflags/bitflags/pull/398 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.2...2.5.0 + +# 2.4.2 + +## What's Changed +* Cargo.toml: Anchor excludes to root of the package by @jamessan in https://github.com/bitflags/bitflags/pull/387 +* Update error messages by @KodrAus in https://github.com/bitflags/bitflags/pull/390 +* Add support for impl mode structs to be repr(packed) by @GnomedDev in https://github.com/bitflags/bitflags/pull/388 +* Remove old `unused_tuple_struct_fields` lint by @dtolnay in https://github.com/bitflags/bitflags/pull/393 +* Delete use of `local_inner_macros` by @dtolnay in https://github.com/bitflags/bitflags/pull/392 + +## New Contributors +* @jamessan made their first contribution in https://github.com/bitflags/bitflags/pull/387 +* @GnomedDev made their first contribution in https://github.com/bitflags/bitflags/pull/388 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.1...2.4.2 + +# 2.4.1 + +## What's Changed +* Allow some new pedantic clippy lints by @KodrAus in https://github.com/bitflags/bitflags/pull/380 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.4.0...2.4.1 + +# 2.4.0 + +## What's Changed +* Remove html_root_url by @eldruin in https://github.com/bitflags/bitflags/pull/368 +* Support unnamed flags by @KodrAus in https://github.com/bitflags/bitflags/pull/371 +* Update smoke test to verify all Clippy and rustc lints by @MitMaro in https://github.com/bitflags/bitflags/pull/374 +* Specify the behavior of bitflags by @KodrAus in https://github.com/bitflags/bitflags/pull/369 + +## New Contributors +* @eldruin made their first contribution in https://github.com/bitflags/bitflags/pull/368 +* @MitMaro made their first contribution in https://github.com/bitflags/bitflags/pull/374 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.3...2.4.0 + +# 2.3.3 + +## Changes to `-=` + +The `-=` operator was incorrectly changed to truncate bits that didn't correspond to valid flags in `2.3.0`. This has +been fixed up so it once again behaves the same as `-` and `difference`. + +## Changes to `!` + +The `!` operator previously called `Self::from_bits_truncate`, which would truncate any bits that only partially +overlapped with a valid flag. It will now use `bits & Self::all().bits()`, so any bits that overlap any bits +specified by any flag will be respected. This is unlikely to have any practical implications, but enables defining +a flag like `const ALL = !0` as a way to signal that any bit pattern is a known set of flags. + +## Changes to formatting + +Zero-valued flags will never be printed. You'll either get `0x0` for empty flags using debug formatting, or the +set of flags with zero-valued flags omitted for others. + +Composite flags will no longer be redundantly printed if there are extra bits to print at the end that don't correspond +to a valid flag. + +## What's Changed +* Fix up incorrect sub assign behavior and other cleanups by @KodrAus in https://github.com/bitflags/bitflags/pull/366 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.2...2.3.3 + +# 2.3.2 + +## What's Changed +* [doc] [src/lib.rs] delete redundant path prefix by @OccupyMars2025 in https://github.com/bitflags/bitflags/pull/361 + +## New Contributors +* @OccupyMars2025 made their first contribution in https://github.com/bitflags/bitflags/pull/361 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.1...2.3.2 + +# 2.3.1 + +## What's Changed +* Fix Self in flags value expressions by @KodrAus in https://github.com/bitflags/bitflags/pull/355 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.3.0...2.3.1 + +# 2.3.0 + +## Major changes + +### `BitFlags` trait deprecated in favor of `Flags` trait + +This release introduces the `Flags` trait and deprecates the `BitFlags` trait. These two traits are semver compatible so if you have public API code depending on `BitFlags` you can move to `Flags` without breaking end-users. This is possible because the `BitFlags` trait was never publicly implementable, so it now carries `Flags` as a supertrait. All implementations of `Flags` additionally implement `BitFlags`. + +The `Flags` trait is a publicly implementable version of the old `BitFlags` trait. The original `BitFlags` trait carried some macro baggage that made it difficult to implement, so a new `Flags` trait has been introduced as the _One True Trait_ for interacting with flags types generically. See the the `macro_free` and `custom_derive` examples for more details. + +### `Bits` trait publicly exposed + +The `Bits` trait for the underlying storage of flags values is also now publicly implementable. This lets you define your own exotic backing storage for flags. See the `custom_bits_type` example for more details. + +## What's Changed +* Use explicit hashes for actions steps by @KodrAus in https://github.com/bitflags/bitflags/pull/350 +* Support ejecting flags types from the bitflags macro by @KodrAus in https://github.com/bitflags/bitflags/pull/351 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.2.1...2.3.0 + +# 2.2.1 + +## What's Changed +* Refactor attribute filtering to apply per-flag by @KodrAus in https://github.com/bitflags/bitflags/pull/345 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.2.0...2.2.1 + +# 2.2.0 + +## What's Changed +* Create SECURITY.md by @KodrAus in https://github.com/bitflags/bitflags/pull/338 +* add docs to describe the behavior of multi-bit flags by @nicholasbishop in https://github.com/bitflags/bitflags/pull/340 +* Add support for bytemuck by @KodrAus in https://github.com/bitflags/bitflags/pull/336 +* Add a top-level macro for filtering attributes by @KodrAus in https://github.com/bitflags/bitflags/pull/341 + +## New Contributors +* @nicholasbishop made their first contribution in https://github.com/bitflags/bitflags/pull/340 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.1.0...2.2.0 + +# 2.1.0 + +## What's Changed +* Add docs for the internal Field0 and examples of formatting/parsing by @KodrAus in https://github.com/bitflags/bitflags/pull/328 +* Add support for arbitrary by @KodrAus in https://github.com/bitflags/bitflags/pull/324 +* Fix up missing docs for consts within consts by @KodrAus in https://github.com/bitflags/bitflags/pull/330 +* Ignore clippy lint in generated code by @Jake-Shadle in https://github.com/bitflags/bitflags/pull/331 + +## New Contributors +* @Jake-Shadle made their first contribution in https://github.com/bitflags/bitflags/pull/331 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.2...2.1.0 + +# 2.0.2 + +## What's Changed +* Fix up missing isize and usize Bits impls by @KodrAus in https://github.com/bitflags/bitflags/pull/321 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.1...2.0.2 + +# 2.0.1 + +## What's Changed +* Fix up some docs issues by @KodrAus in https://github.com/bitflags/bitflags/pull/309 +* Make empty_flag() const. by @tormeh in https://github.com/bitflags/bitflags/pull/313 +* Fix formatting of multi-bit flags with partial overlap by @KodrAus in https://github.com/bitflags/bitflags/pull/316 + +## New Contributors +* @tormeh made their first contribution in https://github.com/bitflags/bitflags/pull/313 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.0...2.0.1 + +# 2.0.0 + +## Major changes + +This release includes some major changes over `1.x`. If you use `bitflags!` types in your public API then upgrading this library may cause breakage in your downstream users. + +### ⚠️ Serialization + +You'll need to add the `serde` Cargo feature in order to `#[derive(Serialize, Deserialize)]` on your generated flags types: + +```rust +bitflags! { + #[derive(Serialize, Deserialize)] + #[serde(transparent)] + pub struct Flags: T { + .. + } +} +``` + +where `T` is the underlying bits type you're using, such as `u32`. + +The default serialization format with `serde` **has changed** if you `#[derive(Serialize, Deserialize)]` on your generated flags types. It will now use a formatted string for human-readable formats and the underlying bits type for compact formats. + +To keep the old format, see the https://github.com/KodrAus/bitflags-serde-legacy library. + +### ⚠️ Traits + +Generated flags types now derive fewer traits. If you need to maintain backwards compatibility, you can derive the following yourself: + +```rust +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] +``` + +### ⚠️ Methods + +The unsafe `from_bits_unchecked` method is now a safe `from_bits_retain` method. + +You can add the following method to your generated types to keep them compatible: + +```rust +#[deprecated = "use the safe `from_bits_retain` method instead"] +pub unsafe fn from_bits_unchecked(bits: T) -> Self { + Self::from_bits_retain(bits) +} +``` + +where `T` is the underlying bits type you're using, such as `u32`. + +### ⚠️ `.bits` field + +You can now use the `.bits()` method instead of the old `.bits`. + +The representation of generated flags types has changed from a struct with the single field `bits` to a newtype. + +## What's Changed +* Fix a typo and call out MSRV bump by @KodrAus in https://github.com/bitflags/bitflags/pull/259 +* BitFlags trait by @arturoc in https://github.com/bitflags/bitflags/pull/220 +* Add a hidden trait to discourage manual impls of BitFlags by @KodrAus in https://github.com/bitflags/bitflags/pull/261 +* Sanitize `Ok` by @konsumlamm in https://github.com/bitflags/bitflags/pull/266 +* Fix bug in `Debug` implementation by @konsumlamm in https://github.com/bitflags/bitflags/pull/268 +* Fix a typo in the generated documentation by @wackbyte in https://github.com/bitflags/bitflags/pull/271 +* Use SPDX license format by @atouchet in https://github.com/bitflags/bitflags/pull/272 +* serde tests fail in CI by @arturoc in https://github.com/bitflags/bitflags/pull/277 +* Fix beta test output by @KodrAus in https://github.com/bitflags/bitflags/pull/279 +* Add example to the README.md file by @tiaanl in https://github.com/bitflags/bitflags/pull/270 +* Iterator over all the enabled options by @arturoc in https://github.com/bitflags/bitflags/pull/278 +* from_bits_(truncate) fail with composite flags by @arturoc in https://github.com/bitflags/bitflags/pull/276 +* Add more platform coverage to CI by @KodrAus in https://github.com/bitflags/bitflags/pull/280 +* rework the way cfgs are handled by @KodrAus in https://github.com/bitflags/bitflags/pull/281 +* Split generated code into two types by @KodrAus in https://github.com/bitflags/bitflags/pull/282 +* expose bitflags iters using nameable types by @KodrAus in https://github.com/bitflags/bitflags/pull/286 +* Support creating flags from their names by @KodrAus in https://github.com/bitflags/bitflags/pull/287 +* Update README.md by @KodrAus in https://github.com/bitflags/bitflags/pull/288 +* Prepare for 2.0.0-rc.1 release by @KodrAus in https://github.com/bitflags/bitflags/pull/289 +* Add missing "if" to contains doc-comment in traits.rs by @rusty-snake in https://github.com/bitflags/bitflags/pull/291 +* Forbid unsafe_code by @fintelia in https://github.com/bitflags/bitflags/pull/294 +* serde: enable no-std support by @nim65s in https://github.com/bitflags/bitflags/pull/296 +* Add a parser for flags formatted as bar-separated-values by @KodrAus in https://github.com/bitflags/bitflags/pull/297 +* Prepare for 2.0.0-rc.2 release by @KodrAus in https://github.com/bitflags/bitflags/pull/299 +* Use strip_prefix instead of starts_with + slice by @QuinnPainter in https://github.com/bitflags/bitflags/pull/301 +* Fix up some clippy lints by @KodrAus in https://github.com/bitflags/bitflags/pull/302 +* Prepare for 2.0.0-rc.3 release by @KodrAus in https://github.com/bitflags/bitflags/pull/303 +* feat: Add minimum permissions to rust.yml workflow by @gabibguti in https://github.com/bitflags/bitflags/pull/305 + +## New Contributors +* @wackbyte made their first contribution in https://github.com/bitflags/bitflags/pull/271 +* @atouchet made their first contribution in https://github.com/bitflags/bitflags/pull/272 +* @tiaanl made their first contribution in https://github.com/bitflags/bitflags/pull/270 +* @rusty-snake made their first contribution in https://github.com/bitflags/bitflags/pull/291 +* @fintelia made their first contribution in https://github.com/bitflags/bitflags/pull/294 +* @nim65s made their first contribution in https://github.com/bitflags/bitflags/pull/296 +* @QuinnPainter made their first contribution in https://github.com/bitflags/bitflags/pull/301 +* @gabibguti made their first contribution in https://github.com/bitflags/bitflags/pull/305 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/1.3.2...2.0.0 + +# 2.0.0-rc.3 + +## What's Changed +* Use strip_prefix instead of starts_with + slice by @QuinnPainter in https://github.com/bitflags/bitflags/pull/301 +* Fix up some clippy lints by @KodrAus in https://github.com/bitflags/bitflags/pull/302 + +## New Contributors +* @QuinnPainter made their first contribution in https://github.com/bitflags/bitflags/pull/301 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.0-rc.2...2.0.0-rc.3 + +# 2.0.0-rc.2 + +## Changes to `serde` serialization + +**⚠️ NOTE ⚠️** This release changes the default serialization you'll get if you `#[derive(Serialize, Deserialize)]` +on your generated flags types. It will now use a formatted string for human-readable formats and the underlying bits +type for compact formats. + +To keep the old behavior, see the [`bitflags-serde-legacy`](https://github.com/KodrAus/bitflags-serde-legacy) library. + +## What's Changed + +* Add missing "if" to contains doc-comment in traits.rs by @rusty-snake in https://github.com/bitflags/bitflags/pull/291 +* Forbid unsafe_code by @fintelia in https://github.com/bitflags/bitflags/pull/294 +* serde: enable no-std support by @nim65s in https://github.com/bitflags/bitflags/pull/296 +* Add a parser for flags formatted as bar-separated-values by @KodrAus in https://github.com/bitflags/bitflags/pull/297 + +## New Contributors +* @rusty-snake made their first contribution in https://github.com/bitflags/bitflags/pull/291 +* @fintelia made their first contribution in https://github.com/bitflags/bitflags/pull/294 +* @nim65s made their first contribution in https://github.com/bitflags/bitflags/pull/296 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/2.0.0-rc.1...2.0.0-rc.2 + +# 2.0.0-rc.1 + +This is a big release including a few years worth of work on a new `BitFlags` trait, iteration, and better macro organization for future extensibility. + +## What's Changed +* Fix a typo and call out MSRV bump by @KodrAus in https://github.com/bitflags/bitflags/pull/259 +* BitFlags trait by @arturoc in https://github.com/bitflags/bitflags/pull/220 +* Add a hidden trait to discourage manual impls of BitFlags by @KodrAus in https://github.com/bitflags/bitflags/pull/261 +* Sanitize `Ok` by @konsumlamm in https://github.com/bitflags/bitflags/pull/266 +* Fix bug in `Debug` implementation by @konsumlamm in https://github.com/bitflags/bitflags/pull/268 +* Fix a typo in the generated documentation by @wackbyte in https://github.com/bitflags/bitflags/pull/271 +* Use SPDX license format by @atouchet in https://github.com/bitflags/bitflags/pull/272 +* serde tests fail in CI by @arturoc in https://github.com/bitflags/bitflags/pull/277 +* Fix beta test output by @KodrAus in https://github.com/bitflags/bitflags/pull/279 +* Add example to the README.md file by @tiaanl in https://github.com/bitflags/bitflags/pull/270 +* Iterator over all the enabled options by @arturoc in https://github.com/bitflags/bitflags/pull/278 +* from_bits_(truncate) fail with composite flags by @arturoc in https://github.com/bitflags/bitflags/pull/276 +* Add more platform coverage to CI by @KodrAus in https://github.com/bitflags/bitflags/pull/280 +* rework the way cfgs are handled by @KodrAus in https://github.com/bitflags/bitflags/pull/281 +* Split generated code into two types by @KodrAus in https://github.com/bitflags/bitflags/pull/282 +* expose bitflags iters using nameable types by @KodrAus in https://github.com/bitflags/bitflags/pull/286 +* Support creating flags from their names by @KodrAus in https://github.com/bitflags/bitflags/pull/287 +* Update README.md by @KodrAus in https://github.com/bitflags/bitflags/pull/288 + +## New Contributors +* @wackbyte made their first contribution in https://github.com/bitflags/bitflags/pull/271 +* @atouchet made their first contribution in https://github.com/bitflags/bitflags/pull/272 +* @tiaanl made their first contribution in https://github.com/bitflags/bitflags/pull/270 + +**Full Changelog**: https://github.com/bitflags/bitflags/compare/1.3.2...2.0.0-rc.1 + # 1.3.2 - Allow `non_snake_case` in generated flags types ([#256]) -[#252]: https://github.com/bitflags/bitflags/pull/256 +[#256]: https://github.com/bitflags/bitflags/pull/256 # 1.3.1 @@ -12,6 +357,8 @@ # 1.3.0 (yanked) +**This release bumps the Minimum Supported Rust Version to `1.46.0`** + - Add `#[repr(transparent)]` ([#187]) - End `empty` doc comment with full stop ([#202]) diff --git a/vendor/bitflags/CONTRIBUTING.md b/vendor/bitflags/CONTRIBUTING.md new file mode 100644 index 0000000..5883363 --- /dev/null +++ b/vendor/bitflags/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Updating compile-fail test outputs + +`bitflags` uses the `trybuild` crate to integration test its macros. Since Rust error messages change frequently enough that `nightly` builds produce spurious failures, we only check the compiler output in `beta` builds. If you run: + +``` +TRYBUILD=overwrite cargo +beta test --all +``` + +it will run the tests and update the `trybuild` output files. diff --git a/vendor/bitflags/Cargo.lock b/vendor/bitflags/Cargo.lock new file mode 100644 index 0000000..5f98ce0 --- /dev/null +++ b/vendor/bitflags/Cargo.lock @@ -0,0 +1,383 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +dependencies = [ + "arbitrary", + "bytemuck", + "compiler_builtins", + "rustc-std-workspace-core", + "rustversion", + "serde", + "serde_derive", + "serde_json", + "serde_test", + "trybuild", + "zerocopy", +] + +[[package]] +name = "bytemuck" +version = "1.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "compiler_builtins" +version = "0.1.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15acab2bb4fe4dad1f1e31f3d9e714f50ef561a0f87dd8a9da004f14d455e1a" + +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_test" +version = "1.0.176" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a2f49ace1498612d14f7e0b8245519584db8299541dfe31a06374a828d620ab" +dependencies = [ + "serde", +] + +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "trybuild" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33a5f13f11071020bb12de7a16b925d2d58636175c20c11dc5f96cb64bb6c9b3" +dependencies = [ + "glob", + "serde", + "serde_derive", + "serde_json", + "termcolor", + "toml", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + +[[package]] +name = "zerocopy" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/vendor/bitflags/Cargo.toml b/vendor/bitflags/Cargo.toml index 9d54c72..54c4b82 100644 --- a/vendor/bitflags/Cargo.toml +++ b/vendor/bitflags/Cargo.toml @@ -3,29 +3,49 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] -edition = "2018" +edition = "2021" +rust-version = "1.56.0" name = "bitflags" -version = "1.3.2" +version = "2.6.0" authors = ["The Rust Project Developers"] -exclude = ["bors.toml"] -description = "A macro to generate structures which behave like bitflags.\n" +exclude = [ + "/tests", + "/.github", +] +description = """ +A macro to generate structures which behave like bitflags. +""" homepage = "https://github.com/bitflags/bitflags" documentation = "https://docs.rs/bitflags" readme = "README.md" -keywords = ["bit", "bitmask", "bitflags", "flags"] +keywords = [ + "bit", + "bitmask", + "bitflags", + "flags", +] categories = ["no-std"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "https://github.com/bitflags/bitflags" + [package.metadata.docs.rs] features = ["example_generated"] + +[dependencies.arbitrary] +version = "1.0" +optional = true + +[dependencies.bytemuck] +version = "1.12" +optional = true + [dependencies.compiler_builtins] version = "0.1.2" optional = true @@ -34,25 +54,43 @@ optional = true version = "1.0.0" optional = true package = "rustc-std-workspace-core" -[dev-dependencies.rustversion] + +[dependencies.serde] +version = "1.0.103" +optional = true +default-features = false + +[dev-dependencies.arbitrary] version = "1.0" +features = ["derive"] + +[dev-dependencies.bytemuck] +version = "1.12.2" +features = ["derive"] -[dev-dependencies.serde] +[dev-dependencies.rustversion] version = "1.0" [dev-dependencies.serde_derive] -version = "1.0" +version = "1.0.103" [dev-dependencies.serde_json] version = "1.0" +[dev-dependencies.serde_test] +version = "1.0.19" + [dev-dependencies.trybuild] -version = "1.0" +version = "1.0.18" -[dev-dependencies.walkdir] -version = "2.3" +[dev-dependencies.zerocopy] +version = "0.7" +features = ["derive"] [features] -default = [] example_generated = [] -rustc-dep-of-std = ["core", "compiler_builtins"] +rustc-dep-of-std = [ + "core", + "compiler_builtins", +] +std = [] diff --git a/vendor/bitflags/README.md b/vendor/bitflags/README.md index 0da0f85..f2ad555 100644 --- a/vendor/bitflags/README.md +++ b/vendor/bitflags/README.md @@ -2,14 +2,24 @@ bitflags ======== [![Rust](https://github.com/bitflags/bitflags/workflows/Rust/badge.svg)](https://github.com/bitflags/bitflags/actions) -[![Join the chat at https://gitter.im/bitflags/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bitflags/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge) [![Latest version](https://img.shields.io/crates/v/bitflags.svg)](https://crates.io/crates/bitflags) [![Documentation](https://docs.rs/bitflags/badge.svg)](https://docs.rs/bitflags) ![License](https://img.shields.io/crates/l/bitflags.svg) -A Rust macro to generate structures which behave like a set of bitflags +`bitflags` generates flags enums with well-defined semantics and ergonomic end-user APIs. + +You can use `bitflags` to: + +- provide more user-friendly bindings to C APIs where flags may or may not be fully known in advance. +- generate efficient options types with string parsing and formatting support. + +You can't use `bitflags` to: + +- guarantee only bits corresponding to defined flags will ever be set. `bitflags` allows access to the underlying bits type so arbitrary bits may be set. +- define bitfields. `bitflags` only generates types where set bits denote the presence of some combination of flags. - [Documentation](https://docs.rs/bitflags) +- [Specification](https://github.com/bitflags/bitflags/blob/main/spec.md) - [Release notes](https://github.com/bitflags/bitflags/releases) ## Usage @@ -18,7 +28,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -bitflags = "1.3" +bitflags = "2.6.0" ``` and this to your source code: @@ -27,6 +37,41 @@ and this to your source code: use bitflags::bitflags; ``` +## Example + +Generate a flags structure: + +```rust +use bitflags::bitflags; + +// The `bitflags!` macro generates `struct`s that manage a set of flags. +bitflags! { + /// Represents a set of flags. + #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + struct Flags: u32 { + /// The value `A`, at bit position `0`. + const A = 0b00000001; + /// The value `B`, at bit position `1`. + const B = 0b00000010; + /// The value `C`, at bit position `2`. + const C = 0b00000100; + + /// The combination of `A`, `B`, and `C`. + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); + } +} + +fn main() { + let e1 = Flags::A | Flags::C; + let e2 = Flags::B | Flags::C; + assert_eq!((e1 | e2), Flags::ABC); // union + assert_eq!((e1 & e2), Flags::C); // intersection + assert_eq!((e1 - e2), Flags::A); // set difference + assert_eq!(!e2, Flags::A); // set complement +} +``` + ## Rust Version Support -The minimum supported Rust version is 1.46 due to use of associated constants and const functions. +The minimum supported Rust version is documented in the `Cargo.toml` file. +This may be bumped in minor releases as necessary. diff --git a/vendor/bitflags/SECURITY.md b/vendor/bitflags/SECURITY.md new file mode 100644 index 0000000..790ac5b --- /dev/null +++ b/vendor/bitflags/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security updates are applied only to the latest release. + +## Reporting a Vulnerability + +If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. + +Please disclose it at [security advisory](https://github.com/bitflags/bitflags/security/advisories/new). + +This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. diff --git a/vendor/bitflags/benches/parse.rs b/vendor/bitflags/benches/parse.rs new file mode 100644 index 0000000..caa9203 --- /dev/null +++ b/vendor/bitflags/benches/parse.rs @@ -0,0 +1,96 @@ +#![feature(test)] + +extern crate test; + +use std::{ + fmt::{self, Display}, + str::FromStr, +}; + +bitflags::bitflags! { + struct Flags10: u32 { + const A = 0b0000_0000_0000_0001; + const B = 0b0000_0000_0000_0010; + const C = 0b0000_0000_0000_0100; + const D = 0b0000_0000_0000_1000; + const E = 0b0000_0000_0001_0000; + const F = 0b0000_0000_0010_0000; + const G = 0b0000_0000_0100_0000; + const H = 0b0000_0000_1000_0000; + const I = 0b0000_0001_0000_0000; + const J = 0b0000_0010_0000_0000; + } +} + +impl FromStr for Flags10 { + type Err = bitflags::parser::ParseError; + + fn from_str(flags: &str) -> Result { + Ok(Flags10(flags.parse()?)) + } +} + +impl Display for Flags10 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + Display::fmt(&self.0, f) + } +} + +#[bench] +fn format_flags_1_present(b: &mut test::Bencher) { + b.iter(|| Flags10::J.to_string()) +} + +#[bench] +fn format_flags_5_present(b: &mut test::Bencher) { + b.iter(|| (Flags10::F | Flags10::G | Flags10::H | Flags10::I | Flags10::J).to_string()) +} + +#[bench] +fn format_flags_10_present(b: &mut test::Bencher) { + b.iter(|| { + (Flags10::A + | Flags10::B + | Flags10::C + | Flags10::D + | Flags10::E + | Flags10::F + | Flags10::G + | Flags10::H + | Flags10::I + | Flags10::J) + .to_string() + }) +} + +#[bench] +fn parse_flags_1_10(b: &mut test::Bencher) { + b.iter(|| { + let flags: Flags10 = "J".parse().unwrap(); + flags + }) +} + +#[bench] +fn parse_flags_5_10(b: &mut test::Bencher) { + b.iter(|| { + let flags: Flags10 = "F | G | H | I | J".parse().unwrap(); + flags + }) +} + +#[bench] +fn parse_flags_10_10(b: &mut test::Bencher) { + b.iter(|| { + let flags: Flags10 = "A | B | C | D | E | F | G | H | I | J".parse().unwrap(); + flags + }) +} + +#[bench] +fn parse_flags_1_10_hex(b: &mut test::Bencher) { + b.iter(|| { + let flags: Flags10 = "0xFF".parse().unwrap(); + flags + }) +} diff --git a/vendor/bitflags/examples/custom_bits_type.rs b/vendor/bitflags/examples/custom_bits_type.rs new file mode 100644 index 0000000..8924bfd --- /dev/null +++ b/vendor/bitflags/examples/custom_bits_type.rs @@ -0,0 +1,97 @@ +use std::ops::{BitAnd, BitOr, BitXor, Not}; + +use bitflags::{Bits, Flag, Flags}; + +// Define a custom container that can be used in flags types +// Note custom bits types can't be used in `bitflags!` +// without making the trait impls `const`. This is currently +// unstable +#[derive(Clone, Copy, Debug)] +pub struct CustomBits([bool; 3]); + +impl Bits for CustomBits { + const EMPTY: Self = CustomBits([false; 3]); + + const ALL: Self = CustomBits([true; 3]); +} + +impl PartialEq for CustomBits { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl BitAnd for CustomBits { + type Output = Self; + + fn bitand(self, other: Self) -> Self { + CustomBits([ + self.0[0] & other.0[0], + self.0[1] & other.0[1], + self.0[2] & other.0[2], + ]) + } +} + +impl BitOr for CustomBits { + type Output = Self; + + fn bitor(self, other: Self) -> Self { + CustomBits([ + self.0[0] | other.0[0], + self.0[1] | other.0[1], + self.0[2] | other.0[2], + ]) + } +} + +impl BitXor for CustomBits { + type Output = Self; + + fn bitxor(self, other: Self) -> Self { + CustomBits([ + self.0[0] & other.0[0], + self.0[1] & other.0[1], + self.0[2] & other.0[2], + ]) + } +} + +impl Not for CustomBits { + type Output = Self; + + fn not(self) -> Self { + CustomBits([!self.0[0], !self.0[1], !self.0[2]]) + } +} + +#[derive(Clone, Copy, Debug)] +pub struct CustomFlags(CustomBits); + +impl CustomFlags { + pub const A: Self = CustomFlags(CustomBits([true, false, false])); + pub const B: Self = CustomFlags(CustomBits([false, true, false])); + pub const C: Self = CustomFlags(CustomBits([false, false, true])); +} + +impl Flags for CustomFlags { + const FLAGS: &'static [Flag] = &[ + Flag::new("A", Self::A), + Flag::new("B", Self::B), + Flag::new("C", Self::C), + ]; + + type Bits = CustomBits; + + fn bits(&self) -> Self::Bits { + self.0 + } + + fn from_bits_retain(bits: Self::Bits) -> Self { + CustomFlags(bits) + } +} + +fn main() { + println!("{:?}", CustomFlags::A.union(CustomFlags::C)); +} diff --git a/vendor/bitflags/examples/custom_derive.rs b/vendor/bitflags/examples/custom_derive.rs new file mode 100644 index 0000000..4239ee4 --- /dev/null +++ b/vendor/bitflags/examples/custom_derive.rs @@ -0,0 +1,23 @@ +//! An example of implementing the `BitFlags` trait manually for a flags type. + +use std::str; + +use bitflags::bitflags; + +// Define a flags type outside of the `bitflags` macro as a newtype +// It can accept custom derives for libraries `bitflags` doesn't support natively +#[derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes)] +#[repr(transparent)] +pub struct ManualFlags(u32); + +// Next: use `impl Flags` instead of `struct Flags` +bitflags! { + impl ManualFlags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); + } +} + +fn main() {} diff --git a/vendor/bitflags/examples/fmt.rs b/vendor/bitflags/examples/fmt.rs new file mode 100644 index 0000000..724b207 --- /dev/null +++ b/vendor/bitflags/examples/fmt.rs @@ -0,0 +1,49 @@ +//! An example of implementing Rust's standard formatting and parsing traits for flags types. + +use core::{fmt, str}; + +bitflags::bitflags! { + // You can `#[derive]` the `Debug` trait, but implementing it manually + // can produce output like `A | B` instead of `Flags(A | B)`. + // #[derive(Debug)] + #[derive(PartialEq, Eq)] + pub struct Flags: u32 { + const A = 1; + const B = 2; + const C = 4; + const D = 8; + } +} + +impl fmt::Debug for Flags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + bitflags::parser::to_writer(self, f) + } +} + +impl fmt::Display for Flags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + bitflags::parser::to_writer(self, f) + } +} + +impl str::FromStr for Flags { + type Err = bitflags::parser::ParseError; + + fn from_str(flags: &str) -> Result { + bitflags::parser::from_str(flags) + } +} + +fn main() -> Result<(), bitflags::parser::ParseError> { + let flags = Flags::A | Flags::B; + + println!("{}", flags); + + let formatted = flags.to_string(); + let parsed: Flags = formatted.parse()?; + + assert_eq!(flags, parsed); + + Ok(()) +} diff --git a/vendor/bitflags/examples/macro_free.rs b/vendor/bitflags/examples/macro_free.rs new file mode 100644 index 0000000..7563379 --- /dev/null +++ b/vendor/bitflags/examples/macro_free.rs @@ -0,0 +1,61 @@ +//! An example of implementing the `BitFlags` trait manually for a flags type. +//! +//! This example doesn't use any macros. + +use std::{fmt, str}; + +use bitflags::{Flag, Flags}; + +// First: Define your flags type. It just needs to be `Sized + 'static`. +pub struct ManualFlags(u32); + +// Not required: Define some constants for valid flags +impl ManualFlags { + pub const A: ManualFlags = ManualFlags(0b00000001); + pub const B: ManualFlags = ManualFlags(0b00000010); + pub const C: ManualFlags = ManualFlags(0b00000100); + pub const ABC: ManualFlags = ManualFlags(0b00000111); +} + +// Next: Implement the `BitFlags` trait, specifying your set of valid flags +// and iterators +impl Flags for ManualFlags { + const FLAGS: &'static [Flag] = &[ + Flag::new("A", Self::A), + Flag::new("B", Self::B), + Flag::new("C", Self::C), + ]; + + type Bits = u32; + + fn bits(&self) -> u32 { + self.0 + } + + fn from_bits_retain(bits: u32) -> Self { + Self(bits) + } +} + +// Not required: Add parsing support +impl str::FromStr for ManualFlags { + type Err = bitflags::parser::ParseError; + + fn from_str(input: &str) -> Result { + bitflags::parser::from_str(input) + } +} + +// Not required: Add formatting support +impl fmt::Display for ManualFlags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + bitflags::parser::to_writer(self, f) + } +} + +fn main() { + println!( + "{}", + ManualFlags::A.union(ManualFlags::B).union(ManualFlags::C) + ); +} diff --git a/vendor/bitflags/examples/serde.rs b/vendor/bitflags/examples/serde.rs new file mode 100644 index 0000000..22eae2d --- /dev/null +++ b/vendor/bitflags/examples/serde.rs @@ -0,0 +1,36 @@ +//! An example of implementing `serde::Serialize` and `serde::Deserialize`. +//! The `#[serde(transparent)]` attribute is recommended to serialize directly +//! to the underlying bits type without wrapping it in a `serde` newtype. + +#[cfg(feature = "serde")] +fn main() { + use serde_derive::*; + + bitflags::bitflags! { + #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] + #[serde(transparent)] + pub struct Flags: u32 { + const A = 1; + const B = 2; + const C = 4; + const D = 8; + } + } + + let flags = Flags::A | Flags::B; + + let serialized = serde_json::to_string(&flags).unwrap(); + + println!("{:?} -> {}", flags, serialized); + + assert_eq!(serialized, r#""A | B""#); + + let deserialized: Flags = serde_json::from_str(&serialized).unwrap(); + + println!("{} -> {:?}", serialized, flags); + + assert_eq!(deserialized, flags); +} + +#[cfg(not(feature = "serde"))] +fn main() {} diff --git a/vendor/bitflags/spec.md b/vendor/bitflags/spec.md new file mode 100644 index 0000000..43dae1d --- /dev/null +++ b/vendor/bitflags/spec.md @@ -0,0 +1,552 @@ +# Bitflags + +`bitflags` generates flags enums with well-defined semantics and ergonomic end-user APIs. + +You can use `bitflags` to: + +- provide more user-friendly bindings to C APIs where flags may or may not be fully known in advance. +- generate efficient options types with string parsing and formatting support. + +You can't use `bitflags` to: + +- guarantee only bits corresponding to defined flags will ever be set. `bitflags` allows access to the underlying bits type so arbitrary bits may be set. +- define bitfields. `bitflags` only generates types where set bits denote the presence of some combination of flags. + +## Definitions + +This section formally defines the terminology and semantics of `bitflags`. It's organized so more fundamental concepts are introduced before those that build on them. It may be helpful to start from the bottom of the section and refer back up to concepts defined earlier. + +Examples use `bitflags` syntax with `u8` as the bits type. + +### Bits type + +A type that defines a fixed number of bits at specific locations. + +---- + +Bits types are typically fixed-width unsigned integers. For example, `u8` is a bits type that defines 8 bits; bit-0 through bit-7. + +### Bits value + +An instance of a bits type where each bit may be set (`1`) or unset (`0`). + +---- + +Some examples of bits values for the bits type `u8` are: + +```rust +0b0000_0000 +0b1111_1111 +0b1010_0101 +``` + +#### Equality + +Two bits values are equal if their bits are in the same configuration; set bits in one are set in the other, and unset bits in one are unset in the other. + +#### Operations + +Bits values define the bitwise operators and (`&`), or (`|`), exclusive-or (`^`), and negation (`!`) that apply to each of their bits. + +### Flag + +A set of bits in a bits type that may have a unique name. + +---- + +Bits are not required to be exclusive to a flag. Bits are not required to be contiguous. + +The following is a flag for `u8` with the name `A` that includes bit-0: + +```rust +const A = 0b0000_0001; +``` + +The following is a flag for `u8` with the name `B` that includes bit-0, and bit-5: + +```rust +const B = 0b0010_0001; +``` + +#### Named flag + +A flag with a name. + +---- + +The following is a named flag, where the name is `A`: + +```rust +const A = 0b0000_0001; +``` + +#### Unnamed flag + +A flag without a name. + +---- + +The following is an unnamed flag: + +```rust +const _ = 0b0000_0001; +``` + +#### Zero-bit flag + +A flag with a set of zero bits. + +---- + +The following is a zero-bit flag: + +```rust +const ZERO = 0b0000_0000; +``` + +#### Single-bit flag + +A flag with a set of one bit. + +---- + +The following are single-bit flags: + +```rust +const A = 0b0000_0001; +const B = 0b0000_0010; +``` + +#### Multi-bit flag + +A flag with a set of more than one bit. + +---- + +The following are multi-bit flags: + +```rust +const A = 0b0000_0011; +const B = 0b1111_1111; +``` + +### Flags type + +A set of defined flags over a specific bits type. + +#### Known bit + +A bit in any defined flag. + +---- + +In the following flags type: + +```rust +struct Flags { + const A = 0b0000_0001; + const B = 0b0000_0010; + const C = 0b0000_0100; +} +``` + +the known bits are: + +```rust +0b0000_0111 +``` + +#### Unknown bit + +A bit not in any defined flag. + +---- + +In the following flags type: + +```rust +struct Flags { + const A = 0b0000_0001; + const B = 0b0000_0010; + const C = 0b0000_0100; +} +``` + +the unknown bits are: + +```rust +0b1111_1000 +``` + +### Flags value + +An instance of a flags type using its specific bits value for storage. + +The flags value of a flag is one where each of its bits is set, and all others are unset. + +#### Contains + +Whether all set bits in a source flags value are also set in a target flags value. + +---- + +Given the flags value: + +```rust +0b0000_0011 +``` + +the following flags values are contained: + +```rust +0b0000_0000 +0b0000_0010 +0b0000_0001 +0b0000_0011 +``` + +but the following flags values are not contained: + +```rust +0b0000_1000 +0b0000_0110 +``` + +#### Intersects + +Whether any set bits in a source flags value are also set in a target flags value. + +---- + +Given the flags value: + +```rust +0b0000_0011 +``` + +the following flags intersect: + +```rust +0b0000_0010 +0b0000_0001 +0b1111_1111 +``` + +but the following flags values do not intersect: + +```rust +0b0000_0000 +0b1111_0000 +``` + +#### Empty + +Whether all bits in a flags value are unset. + +---- + +The following flags value is empty: + +```rust +0b0000_0000 +``` + +The following flags values are not empty: + +```rust +0b0000_0001 +0b0110_0000 +``` + +#### All + +Whether all defined flags are contained in a flags value. + +---- + +Given a flags type: + +```rust +struct Flags { + const A = 0b0000_0001; + const B = 0b0000_0010; +} +``` + +the following flags values all satisfy all: + +```rust +0b0000_0011 +0b1000_0011 +0b1111_1111 +``` + +### Operations + +Examples in this section all use the given flags type: + +```rust +struct Flags { + const A = 0b0000_0001; + const B = 0b0000_0010; + const C = 0b0000_1100; +} +``` + +#### Truncate + +Unset all unknown bits in a flags value. + +---- + +Given the flags value: + +```rust +0b1111_1111 +``` + +the result of truncation will be: + +```rust +0b0000_1111 +``` + +---- + +Truncating doesn't guarantee that a non-empty result will contain any defined flags. Given the following flags type: + +```rust +struct Flags { + const A = 0b0000_0101; +} +``` + +and the following flags value: + +```rust +0b0000_1110; +``` + +The result of truncation will be: + +```rust +0b0000_0100; +``` + +which intersects the flag `A`, but doesn't contain it. + +This behavior is possible even when only operating with flags values containing defined flags. Given the following flags type: + +```rust +struct Flags { + const A = 0b0000_0101; + const B = 0b0000_0001; +} +``` + +The result of `A ^ B` is `0b0000_0100`, which also doesn't contain any defined flag. + +---- + +If all known bits are in the set of at least one defined single-bit flag, then all operations that produce non-empty results will always contain defined flags. + +#### Union + +The bitwise or (`|`) of the bits in two flags values. + +---- + +The following are examples of the result of unioning flags values: + +```rust +0b0000_0001 | 0b0000_0010 = 0b0000_0011 +0b0000_0000 | 0b1111_1111 = 0b1111_1111 +``` + +#### Intersection + +The bitwise and (`&`) of the bits in two flags values. + +---- + +The following are examples of the result of intersecting flags values: + +```rust +0b0000_0001 & 0b0000_0010 = 0b0000_0000 +0b1111_1100 & 0b1111_0111 = 0b1111_0100 +0b1111_1111 & 0b1111_1111 = 0b1111_1111 +``` + +#### Symmetric difference + +The bitwise exclusive-or (`^`) of the bits in two flags values. + +---- + +The following are examples of the symmetric difference between two flags values: + +```rust +0b0000_0001 ^ 0b0000_0010 = 0b0000_0011 +0b0000_1111 ^ 0b0000_0011 = 0b0000_1100 +0b1100_0000 ^ 0b0011_0000 = 0b1111_0000 +``` + +#### Complement + +The bitwise negation (`!`) of the bits in a flags value, truncating the result. + +---- + +The following are examples of the complement of a flags value: + +```rust +!0b0000_0000 = 0b0000_1111 +!0b0000_1111 = 0b0000_0000 +!0b1111_1000 = 0b0000_0111 +``` + +#### Difference + +The bitwise union (`|`) of the bits in one flags value and the bitwise negation (`!`) of the bits in another. + +---- + +This operation is not equivalent to the intersection of one flags value with the complement of another (`&!`). +The former will truncate the result, where difference will not. + +---- + +The following are examples of the difference between two flags values: + +```rust +0b0000_0001 & !0b0000_0010 = 0b0000_0001 +0b0000_1101 & !0b0000_0011 = 0b0000_1100 +0b1111_1111 & !0b0000_0001 = 0b1111_1110 +``` + +### Iteration + +Yield the bits of a source flags value in a set of contained flags values. + +---- + +To be most useful, each yielded flags value should set exactly the bits of a defined flag contained in the source. Any known bits that aren't in the set of any contained flag should be yielded together as a final flags value. + +---- + +Given the following flags type: + +```rust +struct Flags { + const A = 0b0000_0001; + const B = 0b0000_0010; + const AB = 0b0000_0011; +} +``` + +and the following flags value: + +```rust +0b0000_1111 +``` + +When iterated it may yield a flags value for `A` and `B`, then a final flag with the unknown bits: + +```rust +0b0000_0001 +0b0000_0010 +0b0000_1100 +``` + +It may also yield a flags value for `AB`, then a final flag with the unknown bits: + +```rust +0b0000_0011 +0b0000_1100 +``` + +---- + +Given the following flags type: + +```rust +struct Flags { + const A = 0b0000_0011; +} +``` + +and the following flags value: + +```rust +0b0000_0001 +``` + +When iterated it will still yield a flags value for the known bit `0b0000_0001` even though it doesn't contain a flag. + +### Formatting + +Format and parse a flags value as text using the following grammar: + +- _Flags:_ (_Whitespace_ _Flag_ _Whitespace_)`|`* +- _Flag:_ _Name_ | _Hex Number_ +- _Name:_ The name of any defined flag +- _Hex Number_: `0x`([0-9a-fA-F])* +- _Whitespace_: (\s)* + +Flags values can be formatted as _Flags_ by iterating over them, formatting each yielded flags value as a _Flag_. Any yielded flags value that sets exactly the bits of a defined flag with a name should be formatted as a _Name_. Otherwise it must be formatted as a _Hex Number_. + +Formatting and parsing supports three modes: + +- **Retain**: Formatting and parsing roundtrips exactly the bits of the source flags value. This is the default behavior. +- **Truncate**: Flags values are truncated before formatting, and truncated after parsing. +- **Strict**: A _Flag_ may only be formatted and parsed as a _Name_. _Hex numbers_ are not allowed. A consequence of this is that unknown bits and any bits that aren't in a contained named flag will be ignored. This is recommended for flags values serialized across API boundaries, like web services. + +Text that is empty or whitespace is an empty flags value. + +---- + +Given the following flags type: + +```rust +struct Flags { + const A = 0b0000_0001; + const B = 0b0000_0010; + const AB = 0b0000_0011; + const C = 0b0000_1100; +} +``` + +The following are examples of how flags values can be formatted using any mode: + +```rust +0b0000_0000 = "" +0b0000_0001 = "A" +0b0000_0010 = "B" +0b0000_0011 = "A | B" +0b0000_0011 = "AB" +0b0000_1111 = "A | B | C" +``` + +Truncate mode will unset any unknown bits: + +```rust +0b1000_0000 = "" +0b1111_1111 = "A | B | C" +0b0000_1000 = "0x8" +``` + +Retain mode will include any unknown bits as a final _Flag_: + +```rust +0b1000_0000 = "0x80" +0b1111_1111 = "A | B | C | 0xf0" +0b0000_1000 = "0x8" +``` + +Strict mode will unset any unknown bits, as well as bits not contained in any defined named flags: + +```rust +0b1000_0000 = "" +0b1111_1111 = "A | B | C" +0b0000_1000 = "" +``` diff --git a/vendor/bitflags/src/example_generated.rs b/vendor/bitflags/src/example_generated.rs index cf188d9..abb1118 100644 --- a/vendor/bitflags/src/example_generated.rs +++ b/vendor/bitflags/src/example_generated.rs @@ -1,14 +1,65 @@ //! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS //! CRATE**. +//! +//! Usually, when you call the `bitflags!` macro, only the `Flags` type would be visible. In this +//! example, the `Field0`, `Iter`, and `IterRaw` types are also exposed so that you can explore +//! their APIs. The `Field0` type can be accessed as `self.0` on an instance of `Flags`. -bitflags! { +__declare_public_bitflags! { /// This is the same `Flags` struct defined in the [crate level example](../index.html#example). /// Note that this struct is just for documentation purposes only, it must not be used outside /// this crate. - pub struct Flags: u32 { + pub struct Flags +} + +__declare_internal_bitflags! { + pub struct Field0: u32 +} + +__impl_internal_bitflags! { + Field0: u32, Flags { + // Field `A`. + /// + /// This flag has the value `0b00000001`. + const A = 0b00000001; + /// Field `B`. + /// + /// This flag has the value `0b00000010`. + const B = 0b00000010; + /// Field `C`. + /// + /// This flag has the value `0b00000100`. + const C = 0b00000100; + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); + } +} + +__impl_public_bitflags_forward! { + Flags: u32, Field0 +} + +__impl_public_bitflags_ops! { + Flags +} + +__impl_public_bitflags_iter! { + Flags: u32, Flags +} + +__impl_public_bitflags_consts! { + Flags: u32 { + /// Field `A`. + /// + /// This flag has the value `0b00000001`. const A = 0b00000001; + /// Field `B`. + /// + /// This flag has the value `0b00000010`. const B = 0b00000010; + /// Field `C`. + /// + /// This flag has the value `0b00000100`. const C = 0b00000100; - const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); } } diff --git a/vendor/bitflags/src/external.rs b/vendor/bitflags/src/external.rs new file mode 100644 index 0000000..716af83 --- /dev/null +++ b/vendor/bitflags/src/external.rs @@ -0,0 +1,262 @@ +//! Conditional trait implementations for external libraries. + +/* +How do I support a new external library? + +Let's say we want to add support for `my_library`. + +First, we create a module under `external`, like `serde` with any specialized code. +Ideally, any utilities in here should just work off the `Flags` trait and maybe a +few other assumed bounds. + +Next, re-export the library from the `__private` module here. + +Next, define a macro like so: + +```rust +#[macro_export] +#[doc(hidden)] +#[cfg(feature = "serde")] +macro_rules! __impl_external_bitflags_my_library { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => { + // Implementation goes here + }; +} + +#[macro_export] +#[doc(hidden)] +#[cfg(not(feature = "my_library"))] +macro_rules! __impl_external_bitflags_my_library { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => {}; +} +``` + +Note that the macro is actually defined twice; once for when the `my_library` feature +is available, and once for when it's not. This is because the `__impl_external_bitflags_my_library` +macro is called in an end-user's library, not in `bitflags`. In an end-user's library we don't +know whether or not a particular feature of `bitflags` is enabled, so we unconditionally call +the macro, where the body of that macro depends on the feature flag. + +Now, we add our macro call to the `__impl_external_bitflags` macro body: + +```rust +__impl_external_bitflags_my_library! { + $InternalBitFlags: $T, $PublicBitFlags { + $( + $(#[$inner $($args)*])* + const $Flag; + )* + } +} +``` +*/ + +pub(crate) mod __private { + #[cfg(feature = "serde")] + pub use serde; + + #[cfg(feature = "arbitrary")] + pub use arbitrary; + + #[cfg(feature = "bytemuck")] + pub use bytemuck; +} + +/// Implements traits from external libraries for the internal bitflags type. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_external_bitflags { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => { + // Any new library traits impls should be added here + // Use `serde` as an example: generate code when the feature is available, + // and a no-op when it isn't + + $crate::__impl_external_bitflags_serde! { + $InternalBitFlags: $T, $PublicBitFlags { + $( + $(#[$inner $($args)*])* + const $Flag; + )* + } + } + + $crate::__impl_external_bitflags_arbitrary! { + $InternalBitFlags: $T, $PublicBitFlags { + $( + $(#[$inner $($args)*])* + const $Flag; + )* + } + } + + $crate::__impl_external_bitflags_bytemuck! { + $InternalBitFlags: $T, $PublicBitFlags { + $( + $(#[$inner $($args)*])* + const $Flag; + )* + } + } + }; +} + +#[cfg(feature = "serde")] +pub mod serde; + +/// Implement `Serialize` and `Deserialize` for the internal bitflags type. +#[macro_export] +#[doc(hidden)] +#[cfg(feature = "serde")] +macro_rules! __impl_external_bitflags_serde { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => { + impl $crate::__private::serde::Serialize for $InternalBitFlags { + fn serialize( + &self, + serializer: S, + ) -> $crate::__private::core::result::Result { + $crate::serde::serialize( + &$PublicBitFlags::from_bits_retain(self.bits()), + serializer, + ) + } + } + + impl<'de> $crate::__private::serde::Deserialize<'de> for $InternalBitFlags { + fn deserialize>( + deserializer: D, + ) -> $crate::__private::core::result::Result { + let flags: $PublicBitFlags = $crate::serde::deserialize(deserializer)?; + + Ok(flags.0) + } + } + }; +} + +#[macro_export] +#[doc(hidden)] +#[cfg(not(feature = "serde"))] +macro_rules! __impl_external_bitflags_serde { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => {}; +} + +#[cfg(feature = "arbitrary")] +pub mod arbitrary; + +#[cfg(feature = "bytemuck")] +mod bytemuck; + +/// Implement `Arbitrary` for the internal bitflags type. +#[macro_export] +#[doc(hidden)] +#[cfg(feature = "arbitrary")] +macro_rules! __impl_external_bitflags_arbitrary { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => { + impl<'a> $crate::__private::arbitrary::Arbitrary<'a> for $InternalBitFlags { + fn arbitrary( + u: &mut $crate::__private::arbitrary::Unstructured<'a>, + ) -> $crate::__private::arbitrary::Result { + $crate::arbitrary::arbitrary::<$PublicBitFlags>(u).map(|flags| flags.0) + } + } + }; +} + +#[macro_export] +#[doc(hidden)] +#[cfg(not(feature = "arbitrary"))] +macro_rules! __impl_external_bitflags_arbitrary { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => {}; +} + +/// Implement `Pod` and `Zeroable` for the internal bitflags type. +#[macro_export] +#[doc(hidden)] +#[cfg(feature = "bytemuck")] +macro_rules! __impl_external_bitflags_bytemuck { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => { + // SAFETY: $InternalBitFlags is guaranteed to have the same ABI as $T, + // and $T implements Pod + unsafe impl $crate::__private::bytemuck::Pod for $InternalBitFlags where + $T: $crate::__private::bytemuck::Pod + { + } + + // SAFETY: $InternalBitFlags is guaranteed to have the same ABI as $T, + // and $T implements Zeroable + unsafe impl $crate::__private::bytemuck::Zeroable for $InternalBitFlags where + $T: $crate::__private::bytemuck::Zeroable + { + } + }; +} + +#[macro_export] +#[doc(hidden)] +#[cfg(not(feature = "bytemuck"))] +macro_rules! __impl_external_bitflags_bytemuck { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt; + )* + } + ) => {}; +} diff --git a/vendor/bitflags/src/external/arbitrary.rs b/vendor/bitflags/src/external/arbitrary.rs new file mode 100644 index 0000000..ea76f0a --- /dev/null +++ b/vendor/bitflags/src/external/arbitrary.rs @@ -0,0 +1,33 @@ +//! Specialized fuzzing for flags types using `arbitrary`. + +use crate::Flags; + +/** +Generate some arbitrary flags value with only known bits set. +*/ +pub fn arbitrary<'a, B: Flags>(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result +where + B::Bits: arbitrary::Arbitrary<'a>, +{ + B::from_bits(u.arbitrary()?).ok_or_else(|| arbitrary::Error::IncorrectFormat) +} + +#[cfg(test)] +mod tests { + use arbitrary::Arbitrary; + + bitflags! { + #[derive(Arbitrary)] + struct Color: u32 { + const RED = 0x1; + const GREEN = 0x2; + const BLUE = 0x4; + } + } + + #[test] + fn test_arbitrary() { + let mut unstructured = arbitrary::Unstructured::new(&[0_u8; 256]); + let _color = Color::arbitrary(&mut unstructured); + } +} diff --git a/vendor/bitflags/src/external/bytemuck.rs b/vendor/bitflags/src/external/bytemuck.rs new file mode 100644 index 0000000..a0cd68c --- /dev/null +++ b/vendor/bitflags/src/external/bytemuck.rs @@ -0,0 +1,19 @@ +#[cfg(test)] +mod tests { + use bytemuck::{Pod, Zeroable}; + + bitflags! { + #[derive(Pod, Zeroable, Clone, Copy)] + #[repr(transparent)] + struct Color: u32 { + const RED = 0x1; + const GREEN = 0x2; + const BLUE = 0x4; + } + } + + #[test] + fn test_bytemuck() { + assert_eq!(0x1, bytemuck::cast::(Color::RED)); + } +} diff --git a/vendor/bitflags/src/external/serde.rs b/vendor/bitflags/src/external/serde.rs new file mode 100644 index 0000000..be4f2ed --- /dev/null +++ b/vendor/bitflags/src/external/serde.rs @@ -0,0 +1,93 @@ +//! Specialized serialization for flags types using `serde`. + +use crate::{ + parser::{self, ParseHex, WriteHex}, + Flags, +}; +use core::{fmt, str}; +use serde::{ + de::{Error, Visitor}, + Deserialize, Deserializer, Serialize, Serializer, +}; + +/** +Serialize a set of flags as a human-readable string or their underlying bits. + +Any unknown bits will be retained. +*/ +pub fn serialize(flags: &B, serializer: S) -> Result +where + B::Bits: WriteHex + Serialize, +{ + // Serialize human-readable flags as a string like `"A | B"` + if serializer.is_human_readable() { + serializer.collect_str(&parser::AsDisplay(flags)) + } + // Serialize non-human-readable flags directly as the underlying bits + else { + flags.bits().serialize(serializer) + } +} + +/** +Deserialize a set of flags from a human-readable string or their underlying bits. + +Any unknown bits will be retained. +*/ +pub fn deserialize<'de, B: Flags, D: Deserializer<'de>>(deserializer: D) -> Result +where + B::Bits: ParseHex + Deserialize<'de>, +{ + if deserializer.is_human_readable() { + // Deserialize human-readable flags by parsing them from strings like `"A | B"` + struct FlagsVisitor(core::marker::PhantomData); + + impl<'de, B: Flags> Visitor<'de> for FlagsVisitor + where + B::Bits: ParseHex, + { + type Value = B; + + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("a string value of `|` separated flags") + } + + fn visit_str(self, flags: &str) -> Result { + parser::from_str(flags).map_err(|e| E::custom(e)) + } + } + + deserializer.deserialize_str(FlagsVisitor(Default::default())) + } else { + // Deserialize non-human-readable flags directly from the underlying bits + let bits = B::Bits::deserialize(deserializer)?; + + Ok(B::from_bits_retain(bits)) + } +} + +#[cfg(test)] +mod tests { + use serde_test::{assert_tokens, Configure, Token::*}; + bitflags! { + #[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug, PartialEq, Eq)] + #[serde(transparent)] + struct SerdeFlags: u32 { + const A = 1; + const B = 2; + const C = 4; + const D = 8; + } + } + + #[test] + fn test_serde_bitflags_default() { + assert_tokens(&SerdeFlags::empty().readable(), &[Str("")]); + + assert_tokens(&SerdeFlags::empty().compact(), &[U32(0)]); + + assert_tokens(&(SerdeFlags::A | SerdeFlags::B).readable(), &[Str("A | B")]); + + assert_tokens(&(SerdeFlags::A | SerdeFlags::B).compact(), &[U32(1 | 2)]); + } +} diff --git a/vendor/bitflags/src/internal.rs b/vendor/bitflags/src/internal.rs new file mode 100644 index 0000000..87d01cc --- /dev/null +++ b/vendor/bitflags/src/internal.rs @@ -0,0 +1,125 @@ +//! Generate the internal `bitflags`-facing flags type. +//! +//! The code generated here is owned by `bitflags`, but still part of its public API. +//! Changes to the types generated here need to be considered like any other public API change. + +/// Declare the `bitflags`-facing bitflags struct. +/// +/// This type is part of the `bitflags` crate's public API, but not part of the user's. +#[macro_export] +#[doc(hidden)] +macro_rules! __declare_internal_bitflags { + ( + $vis:vis struct $InternalBitFlags:ident: $T:ty + ) => { + // NOTE: The ABI of this type is _guaranteed_ to be the same as `T` + // This is relied on by some external libraries like `bytemuck` to make + // its `unsafe` trait impls sound. + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[repr(transparent)] + $vis struct $InternalBitFlags($T); + }; +} + +/// Implement functions on the private (bitflags-facing) bitflags type. +/// +/// Methods and trait implementations can be freely added here without breaking end-users. +/// If we want to expose new functionality to `#[derive]`, this is the place to do it. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_internal_bitflags { + ( + $InternalBitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt = $value:expr; + )* + } + ) => { + // NOTE: This impl is also used to prevent using bits types from non-primitive types + // in the `bitflags` macro. If this approach is changed, this guard will need to be + // retained somehow + impl $crate::__private::PublicFlags for $PublicBitFlags { + type Primitive = $T; + type Internal = $InternalBitFlags; + } + + impl $crate::__private::core::default::Default for $InternalBitFlags { + #[inline] + fn default() -> Self { + $InternalBitFlags::empty() + } + } + + impl $crate::__private::core::fmt::Debug for $InternalBitFlags { + fn fmt(&self, f: &mut $crate::__private::core::fmt::Formatter<'_>) -> $crate::__private::core::fmt::Result { + if self.is_empty() { + // If no flags are set then write an empty hex flag to avoid + // writing an empty string. In some contexts, like serialization, + // an empty string is preferable, but it may be unexpected in + // others for a format not to produce any output. + // + // We can remove this `0x0` and remain compatible with `FromStr`, + // because an empty string will still parse to an empty set of flags, + // just like `0x0` does. + $crate::__private::core::write!(f, "{:#x}", <$T as $crate::Bits>::EMPTY) + } else { + $crate::__private::core::fmt::Display::fmt(self, f) + } + } + } + + impl $crate::__private::core::fmt::Display for $InternalBitFlags { + fn fmt(&self, f: &mut $crate::__private::core::fmt::Formatter<'_>) -> $crate::__private::core::fmt::Result { + $crate::parser::to_writer(&$PublicBitFlags(*self), f) + } + } + + impl $crate::__private::core::str::FromStr for $InternalBitFlags { + type Err = $crate::parser::ParseError; + + fn from_str(s: &str) -> $crate::__private::core::result::Result { + $crate::parser::from_str::<$PublicBitFlags>(s).map(|flags| flags.0) + } + } + + impl $crate::__private::core::convert::AsRef<$T> for $InternalBitFlags { + fn as_ref(&self) -> &$T { + &self.0 + } + } + + impl $crate::__private::core::convert::From<$T> for $InternalBitFlags { + fn from(bits: $T) -> Self { + Self::from_bits_retain(bits) + } + } + + // The internal flags type offers a similar API to the public one + + $crate::__impl_public_bitflags! { + $InternalBitFlags: $T, $PublicBitFlags { + $( + $(#[$inner $($args)*])* + const $Flag = $value; + )* + } + } + + $crate::__impl_public_bitflags_ops! { + $InternalBitFlags + } + + $crate::__impl_public_bitflags_iter! { + $InternalBitFlags: $T, $PublicBitFlags + } + + impl $InternalBitFlags { + /// Returns a mutable reference to the raw value of the flags currently stored. + #[inline] + pub fn bits_mut(&mut self) -> &mut $T { + &mut self.0 + } + } + }; +} diff --git a/vendor/bitflags/src/iter.rs b/vendor/bitflags/src/iter.rs new file mode 100644 index 0000000..7f7ce55 --- /dev/null +++ b/vendor/bitflags/src/iter.rs @@ -0,0 +1,145 @@ +/*! +Yield the bits of a source flags value in a set of contained flags values. +*/ + +use crate::{Flag, Flags}; + +/** +An iterator over flags values. + +This iterator will yield flags values for contained, defined flags first, with any remaining bits yielded +as a final flags value. +*/ +pub struct Iter { + inner: IterNames, + done: bool, +} + +impl Iter { + pub(crate) fn new(flags: &B) -> Self { + Iter { + inner: IterNames::new(flags), + done: false, + } + } +} + +impl Iter { + // Used by the `bitflags` macro + #[doc(hidden)] + pub const fn __private_const_new(flags: &'static [Flag], source: B, remaining: B) -> Self { + Iter { + inner: IterNames::__private_const_new(flags, source, remaining), + done: false, + } + } +} + +impl Iterator for Iter { + type Item = B; + + fn next(&mut self) -> Option { + match self.inner.next() { + Some((_, flag)) => Some(flag), + None if !self.done => { + self.done = true; + + // After iterating through valid names, if there are any bits left over + // then return one final value that includes them. This makes `into_iter` + // and `from_iter` roundtrip + if !self.inner.remaining().is_empty() { + Some(B::from_bits_retain(self.inner.remaining.bits())) + } else { + None + } + } + None => None, + } + } +} + +/** +An iterator over flags values. + +This iterator only yields flags values for contained, defined, named flags. Any remaining bits +won't be yielded, but can be found with the [`IterNames::remaining`] method. +*/ +pub struct IterNames { + flags: &'static [Flag], + idx: usize, + source: B, + remaining: B, +} + +impl IterNames { + pub(crate) fn new(flags: &B) -> Self { + IterNames { + flags: B::FLAGS, + idx: 0, + remaining: B::from_bits_retain(flags.bits()), + source: B::from_bits_retain(flags.bits()), + } + } +} + +impl IterNames { + // Used by the bitflags macro + #[doc(hidden)] + pub const fn __private_const_new(flags: &'static [Flag], source: B, remaining: B) -> Self { + IterNames { + flags, + idx: 0, + remaining, + source, + } + } + + /// Get a flags value of any remaining bits that haven't been yielded yet. + /// + /// Once the iterator has finished, this method can be used to + /// check whether or not there are any bits that didn't correspond + /// to a contained, defined, named flag remaining. + pub fn remaining(&self) -> &B { + &self.remaining + } +} + +impl Iterator for IterNames { + type Item = (&'static str, B); + + fn next(&mut self) -> Option { + while let Some(flag) = self.flags.get(self.idx) { + // Short-circuit if our state is empty + if self.remaining.is_empty() { + return None; + } + + self.idx += 1; + + // Skip unnamed flags + if flag.name().is_empty() { + continue; + } + + let bits = flag.value().bits(); + + // If the flag is set in the original source _and_ it has bits that haven't + // been covered by a previous flag yet then yield it. These conditions cover + // two cases for multi-bit flags: + // + // 1. When flags partially overlap, such as `0b00000001` and `0b00000101`, we'll + // yield both flags. + // 2. When flags fully overlap, such as in convenience flags that are a shorthand for others, + // we won't yield both flags. + if self.source.contains(B::from_bits_retain(bits)) + && self.remaining.intersects(B::from_bits_retain(bits)) + { + self.remaining.remove(B::from_bits_retain(bits)); + + return Some((flag.name(), B::from_bits_retain(bits))); + } + } + + None + } +} diff --git a/vendor/bitflags/src/lib.rs b/vendor/bitflags/src/lib.rs index 935e432..a9a6aa4 100644 --- a/vendor/bitflags/src/lib.rs +++ b/vendor/bitflags/src/lib.rs @@ -8,1722 +8,920 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! A typesafe bitmask flag generator useful for sets of C-style bitmask flags. -//! It can be used for creating typesafe wrappers around C APIs. -//! -//! The `bitflags!` macro generates `struct`s that manage a set of flags. The -//! flags should only be defined for integer types, otherwise unexpected type -//! errors may occur at compile time. -//! -//! # Example -//! -//! ``` -//! use bitflags::bitflags; -//! -//! bitflags! { -//! struct Flags: u32 { -//! const A = 0b00000001; -//! const B = 0b00000010; -//! const C = 0b00000100; -//! const ABC = Self::A.bits | Self::B.bits | Self::C.bits; -//! } -//! } -//! -//! fn main() { -//! let e1 = Flags::A | Flags::C; -//! let e2 = Flags::B | Flags::C; -//! assert_eq!((e1 | e2), Flags::ABC); // union -//! assert_eq!((e1 & e2), Flags::C); // intersection -//! assert_eq!((e1 - e2), Flags::A); // set difference -//! assert_eq!(!e2, Flags::A); // set complement -//! } -//! ``` -//! -//! See [`example_generated::Flags`](./example_generated/struct.Flags.html) for documentation of code -//! generated by the above `bitflags!` expansion. -//! -//! The generated `struct`s can also be extended with type and trait -//! implementations: -//! -//! ``` -//! use std::fmt; -//! -//! use bitflags::bitflags; -//! -//! bitflags! { -//! struct Flags: u32 { -//! const A = 0b00000001; -//! const B = 0b00000010; -//! } -//! } -//! -//! impl Flags { -//! pub fn clear(&mut self) { -//! self.bits = 0; // The `bits` field can be accessed from within the -//! // same module where the `bitflags!` macro was invoked. -//! } -//! } -//! -//! impl fmt::Display for Flags { -//! fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -//! write!(f, "hi!") -//! } -//! } -//! -//! fn main() { -//! let mut flags = Flags::A | Flags::B; -//! flags.clear(); -//! assert!(flags.is_empty()); -//! assert_eq!(format!("{}", flags), "hi!"); -//! assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); -//! assert_eq!(format!("{:?}", Flags::B), "B"); -//! } -//! ``` -//! -//! # Visibility -//! -//! The generated structs and their associated flag constants are not exported -//! out of the current module by default. A definition can be exported out of -//! the current module by adding `pub` before `struct`: -//! -//! ``` -//! mod example { -//! use bitflags::bitflags; -//! -//! bitflags! { -//! pub struct Flags1: u32 { -//! const A = 0b00000001; -//! } -//! -//! # pub -//! struct Flags2: u32 { -//! const B = 0b00000010; -//! } -//! } -//! } -//! -//! fn main() { -//! let flag1 = example::Flags1::A; -//! let flag2 = example::Flags2::B; // error: const `B` is private -//! } -//! ``` -//! -//! # Attributes -//! -//! Attributes can be attached to the generated `struct`s by placing them -//! before the `struct` keyword. -//! -//! ## Representations -//! -//! It's valid to add a `#[repr(C)]` or `#[repr(transparent)]` attribute to a type -//! generated by `bitflags!`. In these cases, the type is guaranteed to be a newtype. -//! -//! ``` -//! use bitflags::bitflags; -//! -//! bitflags! { -//! #[repr(transparent)] -//! struct Flags: u32 { -//! const A = 0b00000001; -//! const B = 0b00000010; -//! const C = 0b00000100; -//! } -//! } -//! ``` -//! -//! # Trait implementations -//! -//! The `Copy`, `Clone`, `PartialEq`, `Eq`, `PartialOrd`, `Ord` and `Hash` -//! traits are automatically derived for the `struct`s using the `derive` attribute. -//! Additional traits can be derived by providing an explicit `derive` -//! attribute on `struct`. -//! -//! The `Extend` and `FromIterator` traits are implemented for the `struct`s, -//! too: `Extend` adds the union of the instances of the `struct` iterated over, -//! while `FromIterator` calculates the union. -//! -//! The `Binary`, `Debug`, `LowerHex`, `Octal` and `UpperHex` traits are also -//! implemented by displaying the bits value of the internal struct. -//! -//! ## Operators -//! -//! The following operator traits are implemented for the generated `struct`s: -//! -//! - `BitOr` and `BitOrAssign`: union -//! - `BitAnd` and `BitAndAssign`: intersection -//! - `BitXor` and `BitXorAssign`: toggle -//! - `Sub` and `SubAssign`: set difference -//! - `Not`: set complement -//! -//! # Methods -//! -//! The following methods are defined for the generated `struct`s: -//! -//! - `empty`: an empty set of flags -//! - `all`: the set of all defined flags -//! - `bits`: the raw value of the flags currently stored -//! - `from_bits`: convert from underlying bit representation, unless that -//! representation contains bits that do not correspond to a -//! defined flag -//! - `from_bits_truncate`: convert from underlying bit representation, dropping -//! any bits that do not correspond to defined flags -//! - `from_bits_unchecked`: convert from underlying bit representation, keeping -//! all bits (even those not corresponding to defined -//! flags) -//! - `is_empty`: `true` if no flags are currently stored -//! - `is_all`: `true` if currently set flags exactly equal all defined flags -//! - `intersects`: `true` if there are flags common to both `self` and `other` -//! - `contains`: `true` if all of the flags in `other` are contained within `self` -//! - `insert`: inserts the specified flags in-place -//! - `remove`: removes the specified flags in-place -//! - `toggle`: the specified flags will be inserted if not present, and removed -//! if they are. -//! - `set`: inserts or removes the specified flags depending on the passed value -//! - `intersection`: returns a new set of flags, containing only the flags present -//! in both `self` and `other` (the argument to the function). -//! - `union`: returns a new set of flags, containing any flags present in -//! either `self` or `other` (the argument to the function). -//! - `difference`: returns a new set of flags, containing all flags present in -//! `self` without any of the flags present in `other` (the -//! argument to the function). -//! - `symmetric_difference`: returns a new set of flags, containing all flags -//! present in either `self` or `other` (the argument -//! to the function), but not both. -//! - `complement`: returns a new set of flags, containing all flags which are -//! not set in `self`, but which are allowed for this type. -//! -//! ## Default -//! -//! The `Default` trait is not automatically implemented for the generated structs. -//! -//! If your default value is equal to `0` (which is the same value as calling `empty()` -//! on the generated struct), you can simply derive `Default`: -//! -//! ``` -//! use bitflags::bitflags; -//! -//! bitflags! { -//! // Results in default value with bits: 0 -//! #[derive(Default)] -//! struct Flags: u32 { -//! const A = 0b00000001; -//! const B = 0b00000010; -//! const C = 0b00000100; -//! } -//! } -//! -//! fn main() { -//! let derived_default: Flags = Default::default(); -//! assert_eq!(derived_default.bits(), 0); -//! } -//! ``` -//! -//! If your default value is not equal to `0` you need to implement `Default` yourself: -//! -//! ``` -//! use bitflags::bitflags; -//! -//! bitflags! { -//! struct Flags: u32 { -//! const A = 0b00000001; -//! const B = 0b00000010; -//! const C = 0b00000100; -//! } -//! } -//! -//! // explicit `Default` implementation -//! impl Default for Flags { -//! fn default() -> Flags { -//! Flags::A | Flags::C -//! } -//! } -//! -//! fn main() { -//! let implemented_default: Flags = Default::default(); -//! assert_eq!(implemented_default, (Flags::A | Flags::C)); -//! } -//! ``` -//! -//! # Zero Flags -//! -//! Flags with a value equal to zero will have some strange behavior that one should be aware of. -//! -//! ``` -//! use bitflags::bitflags; -//! -//! bitflags! { -//! struct Flags: u32 { -//! const NONE = 0b00000000; -//! const SOME = 0b00000001; -//! } -//! } -//! -//! fn main() { -//! let empty = Flags::empty(); -//! let none = Flags::NONE; -//! let some = Flags::SOME; -//! -//! // Zero flags are treated as always present -//! assert!(empty.contains(Flags::NONE)); -//! assert!(none.contains(Flags::NONE)); -//! assert!(some.contains(Flags::NONE)); -//! -//! // Zero flags will be ignored when testing for emptiness -//! assert!(none.is_empty()); -//! } -//! ``` -//! -//! Users should generally avoid defining a flag with a value of zero. - -#![cfg_attr(not(test), no_std)] -#![doc(html_root_url = "https://docs.rs/bitflags/1.3.2")] +/*! +Generate types for C-style flags with ergonomic APIs. -#[doc(hidden)] -pub extern crate core as _core; +# Getting started -/// The macro used to generate the flag structures. -/// -/// See the [crate level docs](../bitflags/index.html) for complete documentation. -/// -/// # Example -/// -/// ``` -/// use bitflags::bitflags; -/// -/// bitflags! { -/// struct Flags: u32 { -/// const A = 0b00000001; -/// const B = 0b00000010; -/// const C = 0b00000100; -/// const ABC = Self::A.bits | Self::B.bits | Self::C.bits; -/// } -/// } -/// -/// fn main() { -/// let e1 = Flags::A | Flags::C; -/// let e2 = Flags::B | Flags::C; -/// assert_eq!((e1 | e2), Flags::ABC); // union -/// assert_eq!((e1 & e2), Flags::C); // intersection -/// assert_eq!((e1 - e2), Flags::A); // set difference -/// assert_eq!(!e2, Flags::A); // set complement -/// } -/// ``` -/// -/// The generated `struct`s can also be extended with type and trait -/// implementations: -/// -/// ``` -/// use std::fmt; -/// -/// use bitflags::bitflags; -/// -/// bitflags! { -/// struct Flags: u32 { -/// const A = 0b00000001; -/// const B = 0b00000010; -/// } -/// } -/// -/// impl Flags { -/// pub fn clear(&mut self) { -/// self.bits = 0; // The `bits` field can be accessed from within the -/// // same module where the `bitflags!` macro was invoked. -/// } -/// } -/// -/// impl fmt::Display for Flags { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -/// write!(f, "hi!") -/// } -/// } -/// -/// fn main() { -/// let mut flags = Flags::A | Flags::B; -/// flags.clear(); -/// assert!(flags.is_empty()); -/// assert_eq!(format!("{}", flags), "hi!"); -/// assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); -/// assert_eq!(format!("{:?}", Flags::B), "B"); -/// } -/// ``` -#[macro_export(local_inner_macros)] -macro_rules! bitflags { - ( - $(#[$outer:meta])* - $vis:vis struct $BitFlags:ident: $T:ty { - $( - $(#[$inner:ident $($args:tt)*])* - const $Flag:ident = $value:expr; - )* - } +Add `bitflags` to your `Cargo.toml`: - $($t:tt)* - ) => { - $(#[$outer])* - #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] - $vis struct $BitFlags { - bits: $T, - } +```toml +[dependencies.bitflags] +version = "2.6.0" +``` - __impl_bitflags! { - $BitFlags: $T { - $( - $(#[$inner $($args)*])* - $Flag = $value; - )* - } - } +## Generating flags types - bitflags! { - $($t)* - } - }; - () => {}; -} +Use the [`bitflags`] macro to generate flags types: -// A helper macro to implement the `all` function. -#[macro_export(local_inner_macros)] -#[doc(hidden)] -macro_rules! __impl_all_bitflags { - ( - $BitFlags:ident: $T:ty { - $( - $(#[$attr:ident $($args:tt)*])* - $Flag:ident = $value:expr; - )+ - } - ) => { - // See `Debug::fmt` for why this approach is taken. - #[allow(non_snake_case)] - trait __BitFlags { - $( - const $Flag: $T = 0; - )+ - } - #[allow(non_snake_case)] - impl __BitFlags for $BitFlags { - $( - __impl_bitflags! { - #[allow(deprecated)] - $(? #[$attr $($args)*])* - const $Flag: $T = Self::$Flag.bits; - } - )+ - } - Self { bits: $(::$Flag)|+ } - }; - ( - $BitFlags:ident: $T:ty { } - ) => { - Self { bits: 0 } - }; -} +```rust +use bitflags::bitflags; -#[macro_export(local_inner_macros)] -#[doc(hidden)] -macro_rules! __impl_bitflags { - ( - $BitFlags:ident: $T:ty { - $( - $(#[$attr:ident $($args:tt)*])* - $Flag:ident = $value:expr; - )* - } - ) => { - impl $crate::_core::fmt::Debug for $BitFlags { - fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { - // This convoluted approach is to handle #[cfg]-based flag - // omission correctly. For example it needs to support: - // - // #[cfg(unix)] const A: Flag = /* ... */; - // #[cfg(windows)] const B: Flag = /* ... */; - - // Unconditionally define a check for every flag, even disabled - // ones. - #[allow(non_snake_case)] - trait __BitFlags { - $( - #[inline] - fn $Flag(&self) -> bool { false } - )* - } +bitflags! { + pub struct Flags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; + } +} +``` - // Conditionally override the check for just those flags that - // are not #[cfg]ed away. - #[allow(non_snake_case)] - impl __BitFlags for $BitFlags { - $( - __impl_bitflags! { - #[allow(deprecated)] - #[inline] - $(? #[$attr $($args)*])* - fn $Flag(&self) -> bool { - if Self::$Flag.bits == 0 && self.bits != 0 { - false - } else { - self.bits & Self::$Flag.bits == Self::$Flag.bits - } - } - } - )* - } +See the docs for the `bitflags` macro for the full syntax. - let mut first = true; - $( - if ::$Flag(self) { - if !first { - f.write_str(" | ")?; - } - first = false; - f.write_str($crate::_core::stringify!($Flag))?; - } - )* - let extra_bits = self.bits & !Self::all().bits(); - if extra_bits != 0 { - if !first { - f.write_str(" | ")?; - } - first = false; - f.write_str("0x")?; - $crate::_core::fmt::LowerHex::fmt(&extra_bits, f)?; - } - if first { - f.write_str("(empty)")?; - } - Ok(()) - } - } - impl $crate::_core::fmt::Binary for $BitFlags { - fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { - $crate::_core::fmt::Binary::fmt(&self.bits, f) - } - } - impl $crate::_core::fmt::Octal for $BitFlags { - fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { - $crate::_core::fmt::Octal::fmt(&self.bits, f) - } - } - impl $crate::_core::fmt::LowerHex for $BitFlags { - fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { - $crate::_core::fmt::LowerHex::fmt(&self.bits, f) - } - } - impl $crate::_core::fmt::UpperHex for $BitFlags { - fn fmt(&self, f: &mut $crate::_core::fmt::Formatter) -> $crate::_core::fmt::Result { - $crate::_core::fmt::UpperHex::fmt(&self.bits, f) - } - } +Also see the [`example_generated`](./example_generated/index.html) module for an example of what the `bitflags` macro generates for a flags type. - #[allow(dead_code)] - impl $BitFlags { - $( - $(#[$attr $($args)*])* - pub const $Flag: Self = Self { bits: $value }; - )* +### Externally defined flags - /// Returns an empty set of flags. - #[inline] - pub const fn empty() -> Self { - Self { bits: 0 } - } +If you're generating flags types for an external source, such as a C API, you can define +an extra unnamed flag as a mask of all bits the external source may ever set. Usually this would be all bits (`!0`): - /// Returns the set containing all flags. - #[inline] - pub const fn all() -> Self { - __impl_all_bitflags! { - $BitFlags: $T { - $( - $(#[$attr $($args)*])* - $Flag = $value; - )* - } - } - } +```rust +# use bitflags::bitflags; +bitflags! { + pub struct Flags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; - /// Returns the raw value of the flags currently stored. - #[inline] - pub const fn bits(&self) -> $T { - self.bits - } + // The source may set any bits + const _ = !0; + } +} +``` - /// Convert from underlying bit representation, unless that - /// representation contains bits that do not correspond to a flag. - #[inline] - pub const fn from_bits(bits: $T) -> $crate::_core::option::Option { - if (bits & !Self::all().bits()) == 0 { - $crate::_core::option::Option::Some(Self { bits }) - } else { - $crate::_core::option::Option::None - } - } +Why should you do this? Generated methods like `all` and truncating operators like `!` only consider +bits in defined flags. Adding an unnamed flag makes those methods consider additional bits, +without generating additional constants for them. It helps compatibility when the external source +may start setting additional bits at any time. The [known and unknown bits](#known-and-unknown-bits) +section has more details on this behavior. - /// Convert from underlying bit representation, dropping any bits - /// that do not correspond to flags. - #[inline] - pub const fn from_bits_truncate(bits: $T) -> Self { - Self { bits: bits & Self::all().bits } - } +### Custom derives - /// Convert from underlying bit representation, preserving all - /// bits (even those not corresponding to a defined flag). - /// - /// # Safety - /// - /// The caller of the `bitflags!` macro can chose to allow or - /// disallow extra bits for their bitflags type. - /// - /// The caller of `from_bits_unchecked()` has to ensure that - /// all bits correspond to a defined flag or that extra bits - /// are valid for this bitflags type. - #[inline] - pub const unsafe fn from_bits_unchecked(bits: $T) -> Self { - Self { bits } - } +You can derive some traits on generated flags types if you enable Cargo features. The following +libraries are currently supported: - /// Returns `true` if no flags are currently stored. - #[inline] - pub const fn is_empty(&self) -> bool { - self.bits() == Self::empty().bits() - } +- `serde`: Support `#[derive(Serialize, Deserialize)]`, using text for human-readable formats, +and a raw number for binary formats. +- `arbitrary`: Support `#[derive(Arbitrary)]`, only generating flags values with known bits. +- `bytemuck`: Support `#[derive(Pod, Zeroable)]`, for casting between flags values and their +underlying bits values. - /// Returns `true` if all flags are currently set. - #[inline] - pub const fn is_all(&self) -> bool { - Self::all().bits | self.bits == self.bits - } +You can also define your own flags type outside of the [`bitflags`] macro and then use it to generate methods. +This can be useful if you need a custom `#[derive]` attribute for a library that `bitflags` doesn't +natively support: - /// Returns `true` if there are flags common to both `self` and `other`. - #[inline] - pub const fn intersects(&self, other: Self) -> bool { - !(Self { bits: self.bits & other.bits}).is_empty() - } +```rust +# use std::fmt::Debug as SomeTrait; +# use bitflags::bitflags; +#[derive(SomeTrait)] +pub struct Flags(u32); - /// Returns `true` if all of the flags in `other` are contained within `self`. - #[inline] - pub const fn contains(&self, other: Self) -> bool { - (self.bits & other.bits) == other.bits - } +bitflags! { + impl Flags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; + } +} +``` - /// Inserts the specified flags in-place. - #[inline] - pub fn insert(&mut self, other: Self) { - self.bits |= other.bits; - } +### Adding custom methods - /// Removes the specified flags in-place. - #[inline] - pub fn remove(&mut self, other: Self) { - self.bits &= !other.bits; - } +The [`bitflags`] macro supports attributes on generated flags types within the macro itself, while +`impl` blocks can be added outside of it: - /// Toggles the specified flags in-place. - #[inline] - pub fn toggle(&mut self, other: Self) { - self.bits ^= other.bits; - } +```rust +# use bitflags::bitflags; +bitflags! { + // Attributes can be applied to flags types + #[repr(transparent)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] + pub struct Flags: u32 { + const A = 0b00000001; + const B = 0b00000010; + const C = 0b00000100; + } +} - /// Inserts or removes the specified flags depending on the passed value. - #[inline] - pub fn set(&mut self, other: Self, value: bool) { - if value { - self.insert(other); - } else { - self.remove(other); - } - } +// Impl blocks can be added to flags types +impl Flags { + pub fn as_u64(&self) -> u64 { + self.bits() as u64 + } +} +``` - /// Returns the intersection between the flags in `self` and - /// `other`. - /// - /// Specifically, the returned set contains only the flags which are - /// present in *both* `self` *and* `other`. - /// - /// This is equivalent to using the `&` operator (e.g. - /// [`ops::BitAnd`]), as in `flags & other`. - /// - /// [`ops::BitAnd`]: https://doc.rust-lang.org/std/ops/trait.BitAnd.html - #[inline] - #[must_use] - pub const fn intersection(self, other: Self) -> Self { - Self { bits: self.bits & other.bits } - } +## Working with flags values - /// Returns the union of between the flags in `self` and `other`. - /// - /// Specifically, the returned set contains all flags which are - /// present in *either* `self` *or* `other`, including any which are - /// present in both (see [`Self::symmetric_difference`] if that - /// is undesirable). - /// - /// This is equivalent to using the `|` operator (e.g. - /// [`ops::BitOr`]), as in `flags | other`. - /// - /// [`ops::BitOr`]: https://doc.rust-lang.org/std/ops/trait.BitOr.html - #[inline] - #[must_use] - pub const fn union(self, other: Self) -> Self { - Self { bits: self.bits | other.bits } - } +Use generated constants and standard bitwise operators to interact with flags values: - /// Returns the difference between the flags in `self` and `other`. - /// - /// Specifically, the returned set contains all flags present in - /// `self`, except for the ones present in `other`. - /// - /// It is also conceptually equivalent to the "bit-clear" operation: - /// `flags & !other` (and this syntax is also supported). - /// - /// This is equivalent to using the `-` operator (e.g. - /// [`ops::Sub`]), as in `flags - other`. - /// - /// [`ops::Sub`]: https://doc.rust-lang.org/std/ops/trait.Sub.html - #[inline] - #[must_use] - pub const fn difference(self, other: Self) -> Self { - Self { bits: self.bits & !other.bits } - } +```rust +# use bitflags::bitflags; +# bitflags! { +# #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +# pub struct Flags: u32 { +# const A = 0b00000001; +# const B = 0b00000010; +# const C = 0b00000100; +# } +# } +// union +let ab = Flags::A | Flags::B; - /// Returns the [symmetric difference][sym-diff] between the flags - /// in `self` and `other`. - /// - /// Specifically, the returned set contains the flags present which - /// are present in `self` or `other`, but that are not present in - /// both. Equivalently, it contains the flags present in *exactly - /// one* of the sets `self` and `other`. - /// - /// This is equivalent to using the `^` operator (e.g. - /// [`ops::BitXor`]), as in `flags ^ other`. - /// - /// [sym-diff]: https://en.wikipedia.org/wiki/Symmetric_difference - /// [`ops::BitXor`]: https://doc.rust-lang.org/std/ops/trait.BitXor.html - #[inline] - #[must_use] - pub const fn symmetric_difference(self, other: Self) -> Self { - Self { bits: self.bits ^ other.bits } - } +// intersection +let a = ab & Flags::A; - /// Returns the complement of this set of flags. - /// - /// Specifically, the returned set contains all the flags which are - /// not set in `self`, but which are allowed for this type. - /// - /// Alternatively, it can be thought of as the set difference - /// between [`Self::all()`] and `self` (e.g. `Self::all() - self`) - /// - /// This is equivalent to using the `!` operator (e.g. - /// [`ops::Not`]), as in `!flags`. - /// - /// [`Self::all()`]: Self::all - /// [`ops::Not`]: https://doc.rust-lang.org/std/ops/trait.Not.html - #[inline] - #[must_use] - pub const fn complement(self) -> Self { - Self::from_bits_truncate(!self.bits) - } +// difference +let b = ab - Flags::A; - } +// complement +let c = !ab; +``` - impl $crate::_core::ops::BitOr for $BitFlags { - type Output = Self; +See the docs for the [`Flags`] trait for more details on operators and how they behave. - /// Returns the union of the two sets of flags. - #[inline] - fn bitor(self, other: $BitFlags) -> Self { - Self { bits: self.bits | other.bits } - } - } +# Formatting and parsing - impl $crate::_core::ops::BitOrAssign for $BitFlags { - /// Adds the set of flags. - #[inline] - fn bitor_assign(&mut self, other: Self) { - self.bits |= other.bits; - } - } +`bitflags` defines a text format that can be used to convert any flags value to and from strings. - impl $crate::_core::ops::BitXor for $BitFlags { - type Output = Self; +See the [`parser`] module for more details. - /// Returns the left flags, but with all the right flags toggled. - #[inline] - fn bitxor(self, other: Self) -> Self { - Self { bits: self.bits ^ other.bits } - } - } +# Specification - impl $crate::_core::ops::BitXorAssign for $BitFlags { - /// Toggles the set of flags. - #[inline] - fn bitxor_assign(&mut self, other: Self) { - self.bits ^= other.bits; - } - } +The terminology and behavior of generated flags types is +[specified in the source repository](https://github.com/bitflags/bitflags/blob/main/spec.md). +Details are repeated in these docs where appropriate, but is exhaustively listed in the spec. Some +things are worth calling out explicitly here. - impl $crate::_core::ops::BitAnd for $BitFlags { - type Output = Self; +## Flags types, flags values, flags - /// Returns the intersection between the two sets of flags. - #[inline] - fn bitand(self, other: Self) -> Self { - Self { bits: self.bits & other.bits } - } - } +The spec and these docs use consistent terminology to refer to things in the bitflags domain: - impl $crate::_core::ops::BitAndAssign for $BitFlags { - /// Disables all flags disabled in the set. - #[inline] - fn bitand_assign(&mut self, other: Self) { - self.bits &= other.bits; - } - } +- **Bits type**: A type that defines a fixed number of bits at specific locations. +- **Flag**: A set of bits in a bits type that may have a unique name. +- **Flags type**: A set of defined flags over a specific bits type. +- **Flags value**: An instance of a flags type using its specific bits value for storage. - impl $crate::_core::ops::Sub for $BitFlags { - type Output = Self; +``` +# use bitflags::bitflags; +bitflags! { + struct FlagsType: u8 { +// -- Bits type +// --------- Flags type + const A = 1; +// ----- Flag + } +} - /// Returns the set difference of the two sets of flags. - #[inline] - fn sub(self, other: Self) -> Self { - Self { bits: self.bits & !other.bits } - } - } +let flag = FlagsType::A; +// ---- Flags value +``` - impl $crate::_core::ops::SubAssign for $BitFlags { - /// Disables all flags enabled in the set. - #[inline] - fn sub_assign(&mut self, other: Self) { - self.bits &= !other.bits; - } - } +## Known and unknown bits - impl $crate::_core::ops::Not for $BitFlags { - type Output = Self; +Any bits in a flag you define are called _known bits_. Any other bits are _unknown bits_. +In the following flags type: - /// Returns the complement of this set of flags. - #[inline] - fn not(self) -> Self { - Self { bits: !self.bits } & Self::all() - } - } - - impl $crate::_core::iter::Extend<$BitFlags> for $BitFlags { - fn extend>(&mut self, iterator: T) { - for item in iterator { - self.insert(item) - } - } - } - - impl $crate::_core::iter::FromIterator<$BitFlags> for $BitFlags { - fn from_iter>(iterator: T) -> Self { - let mut result = Self::empty(); - result.extend(iterator); - result - } - } - }; +``` +# use bitflags::bitflags; +bitflags! { + struct Flags: u8 { + const A = 1; + const B = 1 << 1; + const C = 1 << 2; + } +} +``` - // Every attribute that the user writes on a const is applied to the - // corresponding const that we generate, but within the implementation of - // Debug and all() we want to ignore everything but #[cfg] attributes. In - // particular, including a #[deprecated] attribute on those items would fail - // to compile. - // https://github.com/bitflags/bitflags/issues/109 - // - // Input: - // - // ? #[cfg(feature = "advanced")] - // ? #[deprecated(note = "Use something else.")] - // ? #[doc = r"High quality documentation."] - // fn f() -> i32 { /* ... */ } - // - // Output: - // - // #[cfg(feature = "advanced")] - // fn f() -> i32 { /* ... */ } - ( - $(#[$filtered:meta])* - ? #[cfg $($cfgargs:tt)*] - $(? #[$rest:ident $($restargs:tt)*])* - fn $($item:tt)* - ) => { - __impl_bitflags! { - $(#[$filtered])* - #[cfg $($cfgargs)*] - $(? #[$rest $($restargs)*])* - fn $($item)* - } - }; - ( - $(#[$filtered:meta])* - // $next != `cfg` - ? #[$next:ident $($nextargs:tt)*] - $(? #[$rest:ident $($restargs:tt)*])* - fn $($item:tt)* - ) => { - __impl_bitflags! { - $(#[$filtered])* - // $next filtered out - $(? #[$rest $($restargs)*])* - fn $($item)* - } - }; - ( - $(#[$filtered:meta])* - fn $($item:tt)* - ) => { - $(#[$filtered])* - fn $($item)* - }; +The known bits are `0b0000_0111` and the unknown bits are `0b1111_1000`. - // Every attribute that the user writes on a const is applied to the - // corresponding const that we generate, but within the implementation of - // Debug and all() we want to ignore everything but #[cfg] attributes. In - // particular, including a #[deprecated] attribute on those items would fail - // to compile. - // https://github.com/bitflags/bitflags/issues/109 - // - // const version - // - // Input: - // - // ? #[cfg(feature = "advanced")] - // ? #[deprecated(note = "Use something else.")] - // ? #[doc = r"High quality documentation."] - // const f: i32 { /* ... */ } - // - // Output: - // - // #[cfg(feature = "advanced")] - // const f: i32 { /* ... */ } - ( - $(#[$filtered:meta])* - ? #[cfg $($cfgargs:tt)*] - $(? #[$rest:ident $($restargs:tt)*])* - const $($item:tt)* - ) => { - __impl_bitflags! { - $(#[$filtered])* - #[cfg $($cfgargs)*] - $(? #[$rest $($restargs)*])* - const $($item)* - } - }; - ( - $(#[$filtered:meta])* - // $next != `cfg` - ? #[$next:ident $($nextargs:tt)*] - $(? #[$rest:ident $($restargs:tt)*])* - const $($item:tt)* - ) => { - __impl_bitflags! { - $(#[$filtered])* - // $next filtered out - $(? #[$rest $($restargs)*])* - const $($item)* - } - }; - ( - $(#[$filtered:meta])* - const $($item:tt)* - ) => { - $(#[$filtered])* - const $($item)* - }; -} +`bitflags` doesn't guarantee that a flags value will only ever have known bits set, but some operators +will unset any unknown bits they encounter. In a future version of `bitflags`, all operators will +unset unknown bits. -#[cfg(feature = "example_generated")] -pub mod example_generated; +If you're using `bitflags` for flags types defined externally, such as from C, you probably want all +bits to be considered known, in case that external source changes. You can do this using an unnamed +flag, as described in [externally defined flags](#externally-defined-flags). -#[cfg(test)] -mod tests { - use std::collections::hash_map::DefaultHasher; - use std::hash::{Hash, Hasher}; - - bitflags! { - #[doc = "> The first principle is that you must not fool yourself — and"] - #[doc = "> you are the easiest person to fool."] - #[doc = "> "] - #[doc = "> - Richard Feynman"] - #[derive(Default)] - struct Flags: u32 { - const A = 0b00000001; - #[doc = " macros are way better at generating code than trans is"] - const B = 0b00000010; - const C = 0b00000100; - #[doc = "* cmr bed"] - #[doc = "* strcat table"] - #[doc = " wait what?"] - const ABC = Self::A.bits | Self::B.bits | Self::C.bits; - } +## Zero-bit flags - struct _CfgFlags: u32 { - #[cfg(unix)] - const _CFG_A = 0b01; - #[cfg(windows)] - const _CFG_B = 0b01; - #[cfg(unix)] - const _CFG_C = Self::_CFG_A.bits | 0b10; - } +Flags with no bits set should be avoided because they interact strangely with [`Flags::contains`] +and [`Flags::intersects`]. A zero-bit flag is always contained, but is never intersected. The +names of zero-bit flags can be parsed, but are never formatted. - struct AnotherSetOfFlags: i8 { - const ANOTHER_FLAG = -1_i8; - } +## Multi-bit flags - struct LongFlags: u32 { - const LONG_A = 0b1111111111111111; - } - } +Flags that set multiple bits should be avoided unless each bit is also in a single-bit flag. +Take the following flags type as an example: - bitflags! { - struct EmptyFlags: u32 { - } +``` +# use bitflags::bitflags; +bitflags! { + struct Flags: u8 { + const A = 1; + const B = 1 | 1 << 1; } +} +``` - #[test] - fn test_bits() { - assert_eq!(Flags::empty().bits(), 0b00000000); - assert_eq!(Flags::A.bits(), 0b00000001); - assert_eq!(Flags::ABC.bits(), 0b00000111); +The result of `Flags::A ^ Flags::B` is `0b0000_0010`, which doesn't correspond to either +`Flags::A` or `Flags::B` even though it's still a known bit. +*/ - assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00); - assert_eq!(AnotherSetOfFlags::ANOTHER_FLAG.bits(), !0_i8); +#![cfg_attr(not(any(feature = "std", test)), no_std)] +#![cfg_attr(not(test), forbid(unsafe_code))] +#![cfg_attr(test, allow(mixed_script_confusables))] - assert_eq!(EmptyFlags::empty().bits(), 0b00000000); - } +#[doc(inline)] +pub use traits::{Bits, Flag, Flags}; - #[test] - fn test_from_bits() { - assert_eq!(Flags::from_bits(0), Some(Flags::empty())); - assert_eq!(Flags::from_bits(0b1), Some(Flags::A)); - assert_eq!(Flags::from_bits(0b10), Some(Flags::B)); - assert_eq!(Flags::from_bits(0b11), Some(Flags::A | Flags::B)); - assert_eq!(Flags::from_bits(0b1000), None); - - assert_eq!( - AnotherSetOfFlags::from_bits(!0_i8), - Some(AnotherSetOfFlags::ANOTHER_FLAG) - ); - - assert_eq!(EmptyFlags::from_bits(0), Some(EmptyFlags::empty())); - assert_eq!(EmptyFlags::from_bits(0b1), None); - } +pub mod iter; +pub mod parser; - #[test] - fn test_from_bits_truncate() { - assert_eq!(Flags::from_bits_truncate(0), Flags::empty()); - assert_eq!(Flags::from_bits_truncate(0b1), Flags::A); - assert_eq!(Flags::from_bits_truncate(0b10), Flags::B); - assert_eq!(Flags::from_bits_truncate(0b11), (Flags::A | Flags::B)); - assert_eq!(Flags::from_bits_truncate(0b1000), Flags::empty()); - assert_eq!(Flags::from_bits_truncate(0b1001), Flags::A); - - assert_eq!( - AnotherSetOfFlags::from_bits_truncate(0_i8), - AnotherSetOfFlags::empty() - ); - - assert_eq!(EmptyFlags::from_bits_truncate(0), EmptyFlags::empty()); - assert_eq!(EmptyFlags::from_bits_truncate(0b1), EmptyFlags::empty()); - } +mod traits; - #[test] - fn test_from_bits_unchecked() { - let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; - assert_eq!(unsafe { Flags::from_bits_unchecked(0) }, Flags::empty()); - assert_eq!(unsafe { Flags::from_bits_unchecked(0b1) }, Flags::A); - assert_eq!(unsafe { Flags::from_bits_unchecked(0b10) }, Flags::B); - - assert_eq!( - unsafe { Flags::from_bits_unchecked(0b11) }, - (Flags::A | Flags::B) - ); - assert_eq!( - unsafe { Flags::from_bits_unchecked(0b1000) }, - (extra | Flags::empty()) - ); - assert_eq!( - unsafe { Flags::from_bits_unchecked(0b1001) }, - (extra | Flags::A) - ); - - let extra = unsafe { EmptyFlags::from_bits_unchecked(0b1000) }; - assert_eq!( - unsafe { EmptyFlags::from_bits_unchecked(0b1000) }, - (extra | EmptyFlags::empty()) - ); - } +#[doc(hidden)] +pub mod __private { + #[allow(unused_imports)] + // Easier than conditionally checking any optional external dependencies + pub use crate::{external::__private::*, traits::__private::*}; - #[test] - fn test_is_empty() { - assert!(Flags::empty().is_empty()); - assert!(!Flags::A.is_empty()); - assert!(!Flags::ABC.is_empty()); + pub use core; +} - assert!(!AnotherSetOfFlags::ANOTHER_FLAG.is_empty()); +#[allow(unused_imports)] +pub use external::*; - assert!(EmptyFlags::empty().is_empty()); - assert!(EmptyFlags::all().is_empty()); - } +#[allow(deprecated)] +pub use traits::BitFlags; - #[test] - fn test_is_all() { - assert!(Flags::all().is_all()); - assert!(!Flags::A.is_all()); - assert!(Flags::ABC.is_all()); +/* +How does the bitflags crate work? - let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; - assert!(!extra.is_all()); - assert!(!(Flags::A | extra).is_all()); - assert!((Flags::ABC | extra).is_all()); +This library generates a `struct` in the end-user's crate with a bunch of constants on it that represent flags. +The difference between `bitflags` and a lot of other libraries is that we don't actually control the generated `struct` in the end. +It's part of the end-user's crate, so it belongs to them. That makes it difficult to extend `bitflags` with new functionality +because we could end up breaking valid code that was already written. - assert!(AnotherSetOfFlags::ANOTHER_FLAG.is_all()); +Our solution is to split the type we generate into two: the public struct owned by the end-user, and an internal struct owned by `bitflags` (us). +To give you an example, let's say we had a crate that called `bitflags!`: - assert!(EmptyFlags::all().is_all()); - assert!(EmptyFlags::empty().is_all()); +```rust +bitflags! { + pub struct MyFlags: u32 { + const A = 1; + const B = 2; } +} +``` - #[test] - fn test_two_empties_do_not_intersect() { - let e1 = Flags::empty(); - let e2 = Flags::empty(); - assert!(!e1.intersects(e2)); +What they'd end up with looks something like this: - assert!(AnotherSetOfFlags::ANOTHER_FLAG.intersects(AnotherSetOfFlags::ANOTHER_FLAG)); - } +```rust +pub struct MyFlags(::InternalBitFlags); - #[test] - fn test_empty_does_not_intersect_with_full() { - let e1 = Flags::empty(); - let e2 = Flags::ABC; - assert!(!e1.intersects(e2)); +const _: () = { + #[repr(transparent)] + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct MyInternalBitFlags { + bits: u32, } - #[test] - fn test_disjoint_intersects() { - let e1 = Flags::A; - let e2 = Flags::B; - assert!(!e1.intersects(e2)); + impl PublicFlags for MyFlags { + type Internal = InternalBitFlags; } +}; +``` - #[test] - fn test_overlapping_intersects() { - let e1 = Flags::A; - let e2 = Flags::A | Flags::B; - assert!(e1.intersects(e2)); - } +If we want to expose something like a new trait impl for generated flags types, we add it to our generated `MyInternalBitFlags`, +and let `#[derive]` on `MyFlags` pick up that implementation, if an end-user chooses to add one. - #[test] - fn test_contains() { - let e1 = Flags::A; - let e2 = Flags::A | Flags::B; - assert!(!e1.contains(e2)); - assert!(e2.contains(e1)); - assert!(Flags::ABC.contains(e2)); +The public API is generated in the `__impl_public_flags!` macro, and the internal API is generated in +the `__impl_internal_flags!` macro. - assert!(AnotherSetOfFlags::ANOTHER_FLAG.contains(AnotherSetOfFlags::ANOTHER_FLAG)); +The macros are split into 3 modules: - assert!(EmptyFlags::empty().contains(EmptyFlags::empty())); - } +- `public`: where the user-facing flags types are generated. +- `internal`: where the `bitflags`-facing flags types are generated. +- `external`: where external library traits are implemented conditionally. +*/ - #[test] - fn test_insert() { - let mut e1 = Flags::A; - let e2 = Flags::A | Flags::B; - e1.insert(e2); - assert_eq!(e1, e2); +/** +Generate a flags type. - let mut e3 = AnotherSetOfFlags::empty(); - e3.insert(AnotherSetOfFlags::ANOTHER_FLAG); - assert_eq!(e3, AnotherSetOfFlags::ANOTHER_FLAG); - } +# `struct` mode - #[test] - fn test_remove() { - let mut e1 = Flags::A | Flags::B; - let e2 = Flags::A | Flags::C; - e1.remove(e2); - assert_eq!(e1, Flags::B); +A declaration that begins with `$vis struct` will generate a `struct` for a flags type, along with +methods and trait implementations for it. The body of the declaration defines flags as constants, +where each constant is a flags value of the generated flags type. - let mut e3 = AnotherSetOfFlags::ANOTHER_FLAG; - e3.remove(AnotherSetOfFlags::ANOTHER_FLAG); - assert_eq!(e3, AnotherSetOfFlags::empty()); - } +## Examples - #[test] - fn test_operators() { - let e1 = Flags::A | Flags::C; - let e2 = Flags::B | Flags::C; - assert_eq!((e1 | e2), Flags::ABC); // union - assert_eq!((e1 & e2), Flags::C); // intersection - assert_eq!((e1 - e2), Flags::A); // set difference - assert_eq!(!e2, Flags::A); // set complement - assert_eq!(e1 ^ e2, Flags::A | Flags::B); // toggle - let mut e3 = e1; - e3.toggle(e2); - assert_eq!(e3, Flags::A | Flags::B); - - let mut m4 = AnotherSetOfFlags::empty(); - m4.toggle(AnotherSetOfFlags::empty()); - assert_eq!(m4, AnotherSetOfFlags::empty()); - } +Generate a flags type using `u8` as the bits type: - #[test] - fn test_operators_unchecked() { - let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; - let e1 = Flags::A | Flags::C | extra; - let e2 = Flags::B | Flags::C; - assert_eq!((e1 | e2), (Flags::ABC | extra)); // union - assert_eq!((e1 & e2), Flags::C); // intersection - assert_eq!((e1 - e2), (Flags::A | extra)); // set difference - assert_eq!(!e2, Flags::A); // set complement - assert_eq!(!e1, Flags::B); // set complement - assert_eq!(e1 ^ e2, Flags::A | Flags::B | extra); // toggle - let mut e3 = e1; - e3.toggle(e2); - assert_eq!(e3, Flags::A | Flags::B | extra); +``` +# use bitflags::bitflags; +bitflags! { + struct Flags: u8 { + const A = 1; + const B = 1 << 1; + const C = 0b0000_0100; } +} +``` - #[test] - fn test_set_ops_basic() { - let ab = Flags::A.union(Flags::B); - let ac = Flags::A.union(Flags::C); - let bc = Flags::B.union(Flags::C); - assert_eq!(ab.bits, 0b011); - assert_eq!(bc.bits, 0b110); - assert_eq!(ac.bits, 0b101); - - assert_eq!(ab, Flags::B.union(Flags::A)); - assert_eq!(ac, Flags::C.union(Flags::A)); - assert_eq!(bc, Flags::C.union(Flags::B)); - - assert_eq!(ac, Flags::A | Flags::C); - assert_eq!(bc, Flags::B | Flags::C); - assert_eq!(ab.union(bc), Flags::ABC); - - assert_eq!(ac, Flags::A | Flags::C); - assert_eq!(bc, Flags::B | Flags::C); - - assert_eq!(ac.union(bc), ac | bc); - assert_eq!(ac.union(bc), Flags::ABC); - assert_eq!(bc.union(ac), Flags::ABC); - - assert_eq!(ac.intersection(bc), ac & bc); - assert_eq!(ac.intersection(bc), Flags::C); - assert_eq!(bc.intersection(ac), Flags::C); - - assert_eq!(ac.difference(bc), ac - bc); - assert_eq!(bc.difference(ac), bc - ac); - assert_eq!(ac.difference(bc), Flags::A); - assert_eq!(bc.difference(ac), Flags::B); - - assert_eq!(bc.complement(), !bc); - assert_eq!(bc.complement(), Flags::A); - assert_eq!(ac.symmetric_difference(bc), Flags::A.union(Flags::B)); - assert_eq!(bc.symmetric_difference(ac), Flags::A.union(Flags::B)); - } +Flags types are private by default and accept standard visibility modifiers. Flags themselves +are always public: - #[test] - fn test_set_ops_const() { - // These just test that these compile and don't cause use-site panics - // (would be possible if we had some sort of UB) - const INTERSECT: Flags = Flags::all().intersection(Flags::C); - const UNION: Flags = Flags::A.union(Flags::C); - const DIFFERENCE: Flags = Flags::all().difference(Flags::A); - const COMPLEMENT: Flags = Flags::C.complement(); - const SYM_DIFFERENCE: Flags = UNION.symmetric_difference(DIFFERENCE); - assert_eq!(INTERSECT, Flags::C); - assert_eq!(UNION, Flags::A | Flags::C); - assert_eq!(DIFFERENCE, Flags::all() - Flags::A); - assert_eq!(COMPLEMENT, !Flags::C); - assert_eq!(SYM_DIFFERENCE, (Flags::A | Flags::C) ^ (Flags::all() - Flags::A)); +``` +# use bitflags::bitflags; +bitflags! { + pub struct Flags: u8 { + // Constants are always `pub` + const A = 1; } +} +``` - #[test] - fn test_set_ops_unchecked() { - let extra = unsafe { Flags::from_bits_unchecked(0b1000) }; - let e1 = Flags::A.union(Flags::C).union(extra); - let e2 = Flags::B.union(Flags::C); - assert_eq!(e1.bits, 0b1101); - assert_eq!(e1.union(e2), (Flags::ABC | extra)); - assert_eq!(e1.intersection(e2), Flags::C); - assert_eq!(e1.difference(e2), Flags::A | extra); - assert_eq!(e2.difference(e1), Flags::B); - assert_eq!(e2.complement(), Flags::A); - assert_eq!(e1.complement(), Flags::B); - assert_eq!(e1.symmetric_difference(e2), Flags::A | Flags::B | extra); // toggle - } +Flags may refer to other flags using their [`Flags::bits`] value: - #[test] - fn test_set_ops_exhaustive() { - // Define a flag that contains gaps to help exercise edge-cases, - // especially around "unknown" flags (e.g. ones outside of `all()` - // `from_bits_unchecked`). - // - when lhs and rhs both have different sets of unknown flags. - // - unknown flags at both ends, and in the middle - // - cases with "gaps". - bitflags! { - struct Test: u16 { - // Intentionally no `A` - const B = 0b000000010; - // Intentionally no `C` - const D = 0b000001000; - const E = 0b000010000; - const F = 0b000100000; - const G = 0b001000000; - // Intentionally no `H` - const I = 0b100000000; - } - } - let iter_test_flags = - || (0..=0b111_1111_1111).map(|bits| unsafe { Test::from_bits_unchecked(bits) }); - - for a in iter_test_flags() { - assert_eq!( - a.complement(), - Test::from_bits_truncate(!a.bits), - "wrong result: !({:?})", - a, - ); - assert_eq!(a.complement(), !a, "named != op: !({:?})", a); - for b in iter_test_flags() { - // Check that the named operations produce the expected bitwise - // values. - assert_eq!( - a.union(b).bits, - a.bits | b.bits, - "wrong result: `{:?}` | `{:?}`", - a, - b, - ); - assert_eq!( - a.intersection(b).bits, - a.bits & b.bits, - "wrong result: `{:?}` & `{:?}`", - a, - b, - ); - assert_eq!( - a.symmetric_difference(b).bits, - a.bits ^ b.bits, - "wrong result: `{:?}` ^ `{:?}`", - a, - b, - ); - assert_eq!( - a.difference(b).bits, - a.bits & !b.bits, - "wrong result: `{:?}` - `{:?}`", - a, - b, - ); - // Note: Difference is checked as both `a - b` and `b - a` - assert_eq!( - b.difference(a).bits, - b.bits & !a.bits, - "wrong result: `{:?}` - `{:?}`", - b, - a, - ); - // Check that the named set operations are equivalent to the - // bitwise equivalents - assert_eq!(a.union(b), a | b, "named != op: `{:?}` | `{:?}`", a, b,); - assert_eq!( - a.intersection(b), - a & b, - "named != op: `{:?}` & `{:?}`", - a, - b, - ); - assert_eq!( - a.symmetric_difference(b), - a ^ b, - "named != op: `{:?}` ^ `{:?}`", - a, - b, - ); - assert_eq!(a.difference(b), a - b, "named != op: `{:?}` - `{:?}`", a, b,); - // Note: Difference is checked as both `a - b` and `b - a` - assert_eq!(b.difference(a), b - a, "named != op: `{:?}` - `{:?}`", b, a,); - // Verify that the operations which should be symmetric are - // actually symmetric. - assert_eq!(a.union(b), b.union(a), "asymmetry: `{:?}` | `{:?}`", a, b,); - assert_eq!( - a.intersection(b), - b.intersection(a), - "asymmetry: `{:?}` & `{:?}`", - a, - b, - ); - assert_eq!( - a.symmetric_difference(b), - b.symmetric_difference(a), - "asymmetry: `{:?}` ^ `{:?}`", - a, - b, - ); - } - } +``` +# use bitflags::bitflags; +bitflags! { + struct Flags: u8 { + const A = 1; + const B = 1 << 1; + const AB = Flags::A.bits() | Flags::B.bits(); } +} +``` + +A single `bitflags` invocation may include zero or more flags type declarations: - #[test] - fn test_set() { - let mut e1 = Flags::A | Flags::C; - e1.set(Flags::B, true); - e1.set(Flags::C, false); +``` +# use bitflags::bitflags; +bitflags! {} - assert_eq!(e1, Flags::A | Flags::B); +bitflags! { + struct Flags1: u8 { + const A = 1; } - #[test] - fn test_assignment_operators() { - let mut m1 = Flags::empty(); - let e1 = Flags::A | Flags::C; - // union - m1 |= Flags::A; - assert_eq!(m1, Flags::A); - // intersection - m1 &= e1; - assert_eq!(m1, Flags::A); - // set difference - m1 -= m1; - assert_eq!(m1, Flags::empty()); - // toggle - m1 ^= e1; - assert_eq!(m1, e1); + struct Flags2: u8 { + const A = 1; } +} +``` - #[test] - fn test_const_fn() { - const _M1: Flags = Flags::empty(); +# `impl` mode - const M2: Flags = Flags::A; - assert_eq!(M2, Flags::A); +A declaration that begins with `impl` will only generate methods and trait implementations for the +`struct` defined outside of the `bitflags` macro. - const M3: Flags = Flags::C; - assert_eq!(M3, Flags::C); - } +The struct itself must be a newtype using the bits type as its field. - #[test] - fn test_extend() { - let mut flags; +The syntax for `impl` mode is identical to `struct` mode besides the starting token. - flags = Flags::empty(); - flags.extend([].iter().cloned()); - assert_eq!(flags, Flags::empty()); +## Examples - flags = Flags::empty(); - flags.extend([Flags::A, Flags::B].iter().cloned()); - assert_eq!(flags, Flags::A | Flags::B); +Implement flags methods and traits for a custom flags type using `u8` as its underlying bits type: - flags = Flags::A; - flags.extend([Flags::A, Flags::B].iter().cloned()); - assert_eq!(flags, Flags::A | Flags::B); +``` +# use bitflags::bitflags; +struct Flags(u8); - flags = Flags::B; - flags.extend([Flags::A, Flags::ABC].iter().cloned()); - assert_eq!(flags, Flags::ABC); +bitflags! { + impl Flags: u8 { + const A = 1; + const B = 1 << 1; + const C = 0b0000_0100; } +} +``` - #[test] - fn test_from_iterator() { - assert_eq!([].iter().cloned().collect::(), Flags::empty()); - assert_eq!( - [Flags::A, Flags::B].iter().cloned().collect::(), - Flags::A | Flags::B - ); - assert_eq!( - [Flags::A, Flags::ABC].iter().cloned().collect::(), - Flags::ABC - ); - } +# Named and unnamed flags - #[test] - fn test_lt() { - let mut a = Flags::empty(); - let mut b = Flags::empty(); - - assert!(!(a < b) && !(b < a)); - b = Flags::B; - assert!(a < b); - a = Flags::C; - assert!(!(a < b) && b < a); - b = Flags::C | Flags::B; - assert!(a < b); - } +Constants in the body of a declaration are flags. The identifier of the constant is the name of +the flag. If the identifier is `_`, then the flag is unnamed. Unnamed flags don't appear in the +generated API, but affect how bits are truncated. - #[test] - fn test_ord() { - let mut a = Flags::empty(); - let mut b = Flags::empty(); - - assert!(a <= b && a >= b); - a = Flags::A; - assert!(a > b && a >= b); - assert!(b < a && b <= a); - b = Flags::B; - assert!(b > a && b >= a); - assert!(a < b && a <= b); - } +## Examples - fn hash(t: &T) -> u64 { - let mut s = DefaultHasher::new(); - t.hash(&mut s); - s.finish() - } +Adding an unnamed flag that makes all bits known: - #[test] - fn test_hash() { - let mut x = Flags::empty(); - let mut y = Flags::empty(); - assert_eq!(hash(&x), hash(&y)); - x = Flags::all(); - y = Flags::ABC; - assert_eq!(hash(&x), hash(&y)); - } +``` +# use bitflags::bitflags; +bitflags! { + struct Flags: u8 { + const A = 1; + const B = 1 << 1; - #[test] - fn test_default() { - assert_eq!(Flags::empty(), Flags::default()); + const _ = !0; } +} +``` - #[test] - fn test_debug() { - assert_eq!(format!("{:?}", Flags::A | Flags::B), "A | B"); - assert_eq!(format!("{:?}", Flags::empty()), "(empty)"); - assert_eq!(format!("{:?}", Flags::ABC), "A | B | C | ABC"); - let extra = unsafe { Flags::from_bits_unchecked(0xb8) }; - assert_eq!(format!("{:?}", extra), "0xb8"); - assert_eq!(format!("{:?}", Flags::A | extra), "A | 0xb8"); - - assert_eq!( - format!("{:?}", Flags::ABC | extra), - "A | B | C | ABC | 0xb8" - ); - - assert_eq!(format!("{:?}", EmptyFlags::empty()), "(empty)"); - } +Flags types may define multiple unnamed flags: - #[test] - fn test_binary() { - assert_eq!(format!("{:b}", Flags::ABC), "111"); - assert_eq!(format!("{:#b}", Flags::ABC), "0b111"); - let extra = unsafe { Flags::from_bits_unchecked(0b1010000) }; - assert_eq!(format!("{:b}", Flags::ABC | extra), "1010111"); - assert_eq!(format!("{:#b}", Flags::ABC | extra), "0b1010111"); +``` +# use bitflags::bitflags; +bitflags! { + struct Flags: u8 { + const _ = 1; + const _ = 1 << 1; } +} +``` +*/ +#[macro_export] +macro_rules! bitflags { + ( + $(#[$outer:meta])* + $vis:vis struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt = $value:expr; + )* + } - #[test] - fn test_octal() { - assert_eq!(format!("{:o}", LongFlags::LONG_A), "177777"); - assert_eq!(format!("{:#o}", LongFlags::LONG_A), "0o177777"); - let extra = unsafe { LongFlags::from_bits_unchecked(0o5000000) }; - assert_eq!(format!("{:o}", LongFlags::LONG_A | extra), "5177777"); - assert_eq!(format!("{:#o}", LongFlags::LONG_A | extra), "0o5177777"); - } + $($t:tt)* + ) => { + // Declared in the scope of the `bitflags!` call + // This type appears in the end-user's API + $crate::__declare_public_bitflags! { + $(#[$outer])* + $vis struct $BitFlags + } - #[test] - fn test_lowerhex() { - assert_eq!(format!("{:x}", LongFlags::LONG_A), "ffff"); - assert_eq!(format!("{:#x}", LongFlags::LONG_A), "0xffff"); - let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) }; - assert_eq!(format!("{:x}", LongFlags::LONG_A | extra), "e0ffff"); - assert_eq!(format!("{:#x}", LongFlags::LONG_A | extra), "0xe0ffff"); - } + // Workaround for: https://github.com/bitflags/bitflags/issues/320 + $crate::__impl_public_bitflags_consts! { + $BitFlags: $T { + $( + $(#[$inner $($args)*])* + const $Flag = $value; + )* + } + } - #[test] - fn test_upperhex() { - assert_eq!(format!("{:X}", LongFlags::LONG_A), "FFFF"); - assert_eq!(format!("{:#X}", LongFlags::LONG_A), "0xFFFF"); - let extra = unsafe { LongFlags::from_bits_unchecked(0xe00000) }; - assert_eq!(format!("{:X}", LongFlags::LONG_A | extra), "E0FFFF"); - assert_eq!(format!("{:#X}", LongFlags::LONG_A | extra), "0xE0FFFF"); - } + #[allow( + dead_code, + deprecated, + unused_doc_comments, + unused_attributes, + unused_mut, + unused_imports, + non_upper_case_globals, + clippy::assign_op_pattern, + clippy::indexing_slicing, + clippy::same_name_method, + clippy::iter_without_into_iter, + )] + const _: () = { + // Declared in a "hidden" scope that can't be reached directly + // These types don't appear in the end-user's API + $crate::__declare_internal_bitflags! { + $vis struct InternalBitFlags: $T + } + + $crate::__impl_internal_bitflags! { + InternalBitFlags: $T, $BitFlags { + $( + $(#[$inner $($args)*])* + const $Flag = $value; + )* + } + } - mod submodule { - bitflags! { - pub struct PublicFlags: i8 { - const X = 0; + // This is where new library trait implementations can be added + $crate::__impl_external_bitflags! { + InternalBitFlags: $T, $BitFlags { + $( + $(#[$inner $($args)*])* + const $Flag; + )* + } } - struct PrivateFlags: i8 { - const Y = 0; + $crate::__impl_public_bitflags_forward! { + $BitFlags: $T, InternalBitFlags } - } - #[test] - fn test_private() { - let _ = PrivateFlags::Y; - } - } + $crate::__impl_public_bitflags_ops! { + $BitFlags + } - #[test] - fn test_public() { - let _ = submodule::PublicFlags::X; - } + $crate::__impl_public_bitflags_iter! { + $BitFlags: $T, $BitFlags + } + }; - mod t1 { - mod foo { - pub type Bar = i32; + $crate::bitflags! { + $($t)* + } + }; + ( + $(#[$outer:meta])* + impl $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt = $value:expr; + )* } - bitflags! { - /// baz - struct Flags: foo::Bar { - const A = 0b00000001; - #[cfg(foo)] - const B = 0b00000010; - #[cfg(foo)] - const C = 0b00000010; + $($t:tt)* + ) => { + $crate::__impl_public_bitflags_consts! { + $BitFlags: $T { + $( + $(#[$inner $($args)*])* + const $Flag = $value; + )* } } - } - #[test] - fn test_in_function() { - bitflags! { - struct Flags: u8 { - const A = 1; - #[cfg(any())] // false - const B = 2; + #[allow( + dead_code, + deprecated, + unused_doc_comments, + unused_attributes, + unused_mut, + unused_imports, + non_upper_case_globals, + clippy::assign_op_pattern, + clippy::iter_without_into_iter, + )] + const _: () = { + $crate::__impl_public_bitflags! { + $(#[$outer])* + $BitFlags: $T, $BitFlags { + $( + $(#[$inner $($args)*])* + const $Flag = $value; + )* + } } - } - assert_eq!(Flags::all(), Flags::A); - assert_eq!(format!("{:?}", Flags::A), "A"); - } - #[test] - fn test_deprecated() { - bitflags! { - pub struct TestFlags: u32 { - #[deprecated(note = "Use something else.")] - const ONE = 1; + $crate::__impl_public_bitflags_ops! { + $BitFlags } - } - } - #[test] - fn test_pub_crate() { - mod module { - bitflags! { - pub (crate) struct Test: u8 { - const FOO = 1; - } + $crate::__impl_public_bitflags_iter! { + $BitFlags: $T, $BitFlags } + }; + + $crate::bitflags! { + $($t)* } + }; + () => {}; +} - assert_eq!(module::Test::FOO.bits(), 1); - } +/// Implement functions on bitflags types. +/// +/// We need to be careful about adding new methods and trait implementations here because they +/// could conflict with items added by the end-user. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_bitflags { + ( + $(#[$outer:meta])* + $PublicBitFlags:ident: $T:ty { + fn empty() $empty:block + fn all() $all:block + fn bits($bits0:ident) $bits:block + fn from_bits($from_bits0:ident) $from_bits:block + fn from_bits_truncate($from_bits_truncate0:ident) $from_bits_truncate:block + fn from_bits_retain($from_bits_retain0:ident) $from_bits_retain:block + fn from_name($from_name0:ident) $from_name:block + fn is_empty($is_empty0:ident) $is_empty:block + fn is_all($is_all0:ident) $is_all:block + fn intersects($intersects0:ident, $intersects1:ident) $intersects:block + fn contains($contains0:ident, $contains1:ident) $contains:block + fn insert($insert0:ident, $insert1:ident) $insert:block + fn remove($remove0:ident, $remove1:ident) $remove:block + fn toggle($toggle0:ident, $toggle1:ident) $toggle:block + fn set($set0:ident, $set1:ident, $set2:ident) $set:block + fn intersection($intersection0:ident, $intersection1:ident) $intersection:block + fn union($union0:ident, $union1:ident) $union:block + fn difference($difference0:ident, $difference1:ident) $difference:block + fn symmetric_difference($symmetric_difference0:ident, $symmetric_difference1:ident) $symmetric_difference:block + fn complement($complement0:ident) $complement:block + } + ) => { + #[allow(dead_code, deprecated, unused_attributes)] + $(#[$outer])* + impl $PublicBitFlags { + /// Get a flags value with all bits unset. + #[inline] + pub const fn empty() -> Self { + $empty + } - #[test] - fn test_pub_in_module() { - mod module { - mod submodule { - bitflags! { - // `pub (in super)` means only the module `module` will - // be able to access this. - pub (in super) struct Test: u8 { - const FOO = 1; - } - } + /// Get a flags value with all known bits set. + #[inline] + pub const fn all() -> Self { + $all } - mod test { - // Note: due to `pub (in super)`, - // this cannot be accessed directly by the testing code. - pub(super) fn value() -> u8 { - super::submodule::Test::FOO.bits() - } + /// Get the underlying bits value. + /// + /// The returned value is exactly the bits set in this flags value. + #[inline] + pub const fn bits(&self) -> $T { + let $bits0 = self; + $bits } - pub fn value() -> u8 { - test::value() + /// Convert from a bits value. + /// + /// This method will return `None` if any unknown bits are set. + #[inline] + pub const fn from_bits(bits: $T) -> $crate::__private::core::option::Option { + let $from_bits0 = bits; + $from_bits } - } - assert_eq!(module::value(), 1) - } + /// Convert from a bits value, unsetting any unknown bits. + #[inline] + pub const fn from_bits_truncate(bits: $T) -> Self { + let $from_bits_truncate0 = bits; + $from_bits_truncate + } - #[test] - fn test_zero_value_flags() { - bitflags! { - struct Flags: u32 { - const NONE = 0b0; - const SOME = 0b1; + /// Convert from a bits value exactly. + #[inline] + pub const fn from_bits_retain(bits: $T) -> Self { + let $from_bits_retain0 = bits; + $from_bits_retain } - } - assert!(Flags::empty().contains(Flags::NONE)); - assert!(Flags::SOME.contains(Flags::NONE)); - assert!(Flags::NONE.is_empty()); + /// Get a flags value with the bits of a flag with the given name set. + /// + /// This method will return `None` if `name` is empty or doesn't + /// correspond to any named flag. + #[inline] + pub fn from_name(name: &str) -> $crate::__private::core::option::Option { + let $from_name0 = name; + $from_name + } - assert_eq!(format!("{:?}", Flags::empty()), "NONE"); - assert_eq!(format!("{:?}", Flags::SOME), "SOME"); - } + /// Whether all bits in this flags value are unset. + #[inline] + pub const fn is_empty(&self) -> bool { + let $is_empty0 = self; + $is_empty + } - #[test] - fn test_empty_bitflags() { - bitflags! {} - } + /// Whether all known bits in this flags value are set. + #[inline] + pub const fn is_all(&self) -> bool { + let $is_all0 = self; + $is_all + } - #[test] - fn test_u128_bitflags() { - bitflags! { - struct Flags128: u128 { - const A = 0x0000_0000_0000_0000_0000_0000_0000_0001; - const B = 0x0000_0000_0000_1000_0000_0000_0000_0000; - const C = 0x8000_0000_0000_0000_0000_0000_0000_0000; - const ABC = Self::A.bits | Self::B.bits | Self::C.bits; + /// Whether any set bits in a source flags value are also set in a target flags value. + #[inline] + pub const fn intersects(&self, other: Self) -> bool { + let $intersects0 = self; + let $intersects1 = other; + $intersects } - } - assert_eq!(Flags128::ABC, Flags128::A | Flags128::B | Flags128::C); - assert_eq!(Flags128::A.bits, 0x0000_0000_0000_0000_0000_0000_0000_0001); - assert_eq!(Flags128::B.bits, 0x0000_0000_0000_1000_0000_0000_0000_0000); - assert_eq!(Flags128::C.bits, 0x8000_0000_0000_0000_0000_0000_0000_0000); - assert_eq!( - Flags128::ABC.bits, - 0x8000_0000_0000_1000_0000_0000_0000_0001 - ); - assert_eq!(format!("{:?}", Flags128::A), "A"); - assert_eq!(format!("{:?}", Flags128::B), "B"); - assert_eq!(format!("{:?}", Flags128::C), "C"); - assert_eq!(format!("{:?}", Flags128::ABC), "A | B | C | ABC"); - } + /// Whether all set bits in a source flags value are also set in a target flags value. + #[inline] + pub const fn contains(&self, other: Self) -> bool { + let $contains0 = self; + let $contains1 = other; + $contains + } - #[test] - fn test_serde_bitflags_serialize() { - let flags = SerdeFlags::A | SerdeFlags::B; + /// The bitwise or (`|`) of the bits in two flags values. + #[inline] + pub fn insert(&mut self, other: Self) { + let $insert0 = self; + let $insert1 = other; + $insert + } - let serialized = serde_json::to_string(&flags).unwrap(); + /// The intersection of a source flags value with the complement of a target flags value (`&!`). + /// + /// This method is not equivalent to `self & !other` when `other` has unknown bits set. + /// `remove` won't truncate `other`, but the `!` operator will. + #[inline] + pub fn remove(&mut self, other: Self) { + let $remove0 = self; + let $remove1 = other; + $remove + } - assert_eq!(serialized, r#"{"bits":3}"#); - } + /// The bitwise exclusive-or (`^`) of the bits in two flags values. + #[inline] + pub fn toggle(&mut self, other: Self) { + let $toggle0 = self; + let $toggle1 = other; + $toggle + } - #[test] - fn test_serde_bitflags_deserialize() { - let deserialized: SerdeFlags = serde_json::from_str(r#"{"bits":12}"#).unwrap(); + /// Call `insert` when `value` is `true` or `remove` when `value` is `false`. + #[inline] + pub fn set(&mut self, other: Self, value: bool) { + let $set0 = self; + let $set1 = other; + let $set2 = value; + $set + } - let expected = SerdeFlags::C | SerdeFlags::D; + /// The bitwise and (`&`) of the bits in two flags values. + #[inline] + #[must_use] + pub const fn intersection(self, other: Self) -> Self { + let $intersection0 = self; + let $intersection1 = other; + $intersection + } - assert_eq!(deserialized.bits, expected.bits); - } + /// The bitwise or (`|`) of the bits in two flags values. + #[inline] + #[must_use] + pub const fn union(self, other: Self) -> Self { + let $union0 = self; + let $union1 = other; + $union + } - #[test] - fn test_serde_bitflags_roundtrip() { - let flags = SerdeFlags::A | SerdeFlags::B; + /// The intersection of a source flags value with the complement of a target flags value (`&!`). + /// + /// This method is not equivalent to `self & !other` when `other` has unknown bits set. + /// `difference` won't truncate `other`, but the `!` operator will. + #[inline] + #[must_use] + pub const fn difference(self, other: Self) -> Self { + let $difference0 = self; + let $difference1 = other; + $difference + } - let deserialized: SerdeFlags = serde_json::from_str(&serde_json::to_string(&flags).unwrap()).unwrap(); + /// The bitwise exclusive-or (`^`) of the bits in two flags values. + #[inline] + #[must_use] + pub const fn symmetric_difference(self, other: Self) -> Self { + let $symmetric_difference0 = self; + let $symmetric_difference1 = other; + $symmetric_difference + } - assert_eq!(deserialized.bits, flags.bits); - } + /// The bitwise negation (`!`) of the bits in a flags value, truncating the result. + #[inline] + #[must_use] + pub const fn complement(self) -> Self { + let $complement0 = self; + $complement + } + } + }; +} - bitflags! { - #[derive(serde::Serialize, serde::Deserialize)] - struct SerdeFlags: u32 { - const A = 1; - const B = 2; - const C = 4; - const D = 8; +/// A macro that processed the input to `bitflags!` and shuffles attributes around +/// based on whether or not they're "expression-safe". +/// +/// This macro is a token-tree muncher that works on 2 levels: +/// +/// For each attribute, we explicitly match on its identifier, like `cfg` to determine +/// whether or not it should be considered expression-safe. +/// +/// If you find yourself with an attribute that should be considered expression-safe +/// and isn't, it can be added here. +#[macro_export] +#[doc(hidden)] +macro_rules! __bitflags_expr_safe_attrs { + // Entrypoint: Move all flags and all attributes into `unprocessed` lists + // where they'll be munched one-at-a-time + ( + $(#[$inner:ident $($args:tt)*])* + { $e:expr } + ) => { + $crate::__bitflags_expr_safe_attrs! { + expr: { $e }, + attrs: { + // All attributes start here + unprocessed: [$(#[$inner $($args)*])*], + // Attributes that are safe on expressions go here + processed: [], + }, } + }; + // Process the next attribute on the current flag + // `cfg`: The next flag should be propagated to expressions + // NOTE: You can copy this rules block and replace `cfg` with + // your attribute name that should be considered expression-safe + ( + expr: { $e:expr }, + attrs: { + unprocessed: [ + // cfg matched here + #[cfg $($args:tt)*] + $($attrs_rest:tt)* + ], + processed: [$($expr:tt)*], + }, + ) => { + $crate::__bitflags_expr_safe_attrs! { + expr: { $e }, + attrs: { + unprocessed: [ + $($attrs_rest)* + ], + processed: [ + $($expr)* + // cfg added here + #[cfg $($args)*] + ], + }, + } + }; + // Process the next attribute on the current flag + // `$other`: The next flag should not be propagated to expressions + ( + expr: { $e:expr }, + attrs: { + unprocessed: [ + // $other matched here + #[$other:ident $($args:tt)*] + $($attrs_rest:tt)* + ], + processed: [$($expr:tt)*], + }, + ) => { + $crate::__bitflags_expr_safe_attrs! { + expr: { $e }, + attrs: { + unprocessed: [ + $($attrs_rest)* + ], + processed: [ + // $other not added here + $($expr)* + ], + }, + } + }; + // Once all attributes on all flags are processed, generate the actual code + ( + expr: { $e:expr }, + attrs: { + unprocessed: [], + processed: [$(#[$expr:ident $($exprargs:tt)*])*], + }, + ) => { + $(#[$expr $($exprargs)*])* + { $e } } } + +/// Implement a flag, which may be a wildcard `_`. +#[macro_export] +#[doc(hidden)] +macro_rules! __bitflags_flag { + ( + { + name: _, + named: { $($named:tt)* }, + unnamed: { $($unnamed:tt)* }, + } + ) => { + $($unnamed)* + }; + ( + { + name: $Flag:ident, + named: { $($named:tt)* }, + unnamed: { $($unnamed:tt)* }, + } + ) => { + $($named)* + }; +} + +#[macro_use] +mod public; +#[macro_use] +mod internal; +#[macro_use] +mod external; + +#[cfg(feature = "example_generated")] +pub mod example_generated; + +#[cfg(test)] +mod tests; diff --git a/vendor/bitflags/src/parser.rs b/vendor/bitflags/src/parser.rs new file mode 100644 index 0000000..34b432d --- /dev/null +++ b/vendor/bitflags/src/parser.rs @@ -0,0 +1,332 @@ +/*! +Parsing flags from text. + +Format and parse a flags value as text using the following grammar: + +- _Flags:_ (_Whitespace_ _Flag_ _Whitespace_)`|`* +- _Flag:_ _Name_ | _Hex Number_ +- _Name:_ The name of any defined flag +- _Hex Number_: `0x`([0-9a-fA-F])* +- _Whitespace_: (\s)* + +As an example, this is how `Flags::A | Flags::B | 0x0c` can be represented as text: + +```text +A | B | 0x0c +``` + +Alternatively, it could be represented without whitespace: + +```text +A|B|0x0C +``` + +Note that identifiers are *case-sensitive*, so the following is *not equivalent*: + +```text +a|b|0x0C +``` +*/ + +#![allow(clippy::let_unit_value)] + +use core::fmt::{self, Write}; + +use crate::{Bits, Flags}; + +/** +Write a flags value as text. + +Any bits that aren't part of a contained flag will be formatted as a hex number. +*/ +pub fn to_writer(flags: &B, mut writer: impl Write) -> Result<(), fmt::Error> +where + B::Bits: WriteHex, +{ + // A formatter for bitflags that produces text output like: + // + // A | B | 0xf6 + // + // The names of set flags are written in a bar-separated-format, + // followed by a hex number of any remaining bits that are set + // but don't correspond to any flags. + + // Iterate over known flag values + let mut first = true; + let mut iter = flags.iter_names(); + for (name, _) in &mut iter { + if !first { + writer.write_str(" | ")?; + } + + first = false; + writer.write_str(name)?; + } + + // Append any extra bits that correspond to flags to the end of the format + let remaining = iter.remaining().bits(); + if remaining != B::Bits::EMPTY { + if !first { + writer.write_str(" | ")?; + } + + writer.write_str("0x")?; + remaining.write_hex(writer)?; + } + + fmt::Result::Ok(()) +} + +#[cfg(feature = "serde")] +pub(crate) struct AsDisplay<'a, B>(pub(crate) &'a B); + +#[cfg(feature = "serde")] +impl<'a, B: Flags> fmt::Display for AsDisplay<'a, B> +where + B::Bits: WriteHex, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + to_writer(self.0, f) + } +} + +/** +Parse a flags value from text. + +This function will fail on any names that don't correspond to defined flags. +Unknown bits will be retained. +*/ +pub fn from_str(input: &str) -> Result +where + B::Bits: ParseHex, +{ + let mut parsed_flags = B::empty(); + + // If the input is empty then return an empty set of flags + if input.trim().is_empty() { + return Ok(parsed_flags); + } + + for flag in input.split('|') { + let flag = flag.trim(); + + // If the flag is empty then we've got missing input + if flag.is_empty() { + return Err(ParseError::empty_flag()); + } + + // If the flag starts with `0x` then it's a hex number + // Parse it directly to the underlying bits type + let parsed_flag = if let Some(flag) = flag.strip_prefix("0x") { + let bits = + ::parse_hex(flag).map_err(|_| ParseError::invalid_hex_flag(flag))?; + + B::from_bits_retain(bits) + } + // Otherwise the flag is a name + // The generated flags type will determine whether + // or not it's a valid identifier + else { + B::from_name(flag).ok_or_else(|| ParseError::invalid_named_flag(flag))? + }; + + parsed_flags.insert(parsed_flag); + } + + Ok(parsed_flags) +} + +/** +Write a flags value as text, ignoring any unknown bits. +*/ +pub fn to_writer_truncate(flags: &B, writer: impl Write) -> Result<(), fmt::Error> +where + B::Bits: WriteHex, +{ + to_writer(&B::from_bits_truncate(flags.bits()), writer) +} + +/** +Parse a flags value from text. + +This function will fail on any names that don't correspond to defined flags. +Unknown bits will be ignored. +*/ +pub fn from_str_truncate(input: &str) -> Result +where + B::Bits: ParseHex, +{ + Ok(B::from_bits_truncate(from_str::(input)?.bits())) +} + +/** +Write only the contained, defined, named flags in a flags value as text. +*/ +pub fn to_writer_strict(flags: &B, mut writer: impl Write) -> Result<(), fmt::Error> { + // This is a simplified version of `to_writer` that ignores + // any bits not corresponding to a named flag + + let mut first = true; + let mut iter = flags.iter_names(); + for (name, _) in &mut iter { + if !first { + writer.write_str(" | ")?; + } + + first = false; + writer.write_str(name)?; + } + + fmt::Result::Ok(()) +} + +/** +Parse a flags value from text. + +This function will fail on any names that don't correspond to defined flags. +This function will fail to parse hex values. +*/ +pub fn from_str_strict(input: &str) -> Result { + // This is a simplified version of `from_str` that ignores + // any bits not corresponding to a named flag + + let mut parsed_flags = B::empty(); + + // If the input is empty then return an empty set of flags + if input.trim().is_empty() { + return Ok(parsed_flags); + } + + for flag in input.split('|') { + let flag = flag.trim(); + + // If the flag is empty then we've got missing input + if flag.is_empty() { + return Err(ParseError::empty_flag()); + } + + // If the flag starts with `0x` then it's a hex number + // These aren't supported in the strict parser + if flag.starts_with("0x") { + return Err(ParseError::invalid_hex_flag("unsupported hex flag value")); + } + + let parsed_flag = B::from_name(flag).ok_or_else(|| ParseError::invalid_named_flag(flag))?; + + parsed_flags.insert(parsed_flag); + } + + Ok(parsed_flags) +} + +/** +Encode a value as a hex string. + +Implementors of this trait should not write the `0x` prefix. +*/ +pub trait WriteHex { + /// Write the value as hex. + fn write_hex(&self, writer: W) -> fmt::Result; +} + +/** +Parse a value from a hex string. +*/ +pub trait ParseHex { + /// Parse the value from hex. + fn parse_hex(input: &str) -> Result + where + Self: Sized; +} + +/// An error encountered while parsing flags from text. +#[derive(Debug)] +pub struct ParseError(ParseErrorKind); + +#[derive(Debug)] +#[allow(clippy::enum_variant_names)] +enum ParseErrorKind { + EmptyFlag, + InvalidNamedFlag { + #[cfg(not(feature = "std"))] + got: (), + #[cfg(feature = "std")] + got: String, + }, + InvalidHexFlag { + #[cfg(not(feature = "std"))] + got: (), + #[cfg(feature = "std")] + got: String, + }, +} + +impl ParseError { + /// An invalid hex flag was encountered. + pub fn invalid_hex_flag(flag: impl fmt::Display) -> Self { + let _flag = flag; + + let got = { + #[cfg(feature = "std")] + { + _flag.to_string() + } + }; + + ParseError(ParseErrorKind::InvalidHexFlag { got }) + } + + /// A named flag that doesn't correspond to any on the flags type was encountered. + pub fn invalid_named_flag(flag: impl fmt::Display) -> Self { + let _flag = flag; + + let got = { + #[cfg(feature = "std")] + { + _flag.to_string() + } + }; + + ParseError(ParseErrorKind::InvalidNamedFlag { got }) + } + + /// A hex or named flag wasn't found between separators. + pub const fn empty_flag() -> Self { + ParseError(ParseErrorKind::EmptyFlag) + } +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match &self.0 { + ParseErrorKind::InvalidNamedFlag { got } => { + let _got = got; + + write!(f, "unrecognized named flag")?; + + #[cfg(feature = "std")] + { + write!(f, " `{}`", _got)?; + } + } + ParseErrorKind::InvalidHexFlag { got } => { + let _got = got; + + write!(f, "invalid hex flag")?; + + #[cfg(feature = "std")] + { + write!(f, " `{}`", _got)?; + } + } + ParseErrorKind::EmptyFlag => { + write!(f, "encountered empty flag")?; + } + } + + Ok(()) + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ParseError {} diff --git a/vendor/bitflags/src/public.rs b/vendor/bitflags/src/public.rs new file mode 100644 index 0000000..feecdd6 --- /dev/null +++ b/vendor/bitflags/src/public.rs @@ -0,0 +1,578 @@ +//! Generate the user-facing flags type. +//! +//! The code here belongs to the end-user, so new trait implementations and methods can't be +//! added without potentially breaking users. + +/// Declare the user-facing bitflags struct. +/// +/// This type is guaranteed to be a newtype with a `bitflags`-facing type as its single field. +#[macro_export] +#[doc(hidden)] +macro_rules! __declare_public_bitflags { + ( + $(#[$outer:meta])* + $vis:vis struct $PublicBitFlags:ident + ) => { + $(#[$outer])* + $vis struct $PublicBitFlags(<$PublicBitFlags as $crate::__private::PublicFlags>::Internal); + }; +} + +/// Implement functions on the public (user-facing) bitflags type. +/// +/// We need to be careful about adding new methods and trait implementations here because they +/// could conflict with items added by the end-user. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_public_bitflags_forward { + ( + $(#[$outer:meta])* + $PublicBitFlags:ident: $T:ty, $InternalBitFlags:ident + ) => { + $crate::__impl_bitflags! { + $(#[$outer])* + $PublicBitFlags: $T { + fn empty() { + Self($InternalBitFlags::empty()) + } + + fn all() { + Self($InternalBitFlags::all()) + } + + fn bits(f) { + f.0.bits() + } + + fn from_bits(bits) { + match $InternalBitFlags::from_bits(bits) { + $crate::__private::core::option::Option::Some(bits) => $crate::__private::core::option::Option::Some(Self(bits)), + $crate::__private::core::option::Option::None => $crate::__private::core::option::Option::None, + } + } + + fn from_bits_truncate(bits) { + Self($InternalBitFlags::from_bits_truncate(bits)) + } + + fn from_bits_retain(bits) { + Self($InternalBitFlags::from_bits_retain(bits)) + } + + fn from_name(name) { + match $InternalBitFlags::from_name(name) { + $crate::__private::core::option::Option::Some(bits) => $crate::__private::core::option::Option::Some(Self(bits)), + $crate::__private::core::option::Option::None => $crate::__private::core::option::Option::None, + } + } + + fn is_empty(f) { + f.0.is_empty() + } + + fn is_all(f) { + f.0.is_all() + } + + fn intersects(f, other) { + f.0.intersects(other.0) + } + + fn contains(f, other) { + f.0.contains(other.0) + } + + fn insert(f, other) { + f.0.insert(other.0) + } + + fn remove(f, other) { + f.0.remove(other.0) + } + + fn toggle(f, other) { + f.0.toggle(other.0) + } + + fn set(f, other, value) { + f.0.set(other.0, value) + } + + fn intersection(f, other) { + Self(f.0.intersection(other.0)) + } + + fn union(f, other) { + Self(f.0.union(other.0)) + } + + fn difference(f, other) { + Self(f.0.difference(other.0)) + } + + fn symmetric_difference(f, other) { + Self(f.0.symmetric_difference(other.0)) + } + + fn complement(f) { + Self(f.0.complement()) + } + } + } + }; +} + +/// Implement functions on the public (user-facing) bitflags type. +/// +/// We need to be careful about adding new methods and trait implementations here because they +/// could conflict with items added by the end-user. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_public_bitflags { + ( + $(#[$outer:meta])* + $BitFlags:ident: $T:ty, $PublicBitFlags:ident { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt = $value:expr; + )* + } + ) => { + $crate::__impl_bitflags! { + $(#[$outer])* + $BitFlags: $T { + fn empty() { + Self(<$T as $crate::Bits>::EMPTY) + } + + fn all() { + let mut truncated = <$T as $crate::Bits>::EMPTY; + let mut i = 0; + + $( + $crate::__bitflags_expr_safe_attrs!( + $(#[$inner $($args)*])* + {{ + let flag = <$PublicBitFlags as $crate::Flags>::FLAGS[i].value().bits(); + + truncated = truncated | flag; + i += 1; + }} + ); + )* + + let _ = i; + Self::from_bits_retain(truncated) + } + + fn bits(f) { + f.0 + } + + fn from_bits(bits) { + let truncated = Self::from_bits_truncate(bits).0; + + if truncated == bits { + $crate::__private::core::option::Option::Some(Self(bits)) + } else { + $crate::__private::core::option::Option::None + } + } + + fn from_bits_truncate(bits) { + Self(bits & Self::all().bits()) + } + + fn from_bits_retain(bits) { + Self(bits) + } + + fn from_name(name) { + $( + $crate::__bitflags_flag!({ + name: $Flag, + named: { + $crate::__bitflags_expr_safe_attrs!( + $(#[$inner $($args)*])* + { + if name == $crate::__private::core::stringify!($Flag) { + return $crate::__private::core::option::Option::Some(Self($PublicBitFlags::$Flag.bits())); + } + } + ); + }, + unnamed: {}, + }); + )* + + let _ = name; + $crate::__private::core::option::Option::None + } + + fn is_empty(f) { + f.bits() == <$T as $crate::Bits>::EMPTY + } + + fn is_all(f) { + // NOTE: We check against `Self::all` here, not `Self::Bits::ALL` + // because the set of all flags may not use all bits + Self::all().bits() | f.bits() == f.bits() + } + + fn intersects(f, other) { + f.bits() & other.bits() != <$T as $crate::Bits>::EMPTY + } + + fn contains(f, other) { + f.bits() & other.bits() == other.bits() + } + + fn insert(f, other) { + *f = Self::from_bits_retain(f.bits()).union(other); + } + + fn remove(f, other) { + *f = Self::from_bits_retain(f.bits()).difference(other); + } + + fn toggle(f, other) { + *f = Self::from_bits_retain(f.bits()).symmetric_difference(other); + } + + fn set(f, other, value) { + if value { + f.insert(other); + } else { + f.remove(other); + } + } + + fn intersection(f, other) { + Self::from_bits_retain(f.bits() & other.bits()) + } + + fn union(f, other) { + Self::from_bits_retain(f.bits() | other.bits()) + } + + fn difference(f, other) { + Self::from_bits_retain(f.bits() & !other.bits()) + } + + fn symmetric_difference(f, other) { + Self::from_bits_retain(f.bits() ^ other.bits()) + } + + fn complement(f) { + Self::from_bits_truncate(!f.bits()) + } + } + } + }; +} + +/// Implement iterators on the public (user-facing) bitflags type. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_public_bitflags_iter { + ( + $(#[$outer:meta])* + $BitFlags:ident: $T:ty, $PublicBitFlags:ident + ) => { + $(#[$outer])* + impl $BitFlags { + /// Yield a set of contained flags values. + /// + /// Each yielded flags value will correspond to a defined named flag. Any unknown bits + /// will be yielded together as a final flags value. + #[inline] + pub const fn iter(&self) -> $crate::iter::Iter<$PublicBitFlags> { + $crate::iter::Iter::__private_const_new( + <$PublicBitFlags as $crate::Flags>::FLAGS, + $PublicBitFlags::from_bits_retain(self.bits()), + $PublicBitFlags::from_bits_retain(self.bits()), + ) + } + + /// Yield a set of contained named flags values. + /// + /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags. + /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded. + #[inline] + pub const fn iter_names(&self) -> $crate::iter::IterNames<$PublicBitFlags> { + $crate::iter::IterNames::__private_const_new( + <$PublicBitFlags as $crate::Flags>::FLAGS, + $PublicBitFlags::from_bits_retain(self.bits()), + $PublicBitFlags::from_bits_retain(self.bits()), + ) + } + } + + $(#[$outer:meta])* + impl $crate::__private::core::iter::IntoIterator for $BitFlags { + type Item = $PublicBitFlags; + type IntoIter = $crate::iter::Iter<$PublicBitFlags>; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } + } + }; +} + +/// Implement traits on the public (user-facing) bitflags type. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_public_bitflags_ops { + ( + $(#[$outer:meta])* + $PublicBitFlags:ident + ) => { + + $(#[$outer])* + impl $crate::__private::core::fmt::Binary for $PublicBitFlags { + fn fmt( + &self, + f: &mut $crate::__private::core::fmt::Formatter, + ) -> $crate::__private::core::fmt::Result { + let inner = self.0; + $crate::__private::core::fmt::Binary::fmt(&inner, f) + } + } + + $(#[$outer])* + impl $crate::__private::core::fmt::Octal for $PublicBitFlags { + fn fmt( + &self, + f: &mut $crate::__private::core::fmt::Formatter, + ) -> $crate::__private::core::fmt::Result { + let inner = self.0; + $crate::__private::core::fmt::Octal::fmt(&inner, f) + } + } + + $(#[$outer])* + impl $crate::__private::core::fmt::LowerHex for $PublicBitFlags { + fn fmt( + &self, + f: &mut $crate::__private::core::fmt::Formatter, + ) -> $crate::__private::core::fmt::Result { + let inner = self.0; + $crate::__private::core::fmt::LowerHex::fmt(&inner, f) + } + } + + $(#[$outer])* + impl $crate::__private::core::fmt::UpperHex for $PublicBitFlags { + fn fmt( + &self, + f: &mut $crate::__private::core::fmt::Formatter, + ) -> $crate::__private::core::fmt::Result { + let inner = self.0; + $crate::__private::core::fmt::UpperHex::fmt(&inner, f) + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::BitOr for $PublicBitFlags { + type Output = Self; + + /// The bitwise or (`|`) of the bits in two flags values. + #[inline] + fn bitor(self, other: $PublicBitFlags) -> Self { + self.union(other) + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::BitOrAssign for $PublicBitFlags { + /// The bitwise or (`|`) of the bits in two flags values. + #[inline] + fn bitor_assign(&mut self, other: Self) { + self.insert(other); + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::BitXor for $PublicBitFlags { + type Output = Self; + + /// The bitwise exclusive-or (`^`) of the bits in two flags values. + #[inline] + fn bitxor(self, other: Self) -> Self { + self.symmetric_difference(other) + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::BitXorAssign for $PublicBitFlags { + /// The bitwise exclusive-or (`^`) of the bits in two flags values. + #[inline] + fn bitxor_assign(&mut self, other: Self) { + self.toggle(other); + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::BitAnd for $PublicBitFlags { + type Output = Self; + + /// The bitwise and (`&`) of the bits in two flags values. + #[inline] + fn bitand(self, other: Self) -> Self { + self.intersection(other) + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::BitAndAssign for $PublicBitFlags { + /// The bitwise and (`&`) of the bits in two flags values. + #[inline] + fn bitand_assign(&mut self, other: Self) { + *self = Self::from_bits_retain(self.bits()).intersection(other); + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::Sub for $PublicBitFlags { + type Output = Self; + + /// The intersection of a source flags value with the complement of a target flags value (`&!`). + /// + /// This method is not equivalent to `self & !other` when `other` has unknown bits set. + /// `difference` won't truncate `other`, but the `!` operator will. + #[inline] + fn sub(self, other: Self) -> Self { + self.difference(other) + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::SubAssign for $PublicBitFlags { + /// The intersection of a source flags value with the complement of a target flags value (`&!`). + /// + /// This method is not equivalent to `self & !other` when `other` has unknown bits set. + /// `difference` won't truncate `other`, but the `!` operator will. + #[inline] + fn sub_assign(&mut self, other: Self) { + self.remove(other); + } + } + + $(#[$outer])* + impl $crate::__private::core::ops::Not for $PublicBitFlags { + type Output = Self; + + /// The bitwise negation (`!`) of the bits in a flags value, truncating the result. + #[inline] + fn not(self) -> Self { + self.complement() + } + } + + $(#[$outer])* + impl $crate::__private::core::iter::Extend<$PublicBitFlags> for $PublicBitFlags { + /// The bitwise or (`|`) of the bits in each flags value. + fn extend>( + &mut self, + iterator: T, + ) { + for item in iterator { + self.insert(item) + } + } + } + + $(#[$outer])* + impl $crate::__private::core::iter::FromIterator<$PublicBitFlags> for $PublicBitFlags { + /// The bitwise or (`|`) of the bits in each flags value. + fn from_iter>( + iterator: T, + ) -> Self { + use $crate::__private::core::iter::Extend; + + let mut result = Self::empty(); + result.extend(iterator); + result + } + } + }; +} + +/// Implement constants on the public (user-facing) bitflags type. +#[macro_export] +#[doc(hidden)] +macro_rules! __impl_public_bitflags_consts { + ( + $(#[$outer:meta])* + $PublicBitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:tt = $value:expr; + )* + } + ) => { + $(#[$outer])* + impl $PublicBitFlags { + $( + $crate::__bitflags_flag!({ + name: $Flag, + named: { + $(#[$inner $($args)*])* + #[allow( + deprecated, + non_upper_case_globals, + )] + pub const $Flag: Self = Self::from_bits_retain($value); + }, + unnamed: {}, + }); + )* + } + + $(#[$outer])* + impl $crate::Flags for $PublicBitFlags { + const FLAGS: &'static [$crate::Flag<$PublicBitFlags>] = &[ + $( + $crate::__bitflags_flag!({ + name: $Flag, + named: { + $crate::__bitflags_expr_safe_attrs!( + $(#[$inner $($args)*])* + { + #[allow( + deprecated, + non_upper_case_globals, + )] + $crate::Flag::new($crate::__private::core::stringify!($Flag), $PublicBitFlags::$Flag) + } + ) + }, + unnamed: { + $crate::__bitflags_expr_safe_attrs!( + $(#[$inner $($args)*])* + { + #[allow( + deprecated, + non_upper_case_globals, + )] + $crate::Flag::new("", $PublicBitFlags::from_bits_retain($value)) + } + ) + }, + }), + )* + ]; + + type Bits = $T; + + fn bits(&self) -> $T { + $PublicBitFlags::bits(self) + } + + fn from_bits_retain(bits: $T) -> $PublicBitFlags { + $PublicBitFlags::from_bits_retain(bits) + } + } + }; +} diff --git a/vendor/bitflags/src/tests.rs b/vendor/bitflags/src/tests.rs new file mode 100644 index 0000000..ed52ad4 --- /dev/null +++ b/vendor/bitflags/src/tests.rs @@ -0,0 +1,131 @@ +mod all; +mod bits; +mod complement; +mod contains; +mod difference; +mod empty; +mod eq; +mod extend; +mod flags; +mod fmt; +mod from_bits; +mod from_bits_retain; +mod from_bits_truncate; +mod from_name; +mod insert; +mod intersection; +mod intersects; +mod is_all; +mod is_empty; +mod iter; +mod parser; +mod remove; +mod symmetric_difference; +mod union; + +bitflags! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestFlags: u8 { + /// 1 + const A = 1; + + /// 1 << 1 + const B = 1 << 1; + + /// 1 << 2 + const C = 1 << 2; + + /// 1 | (1 << 1) | (1 << 2) + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestFlagsInvert: u8 { + /// 1 | (1 << 1) | (1 << 2) + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); + + /// 1 + const A = 1; + + /// 1 << 1 + const B = 1 << 1; + + /// 1 << 2 + const C = 1 << 2; + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestZero: u8 { + /// 0 + const ZERO = 0; + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestZeroOne: u8 { + /// 0 + const ZERO = 0; + + /// 1 + const ONE = 1; + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestUnicode: u8 { + /// 1 + const 一 = 1; + + /// 2 + const 二 = 1 << 1; + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestEmpty: u8 {} + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestOverlapping: u8 { + /// 1 | (1 << 1) + const AB = 1 | (1 << 1); + + /// (1 << 1) | (1 << 2) + const BC = (1 << 1) | (1 << 2); + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestOverlappingFull: u8 { + /// 1 + const A = 1; + + /// 1 + const B = 1; + + /// 1 + const C = 1; + + /// 2 + const D = 1 << 1; + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestExternal: u8 { + /// 1 + const A = 1; + + /// 1 << 1 + const B = 1 << 1; + + /// 1 << 2 + const C = 1 << 2; + + /// 1 | (1 << 1) | (1 << 2) + const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits(); + + /// External + const _ = !0; + } + + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] + pub struct TestExternalFull: u8 { + /// External + const _ = !0; + } +} diff --git a/vendor/bitflags/src/tests/all.rs b/vendor/bitflags/src/tests/all.rs new file mode 100644 index 0000000..cceb93a --- /dev/null +++ b/vendor/bitflags/src/tests/all.rs @@ -0,0 +1,23 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(1 | 1 << 1 | 1 << 2, TestFlags::all); + + case(0, TestZero::all); + + case(0, TestEmpty::all); + + case(!0, TestExternal::all); +} + +#[track_caller] +fn case(expected: T::Bits, inherent: impl FnOnce() -> T) +where + ::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!(expected, inherent().bits(), "T::all()"); + assert_eq!(expected, T::all().bits(), "Flags::all()"); +} diff --git a/vendor/bitflags/src/tests/bits.rs b/vendor/bitflags/src/tests/bits.rs new file mode 100644 index 0000000..678f153 --- /dev/null +++ b/vendor/bitflags/src/tests/bits.rs @@ -0,0 +1,36 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(0, TestFlags::empty(), TestFlags::bits); + + case(1, TestFlags::A, TestFlags::bits); + case(1 | 1 << 1 | 1 << 2, TestFlags::ABC, TestFlags::bits); + + case(!0, TestFlags::from_bits_retain(u8::MAX), TestFlags::bits); + case(1 << 3, TestFlags::from_bits_retain(1 << 3), TestFlags::bits); + + case(1 << 3, TestZero::from_bits_retain(1 << 3), TestZero::bits); + + case(1 << 3, TestEmpty::from_bits_retain(1 << 3), TestEmpty::bits); + + case( + 1 << 4 | 1 << 6, + TestExternal::from_bits_retain(1 << 4 | 1 << 6), + TestExternal::bits, + ); +} + +#[track_caller] +fn case( + expected: T::Bits, + value: T, + inherent: impl FnOnce(&T) -> T::Bits, +) where + T::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!(expected, inherent(&value), "{:?}.bits()", value); + assert_eq!(expected, Flags::bits(&value), "Flags::bits({:?})", value); +} diff --git a/vendor/bitflags/src/tests/complement.rs b/vendor/bitflags/src/tests/complement.rs new file mode 100644 index 0000000..ac7a421 --- /dev/null +++ b/vendor/bitflags/src/tests/complement.rs @@ -0,0 +1,53 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(0, TestFlags::all(), TestFlags::complement); + case(0, TestFlags::from_bits_retain(!0), TestFlags::complement); + + case(1 | 1 << 1, TestFlags::C, TestFlags::complement); + case( + 1 | 1 << 1, + TestFlags::C | TestFlags::from_bits_retain(1 << 3), + TestFlags::complement, + ); + + case( + 1 | 1 << 1 | 1 << 2, + TestFlags::empty(), + TestFlags::complement, + ); + case( + 1 | 1 << 1 | 1 << 2, + TestFlags::from_bits_retain(1 << 3), + TestFlags::complement, + ); + + case(0, TestZero::empty(), TestZero::complement); + + case(0, TestEmpty::empty(), TestEmpty::complement); + + case(1 << 2, TestOverlapping::AB, TestOverlapping::complement); + + case(!0, TestExternal::empty(), TestExternal::complement); +} + +#[track_caller] +fn case + Copy>( + expected: T::Bits, + value: T, + inherent: impl FnOnce(T) -> T, +) where + T::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!(expected, inherent(value).bits(), "{:?}.complement()", value); + assert_eq!( + expected, + Flags::complement(value).bits(), + "Flags::complement({:?})", + value + ); + assert_eq!(expected, (!value).bits(), "!{:?}", value); +} diff --git a/vendor/bitflags/src/tests/contains.rs b/vendor/bitflags/src/tests/contains.rs new file mode 100644 index 0000000..12428dd --- /dev/null +++ b/vendor/bitflags/src/tests/contains.rs @@ -0,0 +1,108 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[ + (TestFlags::empty(), true), + (TestFlags::A, false), + (TestFlags::B, false), + (TestFlags::C, false), + (TestFlags::from_bits_retain(1 << 3), false), + ], + TestFlags::contains, + ); + + case( + TestFlags::A, + &[ + (TestFlags::empty(), true), + (TestFlags::A, true), + (TestFlags::B, false), + (TestFlags::C, false), + (TestFlags::ABC, false), + (TestFlags::from_bits_retain(1 << 3), false), + (TestFlags::from_bits_retain(1 | (1 << 3)), false), + ], + TestFlags::contains, + ); + + case( + TestFlags::ABC, + &[ + (TestFlags::empty(), true), + (TestFlags::A, true), + (TestFlags::B, true), + (TestFlags::C, true), + (TestFlags::ABC, true), + (TestFlags::from_bits_retain(1 << 3), false), + ], + TestFlags::contains, + ); + + case( + TestFlags::from_bits_retain(1 << 3), + &[ + (TestFlags::empty(), true), + (TestFlags::A, false), + (TestFlags::B, false), + (TestFlags::C, false), + (TestFlags::from_bits_retain(1 << 3), true), + ], + TestFlags::contains, + ); + + case( + TestZero::ZERO, + &[(TestZero::ZERO, true)], + TestZero::contains, + ); + + case( + TestOverlapping::AB, + &[ + (TestOverlapping::AB, true), + (TestOverlapping::BC, false), + (TestOverlapping::from_bits_retain(1 << 1), true), + ], + TestOverlapping::contains, + ); + + case( + TestExternal::all(), + &[ + (TestExternal::A, true), + (TestExternal::B, true), + (TestExternal::C, true), + (TestExternal::from_bits_retain(1 << 5 | 1 << 7), true), + ], + TestExternal::contains, + ); +} + +#[track_caller] +fn case( + value: T, + inputs: &[(T, bool)], + mut inherent: impl FnMut(&T, T) -> bool, +) { + for (input, expected) in inputs { + assert_eq!( + *expected, + inherent(&value, *input), + "{:?}.contains({:?})", + value, + input + ); + assert_eq!( + *expected, + Flags::contains(&value, *input), + "Flags::contains({:?}, {:?})", + value, + input + ); + } +} diff --git a/vendor/bitflags/src/tests/difference.rs b/vendor/bitflags/src/tests/difference.rs new file mode 100644 index 0000000..6ce9c0b --- /dev/null +++ b/vendor/bitflags/src/tests/difference.rs @@ -0,0 +1,92 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::A | TestFlags::B, + &[ + (TestFlags::A, 1 << 1), + (TestFlags::B, 1), + (TestFlags::from_bits_retain(1 << 3), 1 | 1 << 1), + ], + TestFlags::difference, + ); + + case( + TestFlags::from_bits_retain(1 | 1 << 3), + &[ + (TestFlags::A, 1 << 3), + (TestFlags::from_bits_retain(1 << 3), 1), + ], + TestFlags::difference, + ); + + case( + TestExternal::from_bits_retain(!0), + &[(TestExternal::A, 0b1111_1110)], + TestExternal::difference, + ); + + assert_eq!( + 0b1111_1110, + (TestExternal::from_bits_retain(!0) & !TestExternal::A).bits() + ); + + assert_eq!( + 0b1111_1110, + (TestFlags::from_bits_retain(!0).difference(TestFlags::A)).bits() + ); + + // The `!` operator unsets bits that don't correspond to known flags + assert_eq!( + 1 << 1 | 1 << 2, + (TestFlags::from_bits_retain(!0) & !TestFlags::A).bits() + ); +} + +#[track_caller] +fn case + std::ops::SubAssign + Copy>( + value: T, + inputs: &[(T, T::Bits)], + mut inherent: impl FnMut(T, T) -> T, +) where + T::Bits: std::fmt::Debug + PartialEq + Copy, +{ + for (input, expected) in inputs { + assert_eq!( + *expected, + inherent(value, *input).bits(), + "{:?}.difference({:?})", + value, + input + ); + assert_eq!( + *expected, + Flags::difference(value, *input).bits(), + "Flags::difference({:?}, {:?})", + value, + input + ); + assert_eq!( + *expected, + (value - *input).bits(), + "{:?} - {:?}", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + value -= *input; + value + } + .bits(), + "{:?} -= {:?}", + value, + input, + ); + } +} diff --git a/vendor/bitflags/src/tests/empty.rs b/vendor/bitflags/src/tests/empty.rs new file mode 100644 index 0000000..57fb1c7 --- /dev/null +++ b/vendor/bitflags/src/tests/empty.rs @@ -0,0 +1,23 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(0, TestFlags::empty); + + case(0, TestZero::empty); + + case(0, TestEmpty::empty); + + case(0, TestExternal::empty); +} + +#[track_caller] +fn case(expected: T::Bits, inherent: impl FnOnce() -> T) +where + ::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!(expected, inherent().bits(), "T::empty()"); + assert_eq!(expected, T::empty().bits(), "Flags::empty()"); +} diff --git a/vendor/bitflags/src/tests/eq.rs b/vendor/bitflags/src/tests/eq.rs new file mode 100644 index 0000000..9779af7 --- /dev/null +++ b/vendor/bitflags/src/tests/eq.rs @@ -0,0 +1,10 @@ +use super::*; + +#[test] +fn cases() { + assert_eq!(TestFlags::empty(), TestFlags::empty()); + assert_eq!(TestFlags::all(), TestFlags::all()); + + assert!(TestFlags::from_bits_retain(1) < TestFlags::from_bits_retain(2)); + assert!(TestFlags::from_bits_retain(2) > TestFlags::from_bits_retain(1)); +} diff --git a/vendor/bitflags/src/tests/extend.rs b/vendor/bitflags/src/tests/extend.rs new file mode 100644 index 0000000..869dc17 --- /dev/null +++ b/vendor/bitflags/src/tests/extend.rs @@ -0,0 +1,42 @@ +use super::*; + +#[test] +fn cases() { + let mut flags = TestFlags::empty(); + + flags.extend(TestFlags::A); + + assert_eq!(TestFlags::A, flags); + + flags.extend(TestFlags::A | TestFlags::B | TestFlags::C); + + assert_eq!(TestFlags::ABC, flags); + + flags.extend(TestFlags::from_bits_retain(1 << 5)); + + assert_eq!(TestFlags::ABC | TestFlags::from_bits_retain(1 << 5), flags); +} + +mod external { + use super::*; + + #[test] + fn cases() { + let mut flags = TestExternal::empty(); + + flags.extend(TestExternal::A); + + assert_eq!(TestExternal::A, flags); + + flags.extend(TestExternal::A | TestExternal::B | TestExternal::C); + + assert_eq!(TestExternal::ABC, flags); + + flags.extend(TestExternal::from_bits_retain(1 << 5)); + + assert_eq!( + TestExternal::ABC | TestExternal::from_bits_retain(1 << 5), + flags + ); + } +} diff --git a/vendor/bitflags/src/tests/flags.rs b/vendor/bitflags/src/tests/flags.rs new file mode 100644 index 0000000..7a625b3 --- /dev/null +++ b/vendor/bitflags/src/tests/flags.rs @@ -0,0 +1,46 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + let flags = TestFlags::FLAGS + .iter() + .map(|flag| (flag.name(), flag.value().bits())) + .collect::>(); + + assert_eq!( + vec![ + ("A", 1u8), + ("B", 1 << 1), + ("C", 1 << 2), + ("ABC", 1 | 1 << 1 | 1 << 2), + ], + flags, + ); + + assert_eq!(0, TestEmpty::FLAGS.iter().count()); +} + +mod external { + use super::*; + + #[test] + fn cases() { + let flags = TestExternal::FLAGS + .iter() + .map(|flag| (flag.name(), flag.value().bits())) + .collect::>(); + + assert_eq!( + vec![ + ("A", 1u8), + ("B", 1 << 1), + ("C", 1 << 2), + ("ABC", 1 | 1 << 1 | 1 << 2), + ("", !0), + ], + flags, + ); + } +} diff --git a/vendor/bitflags/src/tests/fmt.rs b/vendor/bitflags/src/tests/fmt.rs new file mode 100644 index 0000000..ed45718 --- /dev/null +++ b/vendor/bitflags/src/tests/fmt.rs @@ -0,0 +1,97 @@ +use super::*; + +#[test] +fn cases() { + case(TestFlags::empty(), "TestFlags(0x0)", "0", "0", "0", "0"); + case(TestFlags::A, "TestFlags(A)", "1", "1", "1", "1"); + case( + TestFlags::all(), + "TestFlags(A | B | C)", + "7", + "7", + "7", + "111", + ); + case( + TestFlags::from_bits_retain(1 << 3), + "TestFlags(0x8)", + "8", + "8", + "10", + "1000", + ); + case( + TestFlags::A | TestFlags::from_bits_retain(1 << 3), + "TestFlags(A | 0x8)", + "9", + "9", + "11", + "1001", + ); + + case(TestZero::ZERO, "TestZero(0x0)", "0", "0", "0", "0"); + case( + TestZero::ZERO | TestZero::from_bits_retain(1), + "TestZero(0x1)", + "1", + "1", + "1", + "1", + ); + + case(TestZeroOne::ONE, "TestZeroOne(ONE)", "1", "1", "1", "1"); + + case( + TestOverlapping::from_bits_retain(1 << 1), + "TestOverlapping(0x2)", + "2", + "2", + "2", + "10", + ); + + case( + TestExternal::from_bits_retain(1 | 1 << 1 | 1 << 3), + "TestExternal(A | B | 0x8)", + "B", + "b", + "13", + "1011", + ); + + case( + TestExternal::all(), + "TestExternal(A | B | C | 0xf8)", + "FF", + "ff", + "377", + "11111111", + ); + + case( + TestExternalFull::all(), + "TestExternalFull(0xff)", + "FF", + "ff", + "377", + "11111111", + ); +} + +#[track_caller] +fn case< + T: std::fmt::Debug + std::fmt::UpperHex + std::fmt::LowerHex + std::fmt::Octal + std::fmt::Binary, +>( + value: T, + debug: &str, + uhex: &str, + lhex: &str, + oct: &str, + bin: &str, +) { + assert_eq!(debug, format!("{:?}", value)); + assert_eq!(uhex, format!("{:X}", value)); + assert_eq!(lhex, format!("{:x}", value)); + assert_eq!(oct, format!("{:o}", value)); + assert_eq!(bin, format!("{:b}", value)); +} diff --git a/vendor/bitflags/src/tests/from_bits.rs b/vendor/bitflags/src/tests/from_bits.rs new file mode 100644 index 0000000..dada9af --- /dev/null +++ b/vendor/bitflags/src/tests/from_bits.rs @@ -0,0 +1,45 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(Some(0), 0, TestFlags::from_bits); + case(Some(1), 1, TestFlags::from_bits); + case( + Some(1 | 1 << 1 | 1 << 2), + 1 | 1 << 1 | 1 << 2, + TestFlags::from_bits, + ); + + case(None, 1 << 3, TestFlags::from_bits); + case(None, 1 | 1 << 3, TestFlags::from_bits); + + case(Some(1 | 1 << 1), 1 | 1 << 1, TestOverlapping::from_bits); + + case(Some(1 << 1), 1 << 1, TestOverlapping::from_bits); + + case(Some(1 << 5), 1 << 5, TestExternal::from_bits); +} + +#[track_caller] +fn case( + expected: Option, + input: T::Bits, + inherent: impl FnOnce(T::Bits) -> Option, +) where + ::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!( + expected, + inherent(input).map(|f| f.bits()), + "T::from_bits({:?})", + input + ); + assert_eq!( + expected, + T::from_bits(input).map(|f| f.bits()), + "Flags::from_bits({:?})", + input + ); +} diff --git a/vendor/bitflags/src/tests/from_bits_retain.rs b/vendor/bitflags/src/tests/from_bits_retain.rs new file mode 100644 index 0000000..1ae28a6 --- /dev/null +++ b/vendor/bitflags/src/tests/from_bits_retain.rs @@ -0,0 +1,38 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(0, TestFlags::from_bits_retain); + case(1, TestFlags::from_bits_retain); + case(1 | 1 << 1 | 1 << 2, TestFlags::from_bits_retain); + + case(1 << 3, TestFlags::from_bits_retain); + case(1 | 1 << 3, TestFlags::from_bits_retain); + + case(1 | 1 << 1, TestOverlapping::from_bits_retain); + + case(1 << 1, TestOverlapping::from_bits_retain); + + case(1 << 5, TestExternal::from_bits_retain); +} + +#[track_caller] +fn case(input: T::Bits, inherent: impl FnOnce(T::Bits) -> T) +where + ::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!( + input, + inherent(input).bits(), + "T::from_bits_retain({:?})", + input + ); + assert_eq!( + input, + T::from_bits_retain(input).bits(), + "Flags::from_bits_retain({:?})", + input + ); +} diff --git a/vendor/bitflags/src/tests/from_bits_truncate.rs b/vendor/bitflags/src/tests/from_bits_truncate.rs new file mode 100644 index 0000000..e4f3e53 --- /dev/null +++ b/vendor/bitflags/src/tests/from_bits_truncate.rs @@ -0,0 +1,42 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(0, 0, TestFlags::from_bits_truncate); + case(1, 1, TestFlags::from_bits_truncate); + case( + 1 | 1 << 1 | 1 << 2, + 1 | 1 << 1 | 1 << 2, + TestFlags::from_bits_truncate, + ); + + case(0, 1 << 3, TestFlags::from_bits_truncate); + case(1, 1 | 1 << 3, TestFlags::from_bits_truncate); + + case(1 | 1 << 1, 1 | 1 << 1, TestOverlapping::from_bits_truncate); + + case(1 << 1, 1 << 1, TestOverlapping::from_bits_truncate); + + case(1 << 5, 1 << 5, TestExternal::from_bits_truncate); +} + +#[track_caller] +fn case(expected: T::Bits, input: T::Bits, inherent: impl FnOnce(T::Bits) -> T) +where + ::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!( + expected, + inherent(input).bits(), + "T::from_bits_truncate({:?})", + input + ); + assert_eq!( + expected, + T::from_bits_truncate(input).bits(), + "Flags::from_bits_truncate({:?})", + input + ); +} diff --git a/vendor/bitflags/src/tests/from_name.rs b/vendor/bitflags/src/tests/from_name.rs new file mode 100644 index 0000000..1d9a4e4 --- /dev/null +++ b/vendor/bitflags/src/tests/from_name.rs @@ -0,0 +1,42 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(Some(1), "A", TestFlags::from_name); + case(Some(1 << 1), "B", TestFlags::from_name); + case(Some(1 | 1 << 1 | 1 << 2), "ABC", TestFlags::from_name); + + case(None, "", TestFlags::from_name); + case(None, "a", TestFlags::from_name); + case(None, "0x1", TestFlags::from_name); + case(None, "A | B", TestFlags::from_name); + + case(Some(0), "ZERO", TestZero::from_name); + + case(Some(2), "二", TestUnicode::from_name); + + case(None, "_", TestExternal::from_name); + + case(None, "", TestExternal::from_name); +} + +#[track_caller] +fn case(expected: Option, input: &str, inherent: impl FnOnce(&str) -> Option) +where + ::Bits: std::fmt::Debug + PartialEq, +{ + assert_eq!( + expected, + inherent(input).map(|f| f.bits()), + "T::from_name({:?})", + input + ); + assert_eq!( + expected, + T::from_name(input).map(|f| f.bits()), + "Flags::from_name({:?})", + input + ); +} diff --git a/vendor/bitflags/src/tests/insert.rs b/vendor/bitflags/src/tests/insert.rs new file mode 100644 index 0000000..b18cd17 --- /dev/null +++ b/vendor/bitflags/src/tests/insert.rs @@ -0,0 +1,91 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[ + (TestFlags::A, 1), + (TestFlags::A | TestFlags::B, 1 | 1 << 1), + (TestFlags::empty(), 0), + (TestFlags::from_bits_retain(1 << 3), 1 << 3), + ], + TestFlags::insert, + TestFlags::set, + ); + + case( + TestFlags::A, + &[ + (TestFlags::A, 1), + (TestFlags::empty(), 1), + (TestFlags::B, 1 | 1 << 1), + ], + TestFlags::insert, + TestFlags::set, + ); +} + +#[track_caller] +fn case( + value: T, + inputs: &[(T, T::Bits)], + mut inherent_insert: impl FnMut(&mut T, T), + mut inherent_set: impl FnMut(&mut T, T, bool), +) where + T::Bits: std::fmt::Debug + PartialEq + Copy, +{ + for (input, expected) in inputs { + assert_eq!( + *expected, + { + let mut value = value; + inherent_insert(&mut value, *input); + value + } + .bits(), + "{:?}.insert({:?})", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + Flags::insert(&mut value, *input); + value + } + .bits(), + "Flags::insert({:?}, {:?})", + value, + input + ); + + assert_eq!( + *expected, + { + let mut value = value; + inherent_set(&mut value, *input, true); + value + } + .bits(), + "{:?}.set({:?}, true)", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + Flags::set(&mut value, *input, true); + value + } + .bits(), + "Flags::set({:?}, {:?}, true)", + value, + input + ); + } +} diff --git a/vendor/bitflags/src/tests/intersection.rs b/vendor/bitflags/src/tests/intersection.rs new file mode 100644 index 0000000..10a8ae9 --- /dev/null +++ b/vendor/bitflags/src/tests/intersection.rs @@ -0,0 +1,79 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[(TestFlags::empty(), 0), (TestFlags::all(), 0)], + TestFlags::intersection, + ); + + case( + TestFlags::all(), + &[ + (TestFlags::all(), 1 | 1 << 1 | 1 << 2), + (TestFlags::A, 1), + (TestFlags::from_bits_retain(1 << 3), 0), + ], + TestFlags::intersection, + ); + + case( + TestFlags::from_bits_retain(1 << 3), + &[(TestFlags::from_bits_retain(1 << 3), 1 << 3)], + TestFlags::intersection, + ); + + case( + TestOverlapping::AB, + &[(TestOverlapping::BC, 1 << 1)], + TestOverlapping::intersection, + ); +} + +#[track_caller] +fn case + std::ops::BitAndAssign + Copy>( + value: T, + inputs: &[(T, T::Bits)], + mut inherent: impl FnMut(T, T) -> T, +) where + T::Bits: std::fmt::Debug + PartialEq + Copy, +{ + for (input, expected) in inputs { + assert_eq!( + *expected, + inherent(value, *input).bits(), + "{:?}.intersection({:?})", + value, + input + ); + assert_eq!( + *expected, + Flags::intersection(value, *input).bits(), + "Flags::intersection({:?}, {:?})", + value, + input + ); + assert_eq!( + *expected, + (value & *input).bits(), + "{:?} & {:?}", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + value &= *input; + value + } + .bits(), + "{:?} &= {:?}", + value, + input, + ); + } +} diff --git a/vendor/bitflags/src/tests/intersects.rs b/vendor/bitflags/src/tests/intersects.rs new file mode 100644 index 0000000..fe90798 --- /dev/null +++ b/vendor/bitflags/src/tests/intersects.rs @@ -0,0 +1,91 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[ + (TestFlags::empty(), false), + (TestFlags::A, false), + (TestFlags::B, false), + (TestFlags::C, false), + (TestFlags::from_bits_retain(1 << 3), false), + ], + TestFlags::intersects, + ); + + case( + TestFlags::A, + &[ + (TestFlags::empty(), false), + (TestFlags::A, true), + (TestFlags::B, false), + (TestFlags::C, false), + (TestFlags::ABC, true), + (TestFlags::from_bits_retain(1 << 3), false), + (TestFlags::from_bits_retain(1 | (1 << 3)), true), + ], + TestFlags::intersects, + ); + + case( + TestFlags::ABC, + &[ + (TestFlags::empty(), false), + (TestFlags::A, true), + (TestFlags::B, true), + (TestFlags::C, true), + (TestFlags::ABC, true), + (TestFlags::from_bits_retain(1 << 3), false), + ], + TestFlags::intersects, + ); + + case( + TestFlags::from_bits_retain(1 << 3), + &[ + (TestFlags::empty(), false), + (TestFlags::A, false), + (TestFlags::B, false), + (TestFlags::C, false), + (TestFlags::from_bits_retain(1 << 3), true), + ], + TestFlags::intersects, + ); + + case( + TestOverlapping::AB, + &[ + (TestOverlapping::AB, true), + (TestOverlapping::BC, true), + (TestOverlapping::from_bits_retain(1 << 1), true), + ], + TestOverlapping::intersects, + ); +} + +#[track_caller] +fn case( + value: T, + inputs: &[(T, bool)], + mut inherent: impl FnMut(&T, T) -> bool, +) { + for (input, expected) in inputs { + assert_eq!( + *expected, + inherent(&value, *input), + "{:?}.intersects({:?})", + value, + input + ); + assert_eq!( + *expected, + Flags::intersects(&value, *input), + "Flags::intersects({:?}, {:?})", + value, + input + ); + } +} diff --git a/vendor/bitflags/src/tests/is_all.rs b/vendor/bitflags/src/tests/is_all.rs new file mode 100644 index 0000000..382a458 --- /dev/null +++ b/vendor/bitflags/src/tests/is_all.rs @@ -0,0 +1,32 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(false, TestFlags::empty(), TestFlags::is_all); + case(false, TestFlags::A, TestFlags::is_all); + + case(true, TestFlags::ABC, TestFlags::is_all); + + case( + true, + TestFlags::ABC | TestFlags::from_bits_retain(1 << 3), + TestFlags::is_all, + ); + + case(true, TestZero::empty(), TestZero::is_all); + + case(true, TestEmpty::empty(), TestEmpty::is_all); +} + +#[track_caller] +fn case(expected: bool, value: T, inherent: impl FnOnce(&T) -> bool) { + assert_eq!(expected, inherent(&value), "{:?}.is_all()", value); + assert_eq!( + expected, + Flags::is_all(&value), + "Flags::is_all({:?})", + value + ); +} diff --git a/vendor/bitflags/src/tests/is_empty.rs b/vendor/bitflags/src/tests/is_empty.rs new file mode 100644 index 0000000..92165f1 --- /dev/null +++ b/vendor/bitflags/src/tests/is_empty.rs @@ -0,0 +1,31 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case(true, TestFlags::empty(), TestFlags::is_empty); + + case(false, TestFlags::A, TestFlags::is_empty); + case(false, TestFlags::ABC, TestFlags::is_empty); + case( + false, + TestFlags::from_bits_retain(1 << 3), + TestFlags::is_empty, + ); + + case(true, TestZero::empty(), TestZero::is_empty); + + case(true, TestEmpty::empty(), TestEmpty::is_empty); +} + +#[track_caller] +fn case(expected: bool, value: T, inherent: impl FnOnce(&T) -> bool) { + assert_eq!(expected, inherent(&value), "{:?}.is_empty()", value); + assert_eq!( + expected, + Flags::is_empty(&value), + "Flags::is_empty({:?})", + value + ); +} diff --git a/vendor/bitflags/src/tests/iter.rs b/vendor/bitflags/src/tests/iter.rs new file mode 100644 index 0000000..54b1d27 --- /dev/null +++ b/vendor/bitflags/src/tests/iter.rs @@ -0,0 +1,209 @@ +use super::*; + +use crate::Flags; + +#[test] +#[cfg(not(miri))] // Very slow in miri +fn roundtrip() { + for a in 0u8..=255 { + for b in 0u8..=255 { + let f = TestFlags::from_bits_retain(a | b); + + assert_eq!(f, f.iter().collect::()); + assert_eq!( + TestFlags::from_bits_truncate(f.bits()), + f.iter_names().map(|(_, f)| f).collect::() + ); + + let f = TestExternal::from_bits_retain(a | b); + + assert_eq!(f, f.iter().collect::()); + } + } +} + +mod collect { + use super::*; + + #[test] + fn cases() { + assert_eq!(0, [].into_iter().collect::().bits()); + + assert_eq!(1, [TestFlags::A,].into_iter().collect::().bits()); + + assert_eq!( + 1 | 1 << 1 | 1 << 2, + [TestFlags::A, TestFlags::B | TestFlags::C,] + .into_iter() + .collect::() + .bits() + ); + + assert_eq!( + 1 | 1 << 3, + [ + TestFlags::from_bits_retain(1 << 3), + TestFlags::empty(), + TestFlags::A, + ] + .into_iter() + .collect::() + .bits() + ); + + assert_eq!( + 1 << 5 | 1 << 7, + [ + TestExternal::empty(), + TestExternal::from_bits_retain(1 << 5), + TestExternal::from_bits_retain(1 << 7), + ] + .into_iter() + .collect::() + .bits() + ); + } +} + +mod iter { + use super::*; + + #[test] + fn cases() { + case(&[], TestFlags::empty(), TestFlags::iter); + + case(&[1], TestFlags::A, TestFlags::iter); + case(&[1, 1 << 1], TestFlags::A | TestFlags::B, TestFlags::iter); + case( + &[1, 1 << 1, 1 << 3], + TestFlags::A | TestFlags::B | TestFlags::from_bits_retain(1 << 3), + TestFlags::iter, + ); + + case(&[1, 1 << 1, 1 << 2], TestFlags::ABC, TestFlags::iter); + case( + &[1, 1 << 1, 1 << 2, 1 << 3], + TestFlags::ABC | TestFlags::from_bits_retain(1 << 3), + TestFlags::iter, + ); + + case( + &[1 | 1 << 1 | 1 << 2], + TestFlagsInvert::ABC, + TestFlagsInvert::iter, + ); + + case(&[], TestZero::ZERO, TestZero::iter); + + case( + &[1, 1 << 1, 1 << 2, 0b1111_1000], + TestExternal::all(), + TestExternal::iter, + ); + } + + #[track_caller] + fn case + Copy>( + expected: &[T::Bits], + value: T, + inherent: impl FnOnce(&T) -> crate::iter::Iter, + ) where + T::Bits: std::fmt::Debug + PartialEq, + { + assert_eq!( + expected, + inherent(&value).map(|f| f.bits()).collect::>(), + "{:?}.iter()", + value + ); + assert_eq!( + expected, + Flags::iter(&value).map(|f| f.bits()).collect::>(), + "Flags::iter({:?})", + value + ); + assert_eq!( + expected, + value.into_iter().map(|f| f.bits()).collect::>(), + "{:?}.into_iter()", + value + ); + } +} + +mod iter_names { + use super::*; + + #[test] + fn cases() { + case(&[], TestFlags::empty(), TestFlags::iter_names); + + case(&[("A", 1)], TestFlags::A, TestFlags::iter_names); + case( + &[("A", 1), ("B", 1 << 1)], + TestFlags::A | TestFlags::B, + TestFlags::iter_names, + ); + case( + &[("A", 1), ("B", 1 << 1)], + TestFlags::A | TestFlags::B | TestFlags::from_bits_retain(1 << 3), + TestFlags::iter_names, + ); + + case( + &[("A", 1), ("B", 1 << 1), ("C", 1 << 2)], + TestFlags::ABC, + TestFlags::iter_names, + ); + case( + &[("A", 1), ("B", 1 << 1), ("C", 1 << 2)], + TestFlags::ABC | TestFlags::from_bits_retain(1 << 3), + TestFlags::iter_names, + ); + + case( + &[("ABC", 1 | 1 << 1 | 1 << 2)], + TestFlagsInvert::ABC, + TestFlagsInvert::iter_names, + ); + + case(&[], TestZero::ZERO, TestZero::iter_names); + + case( + &[("A", 1)], + TestOverlappingFull::A, + TestOverlappingFull::iter_names, + ); + case( + &[("A", 1), ("D", 1 << 1)], + TestOverlappingFull::A | TestOverlappingFull::D, + TestOverlappingFull::iter_names, + ); + } + + #[track_caller] + fn case( + expected: &[(&'static str, T::Bits)], + value: T, + inherent: impl FnOnce(&T) -> crate::iter::IterNames, + ) where + T::Bits: std::fmt::Debug + PartialEq, + { + assert_eq!( + expected, + inherent(&value) + .map(|(n, f)| (n, f.bits())) + .collect::>(), + "{:?}.iter_names()", + value + ); + assert_eq!( + expected, + Flags::iter_names(&value) + .map(|(n, f)| (n, f.bits())) + .collect::>(), + "Flags::iter_names({:?})", + value + ); + } +} diff --git a/vendor/bitflags/src/tests/parser.rs b/vendor/bitflags/src/tests/parser.rs new file mode 100644 index 0000000..fb27225 --- /dev/null +++ b/vendor/bitflags/src/tests/parser.rs @@ -0,0 +1,332 @@ +use super::*; + +use crate::{parser::*, Flags}; + +#[test] +#[cfg(not(miri))] // Very slow in miri +fn roundtrip() { + let mut s = String::new(); + + for a in 0u8..=255 { + for b in 0u8..=255 { + let f = TestFlags::from_bits_retain(a | b); + + s.clear(); + to_writer(&f, &mut s).unwrap(); + + assert_eq!(f, from_str::(&s).unwrap()); + } + } +} + +#[test] +#[cfg(not(miri))] // Very slow in miri +fn roundtrip_truncate() { + let mut s = String::new(); + + for a in 0u8..=255 { + for b in 0u8..=255 { + let f = TestFlags::from_bits_retain(a | b); + + s.clear(); + to_writer_truncate(&f, &mut s).unwrap(); + + assert_eq!( + TestFlags::from_bits_truncate(f.bits()), + from_str_truncate::(&s).unwrap() + ); + } + } +} + +#[test] +#[cfg(not(miri))] // Very slow in miri +fn roundtrip_strict() { + let mut s = String::new(); + + for a in 0u8..=255 { + for b in 0u8..=255 { + let f = TestFlags::from_bits_retain(a | b); + + s.clear(); + to_writer_strict(&f, &mut s).unwrap(); + + let mut strict = TestFlags::empty(); + for (_, flag) in f.iter_names() { + strict |= flag; + } + let f = strict; + + if let Ok(s) = from_str_strict::(&s) { + assert_eq!(f, s); + } + } + } +} + +mod from_str { + use super::*; + + #[test] + fn valid() { + assert_eq!(0, from_str::("").unwrap().bits()); + + assert_eq!(1, from_str::("A").unwrap().bits()); + assert_eq!(1, from_str::(" A ").unwrap().bits()); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str::("A | B | C").unwrap().bits() + ); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str::("A\n|\tB\r\n| C ").unwrap().bits() + ); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str::("A|B|C").unwrap().bits() + ); + + assert_eq!(1 << 3, from_str::("0x8").unwrap().bits()); + assert_eq!(1 | 1 << 3, from_str::("A | 0x8").unwrap().bits()); + assert_eq!( + 1 | 1 << 1 | 1 << 3, + from_str::("0x1 | 0x8 | B").unwrap().bits() + ); + + assert_eq!( + 1 | 1 << 1, + from_str::("一 | 二").unwrap().bits() + ); + } + + #[test] + fn invalid() { + assert!(from_str::("a") + .unwrap_err() + .to_string() + .starts_with("unrecognized named flag")); + assert!(from_str::("A & B") + .unwrap_err() + .to_string() + .starts_with("unrecognized named flag")); + + assert!(from_str::("0xg") + .unwrap_err() + .to_string() + .starts_with("invalid hex flag")); + assert!(from_str::("0xffffffffffff") + .unwrap_err() + .to_string() + .starts_with("invalid hex flag")); + } +} + +mod to_writer { + use super::*; + + #[test] + fn cases() { + assert_eq!("", write(TestFlags::empty())); + assert_eq!("A", write(TestFlags::A)); + assert_eq!("A | B | C", write(TestFlags::all())); + assert_eq!("0x8", write(TestFlags::from_bits_retain(1 << 3))); + assert_eq!( + "A | 0x8", + write(TestFlags::A | TestFlags::from_bits_retain(1 << 3)) + ); + + assert_eq!("", write(TestZero::ZERO)); + + assert_eq!("ABC", write(TestFlagsInvert::all())); + + assert_eq!("0x1", write(TestOverlapping::from_bits_retain(1))); + + assert_eq!("A", write(TestOverlappingFull::C)); + assert_eq!( + "A | D", + write(TestOverlappingFull::C | TestOverlappingFull::D) + ); + } + + fn write(value: F) -> String + where + F::Bits: crate::parser::WriteHex, + { + let mut s = String::new(); + + to_writer(&value, &mut s).unwrap(); + s + } +} + +mod from_str_truncate { + use super::*; + + #[test] + fn valid() { + assert_eq!(0, from_str_truncate::("").unwrap().bits()); + + assert_eq!(1, from_str_truncate::("A").unwrap().bits()); + assert_eq!(1, from_str_truncate::(" A ").unwrap().bits()); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str_truncate::("A | B | C").unwrap().bits() + ); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str_truncate::("A\n|\tB\r\n| C ") + .unwrap() + .bits() + ); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str_truncate::("A|B|C").unwrap().bits() + ); + + assert_eq!(0, from_str_truncate::("0x8").unwrap().bits()); + assert_eq!(1, from_str_truncate::("A | 0x8").unwrap().bits()); + assert_eq!( + 1 | 1 << 1, + from_str_truncate::("0x1 | 0x8 | B") + .unwrap() + .bits() + ); + + assert_eq!( + 1 | 1 << 1, + from_str_truncate::("一 | 二").unwrap().bits() + ); + } +} + +mod to_writer_truncate { + use super::*; + + #[test] + fn cases() { + assert_eq!("", write(TestFlags::empty())); + assert_eq!("A", write(TestFlags::A)); + assert_eq!("A | B | C", write(TestFlags::all())); + assert_eq!("", write(TestFlags::from_bits_retain(1 << 3))); + assert_eq!( + "A", + write(TestFlags::A | TestFlags::from_bits_retain(1 << 3)) + ); + + assert_eq!("", write(TestZero::ZERO)); + + assert_eq!("ABC", write(TestFlagsInvert::all())); + + assert_eq!("0x1", write(TestOverlapping::from_bits_retain(1))); + + assert_eq!("A", write(TestOverlappingFull::C)); + assert_eq!( + "A | D", + write(TestOverlappingFull::C | TestOverlappingFull::D) + ); + } + + fn write(value: F) -> String + where + F::Bits: crate::parser::WriteHex, + { + let mut s = String::new(); + + to_writer_truncate(&value, &mut s).unwrap(); + s + } +} + +mod from_str_strict { + use super::*; + + #[test] + fn valid() { + assert_eq!(0, from_str_strict::("").unwrap().bits()); + + assert_eq!(1, from_str_strict::("A").unwrap().bits()); + assert_eq!(1, from_str_strict::(" A ").unwrap().bits()); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str_strict::("A | B | C").unwrap().bits() + ); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str_strict::("A\n|\tB\r\n| C ") + .unwrap() + .bits() + ); + assert_eq!( + 1 | 1 << 1 | 1 << 2, + from_str_strict::("A|B|C").unwrap().bits() + ); + + assert_eq!( + 1 | 1 << 1, + from_str_strict::("一 | 二").unwrap().bits() + ); + } + + #[test] + fn invalid() { + assert!(from_str_strict::("a") + .unwrap_err() + .to_string() + .starts_with("unrecognized named flag")); + assert!(from_str_strict::("A & B") + .unwrap_err() + .to_string() + .starts_with("unrecognized named flag")); + + assert!(from_str_strict::("0x1") + .unwrap_err() + .to_string() + .starts_with("invalid hex flag")); + assert!(from_str_strict::("0xg") + .unwrap_err() + .to_string() + .starts_with("invalid hex flag")); + assert!(from_str_strict::("0xffffffffffff") + .unwrap_err() + .to_string() + .starts_with("invalid hex flag")); + } +} + +mod to_writer_strict { + use super::*; + + #[test] + fn cases() { + assert_eq!("", write(TestFlags::empty())); + assert_eq!("A", write(TestFlags::A)); + assert_eq!("A | B | C", write(TestFlags::all())); + assert_eq!("", write(TestFlags::from_bits_retain(1 << 3))); + assert_eq!( + "A", + write(TestFlags::A | TestFlags::from_bits_retain(1 << 3)) + ); + + assert_eq!("", write(TestZero::ZERO)); + + assert_eq!("ABC", write(TestFlagsInvert::all())); + + assert_eq!("", write(TestOverlapping::from_bits_retain(1))); + + assert_eq!("A", write(TestOverlappingFull::C)); + assert_eq!( + "A | D", + write(TestOverlappingFull::C | TestOverlappingFull::D) + ); + } + + fn write(value: F) -> String + where + F::Bits: crate::parser::WriteHex, + { + let mut s = String::new(); + + to_writer_strict(&value, &mut s).unwrap(); + s + } +} diff --git a/vendor/bitflags/src/tests/remove.rs b/vendor/bitflags/src/tests/remove.rs new file mode 100644 index 0000000..574b1ed --- /dev/null +++ b/vendor/bitflags/src/tests/remove.rs @@ -0,0 +1,100 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[ + (TestFlags::A, 0), + (TestFlags::empty(), 0), + (TestFlags::from_bits_retain(1 << 3), 0), + ], + TestFlags::remove, + TestFlags::set, + ); + + case( + TestFlags::A, + &[ + (TestFlags::A, 0), + (TestFlags::empty(), 1), + (TestFlags::B, 1), + ], + TestFlags::remove, + TestFlags::set, + ); + + case( + TestFlags::ABC, + &[ + (TestFlags::A, 1 << 1 | 1 << 2), + (TestFlags::A | TestFlags::C, 1 << 1), + ], + TestFlags::remove, + TestFlags::set, + ); +} + +#[track_caller] +fn case( + value: T, + inputs: &[(T, T::Bits)], + mut inherent_remove: impl FnMut(&mut T, T), + mut inherent_set: impl FnMut(&mut T, T, bool), +) where + T::Bits: std::fmt::Debug + PartialEq + Copy, +{ + for (input, expected) in inputs { + assert_eq!( + *expected, + { + let mut value = value; + inherent_remove(&mut value, *input); + value + } + .bits(), + "{:?}.remove({:?})", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + Flags::remove(&mut value, *input); + value + } + .bits(), + "Flags::remove({:?}, {:?})", + value, + input + ); + + assert_eq!( + *expected, + { + let mut value = value; + inherent_set(&mut value, *input, false); + value + } + .bits(), + "{:?}.set({:?}, false)", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + Flags::set(&mut value, *input, false); + value + } + .bits(), + "Flags::set({:?}, {:?}, false)", + value, + input + ); + } +} diff --git a/vendor/bitflags/src/tests/symmetric_difference.rs b/vendor/bitflags/src/tests/symmetric_difference.rs new file mode 100644 index 0000000..75e9123 --- /dev/null +++ b/vendor/bitflags/src/tests/symmetric_difference.rs @@ -0,0 +1,110 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[ + (TestFlags::empty(), 0), + (TestFlags::all(), 1 | 1 << 1 | 1 << 2), + (TestFlags::from_bits_retain(1 << 3), 1 << 3), + ], + TestFlags::symmetric_difference, + TestFlags::toggle, + ); + + case( + TestFlags::A, + &[ + (TestFlags::empty(), 1), + (TestFlags::A, 0), + (TestFlags::all(), 1 << 1 | 1 << 2), + ], + TestFlags::symmetric_difference, + TestFlags::toggle, + ); + + case( + TestFlags::A | TestFlags::B | TestFlags::from_bits_retain(1 << 3), + &[ + (TestFlags::ABC, 1 << 2 | 1 << 3), + (TestFlags::from_bits_retain(1 << 3), 1 | 1 << 1), + ], + TestFlags::symmetric_difference, + TestFlags::toggle, + ); +} + +#[track_caller] +fn case + std::ops::BitXorAssign + Copy>( + value: T, + inputs: &[(T, T::Bits)], + mut inherent_sym_diff: impl FnMut(T, T) -> T, + mut inherent_toggle: impl FnMut(&mut T, T), +) where + T::Bits: std::fmt::Debug + PartialEq + Copy, +{ + for (input, expected) in inputs { + assert_eq!( + *expected, + inherent_sym_diff(value, *input).bits(), + "{:?}.symmetric_difference({:?})", + value, + input + ); + assert_eq!( + *expected, + Flags::symmetric_difference(value, *input).bits(), + "Flags::symmetric_difference({:?}, {:?})", + value, + input + ); + assert_eq!( + *expected, + (value ^ *input).bits(), + "{:?} ^ {:?}", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + value ^= *input; + value + } + .bits(), + "{:?} ^= {:?}", + value, + input, + ); + + assert_eq!( + *expected, + { + let mut value = value; + inherent_toggle(&mut value, *input); + value + } + .bits(), + "{:?}.toggle({:?})", + value, + input, + ); + + assert_eq!( + *expected, + { + let mut value = value; + Flags::toggle(&mut value, *input); + value + } + .bits(), + "{:?}.toggle({:?})", + value, + input, + ); + } +} diff --git a/vendor/bitflags/src/tests/union.rs b/vendor/bitflags/src/tests/union.rs new file mode 100644 index 0000000..6190681 --- /dev/null +++ b/vendor/bitflags/src/tests/union.rs @@ -0,0 +1,71 @@ +use super::*; + +use crate::Flags; + +#[test] +fn cases() { + case( + TestFlags::empty(), + &[ + (TestFlags::A, 1), + (TestFlags::all(), 1 | 1 << 1 | 1 << 2), + (TestFlags::empty(), 0), + (TestFlags::from_bits_retain(1 << 3), 1 << 3), + ], + TestFlags::union, + ); + + case( + TestFlags::A | TestFlags::C, + &[ + (TestFlags::A | TestFlags::B, 1 | 1 << 1 | 1 << 2), + (TestFlags::A, 1 | 1 << 2), + ], + TestFlags::union, + ); +} + +#[track_caller] +fn case + std::ops::BitOrAssign + Copy>( + value: T, + inputs: &[(T, T::Bits)], + mut inherent: impl FnMut(T, T) -> T, +) where + T::Bits: std::fmt::Debug + PartialEq + Copy, +{ + for (input, expected) in inputs { + assert_eq!( + *expected, + inherent(value, *input).bits(), + "{:?}.union({:?})", + value, + input + ); + assert_eq!( + *expected, + Flags::union(value, *input).bits(), + "Flags::union({:?}, {:?})", + value, + input + ); + assert_eq!( + *expected, + (value | *input).bits(), + "{:?} | {:?}", + value, + input + ); + assert_eq!( + *expected, + { + let mut value = value; + value |= *input; + value + } + .bits(), + "{:?} |= {:?}", + value, + input, + ); + } +} diff --git a/vendor/bitflags/src/traits.rs b/vendor/bitflags/src/traits.rs new file mode 100644 index 0000000..3905d7d --- /dev/null +++ b/vendor/bitflags/src/traits.rs @@ -0,0 +1,431 @@ +use core::{ + fmt, + ops::{BitAnd, BitOr, BitXor, Not}, +}; + +use crate::{ + iter, + parser::{ParseError, ParseHex, WriteHex}, +}; + +/** +A defined flags value that may be named or unnamed. +*/ +#[derive(Debug)] +pub struct Flag { + name: &'static str, + value: B, +} + +impl Flag { + /** + Define a flag. + + If `name` is non-empty then the flag is named, otherwise it's unnamed. + */ + pub const fn new(name: &'static str, value: B) -> Self { + Flag { name, value } + } + + /** + Get the name of this flag. + + If the flag is unnamed then the returned string will be empty. + */ + pub const fn name(&self) -> &'static str { + self.name + } + + /** + Get the flags value of this flag. + */ + pub const fn value(&self) -> &B { + &self.value + } + + /** + Whether the flag is named. + + If [`Flag::name`] returns a non-empty string then this method will return `true`. + */ + pub const fn is_named(&self) -> bool { + !self.name.is_empty() + } + + /** + Whether the flag is unnamed. + + If [`Flag::name`] returns a non-empty string then this method will return `false`. + */ + pub const fn is_unnamed(&self) -> bool { + self.name.is_empty() + } +} + +/** +A set of defined flags using a bits type as storage. + +## Implementing `Flags` + +This trait is implemented by the [`bitflags`](macro.bitflags.html) macro: + +``` +use bitflags::bitflags; + +bitflags! { + struct MyFlags: u8 { + const A = 1; + const B = 1 << 1; + } +} +``` + +It can also be implemented manually: + +``` +use bitflags::{Flag, Flags}; + +struct MyFlags(u8); + +impl Flags for MyFlags { + const FLAGS: &'static [Flag] = &[ + Flag::new("A", MyFlags(1)), + Flag::new("B", MyFlags(1 << 1)), + ]; + + type Bits = u8; + + fn from_bits_retain(bits: Self::Bits) -> Self { + MyFlags(bits) + } + + fn bits(&self) -> Self::Bits { + self.0 + } +} +``` + +## Using `Flags` + +The `Flags` trait can be used generically to work with any flags types. In this example, +we can count the number of defined named flags: + +``` +# use bitflags::{bitflags, Flags}; +fn defined_flags() -> usize { + F::FLAGS.iter().filter(|f| f.is_named()).count() +} + +bitflags! { + struct MyFlags: u8 { + const A = 1; + const B = 1 << 1; + const C = 1 << 2; + + const _ = !0; + } +} + +assert_eq!(3, defined_flags::()); +``` +*/ +pub trait Flags: Sized + 'static { + /// The set of defined flags. + const FLAGS: &'static [Flag]; + + /// The underlying bits type. + type Bits: Bits; + + /// Get a flags value with all bits unset. + fn empty() -> Self { + Self::from_bits_retain(Self::Bits::EMPTY) + } + + /// Get a flags value with all known bits set. + fn all() -> Self { + let mut truncated = Self::Bits::EMPTY; + + for flag in Self::FLAGS.iter() { + truncated = truncated | flag.value().bits(); + } + + Self::from_bits_retain(truncated) + } + + /// Get the underlying bits value. + /// + /// The returned value is exactly the bits set in this flags value. + fn bits(&self) -> Self::Bits; + + /// Convert from a bits value. + /// + /// This method will return `None` if any unknown bits are set. + fn from_bits(bits: Self::Bits) -> Option { + let truncated = Self::from_bits_truncate(bits); + + if truncated.bits() == bits { + Some(truncated) + } else { + None + } + } + + /// Convert from a bits value, unsetting any unknown bits. + fn from_bits_truncate(bits: Self::Bits) -> Self { + Self::from_bits_retain(bits & Self::all().bits()) + } + + /// Convert from a bits value exactly. + fn from_bits_retain(bits: Self::Bits) -> Self; + + /// Get a flags value with the bits of a flag with the given name set. + /// + /// This method will return `None` if `name` is empty or doesn't + /// correspond to any named flag. + fn from_name(name: &str) -> Option { + // Don't parse empty names as empty flags + if name.is_empty() { + return None; + } + + for flag in Self::FLAGS { + if flag.name() == name { + return Some(Self::from_bits_retain(flag.value().bits())); + } + } + + None + } + + /// Yield a set of contained flags values. + /// + /// Each yielded flags value will correspond to a defined named flag. Any unknown bits + /// will be yielded together as a final flags value. + fn iter(&self) -> iter::Iter { + iter::Iter::new(self) + } + + /// Yield a set of contained named flags values. + /// + /// This method is like [`Flags::iter`], except only yields bits in contained named flags. + /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded. + fn iter_names(&self) -> iter::IterNames { + iter::IterNames::new(self) + } + + /// Whether all bits in this flags value are unset. + fn is_empty(&self) -> bool { + self.bits() == Self::Bits::EMPTY + } + + /// Whether all known bits in this flags value are set. + fn is_all(&self) -> bool { + // NOTE: We check against `Self::all` here, not `Self::Bits::ALL` + // because the set of all flags may not use all bits + Self::all().bits() | self.bits() == self.bits() + } + + /// Whether any set bits in a source flags value are also set in a target flags value. + fn intersects(&self, other: Self) -> bool + where + Self: Sized, + { + self.bits() & other.bits() != Self::Bits::EMPTY + } + + /// Whether all set bits in a source flags value are also set in a target flags value. + fn contains(&self, other: Self) -> bool + where + Self: Sized, + { + self.bits() & other.bits() == other.bits() + } + + /// The bitwise or (`|`) of the bits in two flags values. + fn insert(&mut self, other: Self) + where + Self: Sized, + { + *self = Self::from_bits_retain(self.bits()).union(other); + } + + /// The intersection of a source flags value with the complement of a target flags value (`&!`). + /// + /// This method is not equivalent to `self & !other` when `other` has unknown bits set. + /// `remove` won't truncate `other`, but the `!` operator will. + fn remove(&mut self, other: Self) + where + Self: Sized, + { + *self = Self::from_bits_retain(self.bits()).difference(other); + } + + /// The bitwise exclusive-or (`^`) of the bits in two flags values. + fn toggle(&mut self, other: Self) + where + Self: Sized, + { + *self = Self::from_bits_retain(self.bits()).symmetric_difference(other); + } + + /// Call [`Flags::insert`] when `value` is `true` or [`Flags::remove`] when `value` is `false`. + fn set(&mut self, other: Self, value: bool) + where + Self: Sized, + { + if value { + self.insert(other); + } else { + self.remove(other); + } + } + + /// The bitwise and (`&`) of the bits in two flags values. + #[must_use] + fn intersection(self, other: Self) -> Self { + Self::from_bits_retain(self.bits() & other.bits()) + } + + /// The bitwise or (`|`) of the bits in two flags values. + #[must_use] + fn union(self, other: Self) -> Self { + Self::from_bits_retain(self.bits() | other.bits()) + } + + /// The intersection of a source flags value with the complement of a target flags value (`&!`). + /// + /// This method is not equivalent to `self & !other` when `other` has unknown bits set. + /// `difference` won't truncate `other`, but the `!` operator will. + #[must_use] + fn difference(self, other: Self) -> Self { + Self::from_bits_retain(self.bits() & !other.bits()) + } + + /// The bitwise exclusive-or (`^`) of the bits in two flags values. + #[must_use] + fn symmetric_difference(self, other: Self) -> Self { + Self::from_bits_retain(self.bits() ^ other.bits()) + } + + /// The bitwise negation (`!`) of the bits in a flags value, truncating the result. + #[must_use] + fn complement(self) -> Self { + Self::from_bits_truncate(!self.bits()) + } +} + +/** +A bits type that can be used as storage for a flags type. +*/ +pub trait Bits: + Clone + + Copy + + PartialEq + + BitAnd + + BitOr + + BitXor + + Not + + Sized + + 'static +{ + /// A value with all bits unset. + const EMPTY: Self; + + /// A value with all bits set. + const ALL: Self; +} + +// Not re-exported: prevent custom `Bits` impls being used in the `bitflags!` macro, +// or they may fail to compile based on crate features +pub trait Primitive {} + +macro_rules! impl_bits { + ($($u:ty, $i:ty,)*) => { + $( + impl Bits for $u { + const EMPTY: $u = 0; + const ALL: $u = <$u>::MAX; + } + + impl Bits for $i { + const EMPTY: $i = 0; + const ALL: $i = <$u>::MAX as $i; + } + + impl ParseHex for $u { + fn parse_hex(input: &str) -> Result { + <$u>::from_str_radix(input, 16).map_err(|_| ParseError::invalid_hex_flag(input)) + } + } + + impl ParseHex for $i { + fn parse_hex(input: &str) -> Result { + <$i>::from_str_radix(input, 16).map_err(|_| ParseError::invalid_hex_flag(input)) + } + } + + impl WriteHex for $u { + fn write_hex(&self, mut writer: W) -> fmt::Result { + write!(writer, "{:x}", self) + } + } + + impl WriteHex for $i { + fn write_hex(&self, mut writer: W) -> fmt::Result { + write!(writer, "{:x}", self) + } + } + + impl Primitive for $i {} + impl Primitive for $u {} + )* + } +} + +impl_bits! { + u8, i8, + u16, i16, + u32, i32, + u64, i64, + u128, i128, + usize, isize, +} + +/// A trait for referencing the `bitflags`-owned internal type +/// without exposing it publicly. +pub trait PublicFlags { + /// The type of the underlying storage. + type Primitive: Primitive; + + /// The type of the internal field on the generated flags type. + type Internal; +} + +#[doc(hidden)] +#[deprecated(note = "use the `Flags` trait instead")] +pub trait BitFlags: ImplementedByBitFlagsMacro + Flags { + /// An iterator over enabled flags in an instance of the type. + type Iter: Iterator; + + /// An iterator over the raw names and bits for enabled flags in an instance of the type. + type IterNames: Iterator; +} + +#[allow(deprecated)] +impl BitFlags for B { + type Iter = iter::Iter; + type IterNames = iter::IterNames; +} + +impl ImplementedByBitFlagsMacro for B {} + +/// A marker trait that signals that an implementation of `BitFlags` came from the `bitflags!` macro. +/// +/// There's nothing stopping an end-user from implementing this trait, but we don't guarantee their +/// manual implementations won't break between non-breaking releases. +#[doc(hidden)] +pub trait ImplementedByBitFlagsMacro {} + +pub(crate) mod __private { + pub use super::{ImplementedByBitFlagsMacro, PublicFlags}; +} diff --git a/vendor/kvm-bindings/.cargo-checksum.json b/vendor/kvm-bindings/.cargo-checksum.json index 9944086..6656d95 100644 --- a/vendor/kvm-bindings/.cargo-checksum.json +++ b/vendor/kvm-bindings/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"c742b232063943cfd45dd3ff7df62b0bce00784511164ab20b4017ca041a611d","CODEOWNERS":"62b997d5af358adec513e1935849d6b73e554fd4104d97a9eeff6469c9f4626a","CONTRIBUTING.md":"84f38736580c3af04df0b97cf34571e77978f43cfc489d1c8c5064bfe01baf24","Cargo.toml":"09337c66dedeb94ee13defbca7aa839c292288e98a6551c78b633b39404c70e0","LICENSE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","README.md":"18ff206a6a7e68d85a4888a059c8a41c1e0da9767b083f014283841bdb3c66d8","coverage_config_aarch64.json":"a7d2462cd08e66d5d5514f24aa0ae986e250373c5aad9efc31baa772418f2a3e","coverage_config_x86_64.json":"aa7a04c235220aeae61d8c1cd32e4137fb53655eb7a333637b12ffcdbf155da7","src/arm64/bindings.rs":"101c79b26cd3ab3e811d88d0b298e8afaef70a55dd8c6aac9537e6c470e5b037","src/arm64/fam_wrappers.rs":"2365bafdccf8277cc5d3bdc1521a99b2dc3b91078d0249db089fb5e78481b646","src/arm64/mod.rs":"9a561c94e93d18545ff7b8d6a305282b4a84b6d3d9775ef130852f620e91ef10","src/lib.rs":"2c76f28c5f3c96e2dc2fe74d75dc3277d9f78a8e4a10c63b502df7cc293c9847","src/x86/bindings.rs":"4f6804416948ed0e2ac87698792aaef150c67b9b648599f2baa16f4bed0a5561","src/x86/fam_wrappers.rs":"988b2ca59167735a6f46757cbc5895a46bdffe87f41f47b658f881c41c89e48b","src/x86/mod.rs":"ab41afcb1fad5f42d8f2f05e1c1a0058c2dd684bed220ff803ffc4472d4b1c6d"},"package":"efe70e65a5b092161d17f5005b66e5eefe7a94a70c332e755036fc4af78c4e79"} \ No newline at end of file +{"files":{"CHANGELOG.md":"bc900de5c5906a64c27a4014abfc58244e2196553703d7687ccd03acfd67a000","CODEOWNERS":"62b997d5af358adec513e1935849d6b73e554fd4104d97a9eeff6469c9f4626a","CONTRIBUTING.md":"9d1c96521cce7702a2ebabfb8c5c6097bcbb358d26afc38309f4b00e265b0749","Cargo.toml":"701c9704001b5fd5ccdfb56193bacdb4c1800e55bca2bbdfec09853116689f75","LICENSE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","README.md":"98a870b95d6a0e18f8a5680c256a6e593b49da3c99dcb553ea799d6dbdd43d5e","coverage_config_aarch64.json":"5ae2dff2fea112600df1d55965069d2989dfe14ff4c4a61b9d1365425547a80c","coverage_config_x86_64.json":"c503723b84089ef6ad8039cab4a0d772b9eb18c0e6957f9b4a226f697469e33d","src/arm64/bindings.rs":"8c0c3b89882eeaab9b1e604a8591a7eec982d40f7d58978f64cafcccdd879745","src/arm64/fam_wrappers.rs":"2365bafdccf8277cc5d3bdc1521a99b2dc3b91078d0249db089fb5e78481b646","src/arm64/mod.rs":"af4122ee21aff99afd58120c83c02a6a23568c5195e0e97fff694504c76fadc5","src/arm64/serialize.rs":"bacc64c2ba72fc3dfb9a49c3e5669afdd14fa081d85b3267f26efbe91374d12a","src/lib.rs":"4bf542d81e1b1c9a2a2ab35b15314230ad59256627a71d99423050ccd253857c","src/riscv64/bindings.rs":"fe13450d6e60236e16bcfc7cdbdc564e459e754e2a0e08f44f59bd4e65b9959d","src/riscv64/fam_wrappers.rs":"98755a7ed47a344e956c5551edb1c467ce18d7df92c0c5d1155ce407ec8ffc85","src/riscv64/mod.rs":"9a62d6e8cc256a1fea175b6242e7a6164fd2dc649bcbfcc9acf4a9b388f457d3","src/riscv64/serialize.rs":"627b6bbfcad52297efd819faf2f60af33223ab0052bd6a869aba7cf0600c5c61","src/serialize.rs":"2a607d3ad52375c125bfacea4f7d24d5ce9a02e624bb18263b8759efb6c0ee39","src/x86_64/bindings.rs":"364d0036e68049e21d4ed4520a915578846728054c78e427998d16f3cc49c1b9","src/x86_64/fam_wrappers.rs":"a1077319b084992e7da7168499d94cafc21a67d6d97729b82d967dbf46950804","src/x86_64/mod.rs":"75c69f6c067ff49f5babe43b3ab3951cc993db300da09df84b9bc8b026f01a71","src/x86_64/serialize.rs":"84d8e7ed5e440a3263cbda60cf2398afcf059fa04cc3b60e19915ead7f86c780"},"package":"fa4933174d0cc4b77b958578cd45784071cc5ae212c2d78fbd755aaaa6dfa71a"} \ No newline at end of file diff --git a/vendor/kvm-bindings/CHANGELOG.md b/vendor/kvm-bindings/CHANGELOG.md index d87e538..8b76c69 100644 --- a/vendor/kvm-bindings/CHANGELOG.md +++ b/vendor/kvm-bindings/CHANGELOG.md @@ -1,4 +1,68 @@ # Changelog +## [Unreleased] + +### Added + +### Changed + +### Removed + +## [0.10.0] + +### Added + +- RISC-V KVM bindings for Linux kernel v6.9, including serialization support. + +## [0.9.1] + +### Changed + +- Fixed and validated manual (De)Serialize implementations to work with + `serde_json` crate. + +## [0.9.0] + +### Changed + +- Replaced the v6.2 bindings of arm64, x86\_64 with the v6.9 ones. + +### Removed + +- Removed v6.2 bindings. + +## [0.8.2] + +### Changed + +- Improve performance of bindings deserialization by \~5% by avoiding + a temporary allocation. + +## [0.8.1] + +### Fixed + +- Implement `Default` for `kvm_xsave2`, which fixes usage of `Xsave` + unconditionally causing compile errors in downstream crates. + +## [0.8.0] + +### Added + +- An opt-in feature `serde` that enables [`serde`](https://serde.rs)-based + (de)serialization of various bindings. + +## [0.7.0] + +### Changed +- API change in the bindings from upstream kernel changes: + * system\_event has been made into a new union +- The x86 module has been renamed to x86\_64 for consistency (matches the kernel + architecture directory name) +- Added all features to the generated docs.rs documentation. + +### Removed + +- Dropped "x86" (32-bit) x86 support ## [0.6.0] diff --git a/vendor/kvm-bindings/CONTRIBUTING.md b/vendor/kvm-bindings/CONTRIBUTING.md index 26b39df..e275fa8 100644 --- a/vendor/kvm-bindings/CONTRIBUTING.md +++ b/vendor/kvm-bindings/CONTRIBUTING.md @@ -4,9 +4,9 @@ ### Bindgen The bindings are currently generated using -[bindgen](https://crates.io/crates/bindgen) version 0.59.1: +[bindgen](https://crates.io/crates/bindgen) version 0.64.0: ```bash -cargo install bindgen --vers 0.59.1 +cargo install bindgen-cli --vers 0.64.0 ``` ### Linux Kernel @@ -17,48 +17,50 @@ repository on your machine: git clone https://github.com/torvalds/linux.git ``` -## Add a new architecture +## Updating bindings / adding a new architecture + When adding a new architecture, the bindings must be generated for all existing versions for consistency reasons. -### Example for arm64 and version 5.13 +### Example for arm64 and kernel version 6.9 For this example we assume that you have both linux and kvm-bindings repositories in your root. ```bash -# Step 1: Create a new module using the name of the architecture in src/ -cd kvm-bindings +# Step 1 (if adding a new architecture): Create a new module using the name of the architecture in src/ +pushd kvm-bindings mkdir src/arm64 -cd ~ +popd # linux is the repository that you cloned at the previous step. -cd linux +pushd linux # Step 2: Checkout the version you want to generate the bindings for. -git checkout v5.13 +git checkout v6.9 # Step 3: Generate the bindings. # This will generate the headers for the targeted architecture and place them -# in the user specified directory. In this case, we generate them in the -# arm64_v5_13_headers directory. -make headers_install ARCH=arm64 INSTALL_HDR_PATH=arm64_v5_13_headers -cd arm64_v5_13_headers -bindgen include/linux/kvm.h -o bindings_v5_13_0.rs \ - --with-derive-default \ - --with-derive-partialeq \ - -- -Iinclude -cd ~ +# in the user specified directory + +export ARCH=arm64 +make headers_install ARCH=$ARCH INSTALL_HDR_PATH="$ARCH"_headers +pushd "$ARCH"_headers +bindgen include/linux/kvm.h -o bindings.rs \ + --impl-debug --with-derive-default \ + --with-derive-partialeq --impl-partialeq \ + -- -Iinclude +popd # Step 4: Copy the generated file to the arm64 module. -cp linux/arm64_v5_13_headers/bindings_v5_13_0.rs +popd +cp linux/"$ARCH"_headers/bindings.rs kvm-bindings/src/arm64 + ``` -Steps 2, 3 and 4 must be repeated for each of the existing KVM versions. Don't -forget to change the name of the bindings file using the appropriate version. +Steps 2, 3 and 4 must be repeated for all existing architectures. -Now that we have the bindings generated, we can copy the module file from -one of the existing modules as this is only changed when a new version is -added. +Now that we have the bindings generated, for a new architecture we can copy the +module file from one of the existing modules. ```bash cp arm/mod.rs arm64/ @@ -66,6 +68,32 @@ cp arm/mod.rs arm64/ Also, you will need to add the new architecture to `kvm-bindings/lib.rs`. +When regenerating bindings, care must be taken to re-add various `zerocopy` +derives under the `serde` feature. All items that require derives are +listed in the `x86_64/serialize.rs` and `arm64/serialize.rs` inside the +`serde_impls!` macro invocation, and missing derives will cause these +modules to fail compilation. For all items listed here, the following +derive should be present: + +```rs +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +``` + +Any types whose name contains a suffix akin to `__bindgen_ty_` and +which is contained in any struct listed in `serialize.rs` will also need +to have this derive added (otherwise compilation will fail). Note that +these types are not explicitly listed in `serialize.rs`, as their names +can change across `bindgen.rs` versions. + +Lastly, in `x86_64/bindings.rs`, the derives also need to be added to +`struct __BindgenBitfieldUnit` and `struct __IncompleteArrayField`. +Additionally, these structs need to have their layout changed from `#[repr(C)]` +to `#[repr(transparent)]`. This is needed because `zerocopy` traits can only be +derived on generic structures that are `repr(transparent)` or `repr(packed)`. + ### Future Improvements All the above steps are scriptable, so in the next iteration I will add a script to generate the bindings. diff --git a/vendor/kvm-bindings/Cargo.toml b/vendor/kvm-bindings/Cargo.toml index 6734ae3..6bc5db7 100644 --- a/vendor/kvm-bindings/Cargo.toml +++ b/vendor/kvm-bindings/Cargo.toml @@ -11,17 +11,54 @@ [package] name = "kvm-bindings" -version = "0.6.0" +version = "0.10.0" authors = ["Amazon firecracker team "] +build = false +autobins = false +autoexamples = false +autotests = false +autobenches = false description = "Rust FFI bindings to KVM generated using bindgen." readme = "README.md" keywords = ["kvm"] license = "Apache-2.0" repository = "https://github.com/rust-vmm/kvm-bindings" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "docsrs", +] + +[lib] +name = "kvm_bindings" +path = "src/lib.rs" + +[dependencies.serde] +version = "1.0.0" +features = ["derive"] +optional = true + [dependencies.vmm-sys-util] -version = "0.11.0" +version = "0.12.1" optional = true +[dependencies.zerocopy] +version = "0.7.32" +features = ["derive"] +optional = true + +[dev-dependencies.bincode] +version = "1.3.3" + +[dev-dependencies.serde_json] +version = "1.0.125" + [features] fam-wrappers = ["vmm-sys-util"] +serde = [ + "dep:serde", + "serde/derive", + "dep:zerocopy", +] diff --git a/vendor/kvm-bindings/README.md b/vendor/kvm-bindings/README.md index 4126a6b..dc83c54 100644 --- a/vendor/kvm-bindings/README.md +++ b/vendor/kvm-bindings/README.md @@ -1,14 +1,12 @@ -[![Build Status](https://travis-ci.org/rust-vmm/kvm-bindings.svg?branch=master)](https://travis-ci.org/rust-vmm/kvm-bindings) [![Crates.io](https://img.shields.io/crates/v/kvm-bindings.svg)](https://crates.io/crates/kvm-bindings) ![](https://img.shields.io/crates/l/kvm-bindings.svg) # kvm-bindings Rust FFI bindings to KVM, generated using [bindgen](https://crates.io/crates/bindgen). It currently has support for the following target architectures: -- x86 - x86_64 -- arm - arm64 +- riscv64 The bindings exported by this crate are statically generated using header files associated with a specific kernel version, and are not automatically synced with @@ -19,7 +17,7 @@ kernel version they are using. For example, the `immediate_exit` field from the capability is available. Using invalid fields or features may lead to undefined behaviour. -# Usage +## Usage First, add the following to your `Cargo.toml`: ```toml kvm-bindings = "0.3" @@ -37,7 +35,19 @@ this crate. Example: kvm-bindings = { version = "0.3", features = ["fam-wrappers"]} ``` -# Dependencies +## Dependencies The crate has an `optional` dependency to [vmm-sys-util](https://crates.io/crates/vmm-sys-util) when enabling the `fam-wrappers` feature. + +It also has an optional dependency on [`serde`](serde.rs) when enabling the +`serde` feature, to allow serialization of bindings. Serialization of +bindings happens as opaque binary blobs via [`zerocopy`](https://google.github.io/comprehensive-rust/bare-metal/useful-crates/zerocopy.html). +Due to the kernel's ABI compatibility, this means that bindings serialized +in version `x` of `kvm-bindings` can be deserialized in version `y` of the +crate, even if the bindings have had been regenerated in the meantime. + +## Regenerating Bindings + +Please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for details on how to generate the bindings +or add support for new architectures. \ No newline at end of file diff --git a/vendor/kvm-bindings/coverage_config_aarch64.json b/vendor/kvm-bindings/coverage_config_aarch64.json index 54fd8ea..df5b99f 100644 --- a/vendor/kvm-bindings/coverage_config_aarch64.json +++ b/vendor/kvm-bindings/coverage_config_aarch64.json @@ -1,5 +1,5 @@ { "coverage_score": 60.9, "exclude_path": "", - "crate_features": "fam-wrappers" + "crate_features": "fam-wrappers,serde" } diff --git a/vendor/kvm-bindings/coverage_config_x86_64.json b/vendor/kvm-bindings/coverage_config_x86_64.json index b8228fd..9011c22 100644 --- a/vendor/kvm-bindings/coverage_config_x86_64.json +++ b/vendor/kvm-bindings/coverage_config_x86_64.json @@ -1,5 +1,5 @@ { - "coverage_score": 68.3, - "exclude_path": "", - "crate_features": "fam-wrappers" + "coverage_score": 79.17, + "exclude_path": ".*bindings\\.rs", + "crate_features": "fam-wrappers,serde" } diff --git a/vendor/kvm-bindings/src/arm64/bindings.rs b/vendor/kvm-bindings/src/arm64/bindings.rs index 9159746..20c53a5 100644 --- a/vendor/kvm-bindings/src/arm64/bindings.rs +++ b/vendor/kvm-bindings/src/arm64/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.59.1 */ +/* automatically generated by rust-bindgen 0.64.0 */ #[repr(C)] #[derive(Default)] @@ -31,6 +31,7 @@ impl ::std::fmt::Debug for __IncompleteArrayField { } } pub const __BITS_PER_LONG: u32 = 64; +pub const __BITS_PER_LONG_LONG: u32 = 64; pub const __FD_SETSIZE: u32 = 1024; pub const _IOC_NRBITS: u32 = 8; pub const _IOC_TYPEBITS: u32 = 8; @@ -78,6 +79,8 @@ pub const PSCI_0_2_AFFINITY_LEVEL_ON_PENDING: u32 = 2; pub const PSCI_0_2_TOS_UP_MIGRATE: u32 = 0; pub const PSCI_0_2_TOS_UP_NO_MIGRATE: u32 = 1; pub const PSCI_0_2_TOS_MP: u32 = 2; +pub const PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET: u32 = 0; +pub const PSCI_1_1_RESET_TYPE_VENDOR_START: u32 = 2147483648; pub const PSCI_VERSION_MAJOR_SHIFT: u32 = 16; pub const PSCI_VERSION_MINOR_MASK: u32 = 65535; pub const PSCI_VERSION_MAJOR_MASK: i32 = -65536; @@ -146,6 +149,50 @@ pub const HWCAP2_DGH: u32 = 32768; pub const HWCAP2_RNG: u32 = 65536; pub const HWCAP2_BTI: u32 = 131072; pub const HWCAP2_MTE: u32 = 262144; +pub const HWCAP2_ECV: u32 = 524288; +pub const HWCAP2_AFP: u32 = 1048576; +pub const HWCAP2_RPRES: u32 = 2097152; +pub const HWCAP2_MTE3: u32 = 4194304; +pub const HWCAP2_SME: u32 = 8388608; +pub const HWCAP2_SME_I16I64: u32 = 16777216; +pub const HWCAP2_SME_F64F64: u32 = 33554432; +pub const HWCAP2_SME_I8I32: u32 = 67108864; +pub const HWCAP2_SME_F16F32: u32 = 134217728; +pub const HWCAP2_SME_B16F32: u32 = 268435456; +pub const HWCAP2_SME_F32F32: u32 = 536870912; +pub const HWCAP2_SME_FA64: u32 = 1073741824; +pub const HWCAP2_WFXT: u32 = 2147483648; +pub const HWCAP2_EBF16: u64 = 4294967296; +pub const HWCAP2_SVE_EBF16: u64 = 8589934592; +pub const HWCAP2_CSSC: u64 = 17179869184; +pub const HWCAP2_RPRFM: u64 = 34359738368; +pub const HWCAP2_SVE2P1: u64 = 68719476736; +pub const HWCAP2_SME2: u64 = 137438953472; +pub const HWCAP2_SME2P1: u64 = 274877906944; +pub const HWCAP2_SME_I16I32: u64 = 549755813888; +pub const HWCAP2_SME_BI32I32: u64 = 1099511627776; +pub const HWCAP2_SME_B16B16: u64 = 2199023255552; +pub const HWCAP2_SME_F16F16: u64 = 4398046511104; +pub const HWCAP2_MOPS: u64 = 8796093022208; +pub const HWCAP2_HBC: u64 = 17592186044416; +pub const HWCAP2_SVE_B16B16: u64 = 35184372088832; +pub const HWCAP2_LRCPC3: u64 = 70368744177664; +pub const HWCAP2_LSE128: u64 = 140737488355328; +pub const HWCAP2_FPMR: u64 = 281474976710656; +pub const HWCAP2_LUT: u64 = 562949953421312; +pub const HWCAP2_FAMINMAX: u64 = 1125899906842624; +pub const HWCAP2_F8CVT: u64 = 2251799813685248; +pub const HWCAP2_F8FMA: u64 = 4503599627370496; +pub const HWCAP2_F8DP4: u64 = 9007199254740992; +pub const HWCAP2_F8DP2: u64 = 18014398509481984; +pub const HWCAP2_F8E4M3: u64 = 36028797018963968; +pub const HWCAP2_F8E5M2: u64 = 72057594037927936; +pub const HWCAP2_SME_LUTV2: u64 = 144115188075855872; +pub const HWCAP2_SME_F8F16: u64 = 288230376151711744; +pub const HWCAP2_SME_F8F32: u64 = 576460752303423488; +pub const HWCAP2_SME_SF8FMA: u64 = 1152921504606846976; +pub const HWCAP2_SME_SF8DP4: u64 = 2305843009213693952; +pub const HWCAP2_SME_SF8DP2: u64 = 4611686018427387904; pub const __SVE_VQ_BYTES: u32 = 16; pub const __SVE_VQ_MIN: u32 = 1; pub const __SVE_VQ_MAX: u32 = 512; @@ -195,7 +242,10 @@ pub const SVE_PT_REGS_FPSIMD: u32 = 0; pub const SVE_PT_REGS_SVE: u32 = 1; pub const SVE_PT_VL_INHERIT: u32 = 2; pub const SVE_PT_VL_ONEXEC: u32 = 4; +pub const ZA_PT_VL_INHERIT: u32 = 2; +pub const ZA_PT_VL_ONEXEC: u32 = 4; pub const KVM_COALESCED_MMIO_PAGE_OFFSET: u32 = 1; +pub const KVM_DIRTY_LOG_PAGE_OFFSET: u32 = 64; pub const KVM_ARM_TARGET_AEM_V8: u32 = 0; pub const KVM_ARM_TARGET_FOUNDATION_V8: u32 = 1; pub const KVM_ARM_TARGET_CORTEX_A57: u32 = 2; @@ -204,9 +254,7 @@ pub const KVM_ARM_TARGET_CORTEX_A53: u32 = 4; pub const KVM_ARM_TARGET_GENERIC_V8: u32 = 5; pub const KVM_ARM_NUM_TARGETS: u32 = 6; pub const KVM_ARM_DEVICE_TYPE_SHIFT: u32 = 0; -pub const KVM_ARM_DEVICE_TYPE_MASK: u32 = 65535; pub const KVM_ARM_DEVICE_ID_SHIFT: u32 = 16; -pub const KVM_ARM_DEVICE_ID_MASK: u32 = 4294901760; pub const KVM_ARM_DEVICE_VGIC_V2: u32 = 0; pub const KVM_VGIC_V2_ADDR_TYPE_DIST: u32 = 0; pub const KVM_VGIC_V2_ADDR_TYPE_CPU: u32 = 1; @@ -223,11 +271,18 @@ pub const KVM_ARM_VCPU_PMU_V3: u32 = 3; pub const KVM_ARM_VCPU_SVE: u32 = 4; pub const KVM_ARM_VCPU_PTRAUTH_ADDRESS: u32 = 5; pub const KVM_ARM_VCPU_PTRAUTH_GENERIC: u32 = 6; +pub const KVM_ARM_VCPU_HAS_EL2: u32 = 7; pub const KVM_ARM_MAX_DBG_REGS: u32 = 16; +pub const KVM_DEBUG_ARCH_HSR_HIGH_VALID: u32 = 1; pub const KVM_GUESTDBG_USE_SW_BP: u32 = 65536; pub const KVM_GUESTDBG_USE_HW: u32 = 131072; +pub const KVM_ARM_DEV_EL1_VTIMER: u32 = 1; +pub const KVM_ARM_DEV_EL1_PTIMER: u32 = 2; +pub const KVM_ARM_DEV_PMU: u32 = 4; pub const KVM_PMU_EVENT_ALLOW: u32 = 0; pub const KVM_PMU_EVENT_DENY: u32 = 1; +pub const KVM_ARM_TAGS_TO_GUEST: u32 = 0; +pub const KVM_ARM_TAGS_FROM_GUEST: u32 = 1; pub const KVM_REG_ARM_COPROC_MASK: u32 = 268369920; pub const KVM_REG_ARM_COPROC_SHIFT: u32 = 16; pub const KVM_REG_ARM_CORE: u32 = 1048576; @@ -257,6 +312,9 @@ pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN: u32 = 1; pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_AVAIL: u32 = 2; pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED: u32 = 3; pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED: u32 = 16; +pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_AVAIL: u32 = 0; +pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_AVAIL: u32 = 1; +pub const KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_REQUIRED: u32 = 2; pub const KVM_REG_ARM64_SVE: u32 = 1376256; pub const KVM_REG_ARM64_SVE_ZREG_BASE: u32 = 0; pub const KVM_REG_ARM64_SVE_PREG_BASE: u32 = 1024; @@ -267,6 +325,9 @@ pub const KVM_ARM64_SVE_MAX_SLICES: u32 = 32; pub const KVM_ARM64_SVE_VQ_MIN: u32 = 1; pub const KVM_ARM64_SVE_VQ_MAX: u32 = 512; pub const KVM_ARM64_SVE_VLS_WORDS: u32 = 8; +pub const KVM_REG_ARM_FW_FEAT_BMAP: u32 = 1441792; +pub const KVM_ARM_VM_SMCCC_CTRL: u32 = 0; +pub const KVM_ARM_VM_SMCCC_FILTER: u32 = 0; pub const KVM_DEV_ARM_VGIC_GRP_ADDR: u32 = 0; pub const KVM_DEV_ARM_VGIC_GRP_DIST_REGS: u32 = 1; pub const KVM_DEV_ARM_VGIC_GRP_CPU_REGS: u32 = 2; @@ -296,9 +357,12 @@ pub const KVM_ARM_VCPU_PMU_V3_CTRL: u32 = 0; pub const KVM_ARM_VCPU_PMU_V3_IRQ: u32 = 0; pub const KVM_ARM_VCPU_PMU_V3_INIT: u32 = 1; pub const KVM_ARM_VCPU_PMU_V3_FILTER: u32 = 2; +pub const KVM_ARM_VCPU_PMU_V3_SET_PMU: u32 = 3; pub const KVM_ARM_VCPU_TIMER_CTRL: u32 = 1; pub const KVM_ARM_VCPU_TIMER_IRQ_VTIMER: u32 = 0; pub const KVM_ARM_VCPU_TIMER_IRQ_PTIMER: u32 = 1; +pub const KVM_ARM_VCPU_TIMER_IRQ_HVTIMER: u32 = 2; +pub const KVM_ARM_VCPU_TIMER_IRQ_HPTIMER: u32 = 3; pub const KVM_ARM_VCPU_PVTIME_CTRL: u32 = 2; pub const KVM_ARM_VCPU_PVTIME_IPA: u32 = 0; pub const KVM_ARM_IRQ_VCPU2_SHIFT: u32 = 28; @@ -321,44 +385,17 @@ pub const KVM_PSCI_RET_SUCCESS: u32 = 0; pub const KVM_PSCI_RET_NI: i32 = -1; pub const KVM_PSCI_RET_INVAL: i32 = -2; pub const KVM_PSCI_RET_DENIED: i32 = -3; +pub const KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2: u32 = 1; +pub const KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED: u32 = 1; +pub const KVM_HYPERCALL_EXIT_SMC: u32 = 1; +pub const KVM_HYPERCALL_EXIT_16BIT: u32 = 2; +pub const KVM_ARM_FEATURE_ID_RANGE: u32 = 0; +pub const KVM_ARM_FEATURE_ID_RANGE_SIZE: u32 = 192; pub const KVM_API_VERSION: u32 = 12; -pub const KVM_TRC_SHIFT: u32 = 16; -pub const KVM_TRC_ENTRYEXIT: u32 = 65536; -pub const KVM_TRC_HANDLER: u32 = 131072; -pub const KVM_TRC_VMENTRY: u32 = 65537; -pub const KVM_TRC_VMEXIT: u32 = 65538; -pub const KVM_TRC_PAGE_FAULT: u32 = 131073; -pub const KVM_TRC_HEAD_SIZE: u32 = 12; -pub const KVM_TRC_CYCLE_SIZE: u32 = 8; -pub const KVM_TRC_EXTRA_MAX: u32 = 7; -pub const KVM_TRC_INJ_VIRQ: u32 = 131074; -pub const KVM_TRC_REDELIVER_EVT: u32 = 131075; -pub const KVM_TRC_PEND_INTR: u32 = 131076; -pub const KVM_TRC_IO_READ: u32 = 131077; -pub const KVM_TRC_IO_WRITE: u32 = 131078; -pub const KVM_TRC_CR_READ: u32 = 131079; -pub const KVM_TRC_CR_WRITE: u32 = 131080; -pub const KVM_TRC_DR_READ: u32 = 131081; -pub const KVM_TRC_DR_WRITE: u32 = 131082; -pub const KVM_TRC_MSR_READ: u32 = 131083; -pub const KVM_TRC_MSR_WRITE: u32 = 131084; -pub const KVM_TRC_CPUID: u32 = 131085; -pub const KVM_TRC_INTR: u32 = 131086; -pub const KVM_TRC_NMI: u32 = 131087; -pub const KVM_TRC_VMMCALL: u32 = 131088; -pub const KVM_TRC_HLT: u32 = 131089; -pub const KVM_TRC_CLTS: u32 = 131090; -pub const KVM_TRC_LMSW: u32 = 131091; -pub const KVM_TRC_APIC_ACCESS: u32 = 131092; -pub const KVM_TRC_TDP_FAULT: u32 = 131093; -pub const KVM_TRC_GTLB_WRITE: u32 = 131094; -pub const KVM_TRC_STLB_WRITE: u32 = 131095; -pub const KVM_TRC_STLB_INVAL: u32 = 131096; -pub const KVM_TRC_PPC_INSTR: u32 = 131097; pub const KVM_MEM_LOG_DIRTY_PAGES: u32 = 1; pub const KVM_MEM_READONLY: u32 = 2; +pub const KVM_MEM_GUEST_MEMFD: u32 = 4; pub const KVM_PIT_SPEAKER_DUMMY: u32 = 1; -pub const KVM_S390_CMMA_PEEK: u32 = 1; pub const KVM_EXIT_HYPERV_SYNIC: u32 = 1; pub const KVM_EXIT_HYPERV_HCALL: u32 = 2; pub const KVM_EXIT_HYPERV_SYNDBG: u32 = 3; @@ -400,30 +437,31 @@ pub const KVM_EXIT_DIRTY_RING_FULL: u32 = 31; pub const KVM_EXIT_AP_RESET_HOLD: u32 = 32; pub const KVM_EXIT_X86_BUS_LOCK: u32 = 33; pub const KVM_EXIT_XEN: u32 = 34; +pub const KVM_EXIT_RISCV_SBI: u32 = 35; +pub const KVM_EXIT_RISCV_CSR: u32 = 36; +pub const KVM_EXIT_NOTIFY: u32 = 37; +pub const KVM_EXIT_LOONGARCH_IOCSR: u32 = 38; +pub const KVM_EXIT_MEMORY_FAULT: u32 = 39; pub const KVM_INTERNAL_ERROR_EMULATION: u32 = 1; pub const KVM_INTERNAL_ERROR_SIMUL_EX: u32 = 2; pub const KVM_INTERNAL_ERROR_DELIVERY_EV: u32 = 3; pub const KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON: u32 = 4; +pub const KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES: u32 = 1; pub const KVM_EXIT_IO_IN: u32 = 0; pub const KVM_EXIT_IO_OUT: u32 = 1; -pub const KVM_S390_RESET_POR: u32 = 1; -pub const KVM_S390_RESET_CLEAR: u32 = 2; -pub const KVM_S390_RESET_SUBSYSTEM: u32 = 4; -pub const KVM_S390_RESET_CPU_INIT: u32 = 8; -pub const KVM_S390_RESET_IPL: u32 = 16; pub const KVM_SYSTEM_EVENT_SHUTDOWN: u32 = 1; pub const KVM_SYSTEM_EVENT_RESET: u32 = 2; pub const KVM_SYSTEM_EVENT_CRASH: u32 = 3; +pub const KVM_SYSTEM_EVENT_WAKEUP: u32 = 4; +pub const KVM_SYSTEM_EVENT_SUSPEND: u32 = 5; +pub const KVM_SYSTEM_EVENT_SEV_TERM: u32 = 6; pub const KVM_MSR_EXIT_REASON_INVAL: u32 = 1; pub const KVM_MSR_EXIT_REASON_UNKNOWN: u32 = 2; pub const KVM_MSR_EXIT_REASON_FILTER: u32 = 4; +pub const KVM_MSR_EXIT_REASON_VALID_MASK: u32 = 7; +pub const KVM_NOTIFY_CONTEXT_INVALID: u32 = 1; +pub const KVM_MEMORY_EXIT_FLAG_PRIVATE: u32 = 8; pub const SYNC_REGS_SIZE_BYTES: u32 = 2048; -pub const KVM_S390_MEMOP_LOGICAL_READ: u32 = 0; -pub const KVM_S390_MEMOP_LOGICAL_WRITE: u32 = 1; -pub const KVM_S390_MEMOP_SIDA_READ: u32 = 2; -pub const KVM_S390_MEMOP_SIDA_WRITE: u32 = 3; -pub const KVM_S390_MEMOP_F_CHECK_ONLY: u32 = 1; -pub const KVM_S390_MEMOP_F_INJECT_EXCEPTION: u32 = 2; pub const KVM_MP_STATE_RUNNABLE: u32 = 0; pub const KVM_MP_STATE_UNINITIALIZED: u32 = 1; pub const KVM_MP_STATE_INIT_RECEIVED: u32 = 2; @@ -434,28 +472,7 @@ pub const KVM_MP_STATE_CHECK_STOP: u32 = 6; pub const KVM_MP_STATE_OPERATING: u32 = 7; pub const KVM_MP_STATE_LOAD: u32 = 8; pub const KVM_MP_STATE_AP_RESET_HOLD: u32 = 9; -pub const KVM_S390_SIGP_STOP: u32 = 4294836224; -pub const KVM_S390_PROGRAM_INT: u32 = 4294836225; -pub const KVM_S390_SIGP_SET_PREFIX: u32 = 4294836226; -pub const KVM_S390_RESTART: u32 = 4294836227; -pub const KVM_S390_INT_PFAULT_INIT: u32 = 4294836228; -pub const KVM_S390_INT_PFAULT_DONE: u32 = 4294836229; -pub const KVM_S390_MCHK: u32 = 4294840320; -pub const KVM_S390_INT_CLOCK_COMP: u32 = 4294905860; -pub const KVM_S390_INT_CPU_TIMER: u32 = 4294905861; -pub const KVM_S390_INT_VIRTIO: u32 = 4294911491; -pub const KVM_S390_INT_SERVICE: u32 = 4294910977; -pub const KVM_S390_INT_EMERGENCY: u32 = 4294906369; -pub const KVM_S390_INT_EXTERNAL_CALL: u32 = 4294906370; -pub const KVM_S390_INT_IO_MIN: u32 = 0; -pub const KVM_S390_INT_IO_MAX: u32 = 4294836223; -pub const KVM_S390_INT_IO_AI_MASK: u32 = 67108864; -pub const KVM_S390_PGM_FLAGS_ILC_VALID: u32 = 1; -pub const KVM_S390_PGM_FLAGS_ILC_0: u32 = 2; -pub const KVM_S390_PGM_FLAGS_ILC_1: u32 = 4; -pub const KVM_S390_PGM_FLAGS_ILC_MASK: u32 = 6; -pub const KVM_S390_PGM_FLAGS_NO_REWIND: u32 = 8; -pub const KVM_S390_STOP_FLAG_STORE_STATUS: u32 = 1; +pub const KVM_MP_STATE_SUSPENDED: u32 = 10; pub const KVM_GUESTDBG_ENABLE: u32 = 1; pub const KVM_GUESTDBG_SINGLESTEP: u32 = 2; pub const KVM_X86_DISABLE_EXITS_MWAIT: u32 = 1; @@ -463,11 +480,6 @@ pub const KVM_X86_DISABLE_EXITS_HLT: u32 = 2; pub const KVM_X86_DISABLE_EXITS_PAUSE: u32 = 4; pub const KVM_X86_DISABLE_EXITS_CSTATE: u32 = 8; pub const KVM_X86_DISABLE_VALID_EXITS: u32 = 15; -pub const KVM_PPC_PVINFO_FLAGS_EV_IDLE: u32 = 1; -pub const KVM_PPC_PAGE_SIZES_MAX_SZ: u32 = 8; -pub const KVM_PPC_PAGE_SIZES_REAL: u32 = 1; -pub const KVM_PPC_1T_SEGMENTS: u32 = 2; -pub const KVM_PPC_NO_HASH: u32 = 4; pub const KVMIO: u32 = 174; pub const KVM_VM_S390_UCONTROL: u32 = 1; pub const KVM_VM_PPC_HV: u32 = 1; @@ -662,13 +674,53 @@ pub const KVM_CAP_SET_GUEST_DEBUG2: u32 = 195; pub const KVM_CAP_SGX_ATTRIBUTE: u32 = 196; pub const KVM_CAP_VM_COPY_ENC_CONTEXT_FROM: u32 = 197; pub const KVM_CAP_PTP_KVM: u32 = 198; +pub const KVM_CAP_HYPERV_ENFORCE_CPUID: u32 = 199; +pub const KVM_CAP_SREGS2: u32 = 200; +pub const KVM_CAP_EXIT_HYPERCALL: u32 = 201; +pub const KVM_CAP_PPC_RPT_INVALIDATE: u32 = 202; +pub const KVM_CAP_BINARY_STATS_FD: u32 = 203; +pub const KVM_CAP_EXIT_ON_EMULATION_FAILURE: u32 = 204; +pub const KVM_CAP_ARM_MTE: u32 = 205; +pub const KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM: u32 = 206; +pub const KVM_CAP_VM_GPA_BITS: u32 = 207; +pub const KVM_CAP_XSAVE2: u32 = 208; +pub const KVM_CAP_SYS_ATTRIBUTES: u32 = 209; +pub const KVM_CAP_PPC_AIL_MODE_3: u32 = 210; +pub const KVM_CAP_S390_MEM_OP_EXTENSION: u32 = 211; +pub const KVM_CAP_PMU_CAPABILITY: u32 = 212; +pub const KVM_CAP_DISABLE_QUIRKS2: u32 = 213; +pub const KVM_CAP_VM_TSC_CONTROL: u32 = 214; +pub const KVM_CAP_SYSTEM_EVENT_DATA: u32 = 215; +pub const KVM_CAP_ARM_SYSTEM_SUSPEND: u32 = 216; +pub const KVM_CAP_S390_PROTECTED_DUMP: u32 = 217; +pub const KVM_CAP_X86_TRIPLE_FAULT_EVENT: u32 = 218; +pub const KVM_CAP_X86_NOTIFY_VMEXIT: u32 = 219; +pub const KVM_CAP_VM_DISABLE_NX_HUGE_PAGES: u32 = 220; +pub const KVM_CAP_S390_ZPCI_OP: u32 = 221; +pub const KVM_CAP_S390_CPU_TOPOLOGY: u32 = 222; +pub const KVM_CAP_DIRTY_LOG_RING_ACQ_REL: u32 = 223; +pub const KVM_CAP_S390_PROTECTED_ASYNC_DISABLE: u32 = 224; +pub const KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP: u32 = 225; +pub const KVM_CAP_PMU_EVENT_MASKED_EVENTS: u32 = 226; +pub const KVM_CAP_COUNTER_OFFSET: u32 = 227; +pub const KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE: u32 = 228; +pub const KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES: u32 = 229; +pub const KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES: u32 = 230; +pub const KVM_CAP_USER_MEMORY2: u32 = 231; +pub const KVM_CAP_MEMORY_FAULT_INFO: u32 = 232; +pub const KVM_CAP_MEMORY_ATTRIBUTES: u32 = 233; +pub const KVM_CAP_GUEST_MEMFD: u32 = 234; +pub const KVM_CAP_VM_TYPES: u32 = 235; pub const KVM_IRQ_ROUTING_IRQCHIP: u32 = 1; pub const KVM_IRQ_ROUTING_MSI: u32 = 2; pub const KVM_IRQ_ROUTING_S390_ADAPTER: u32 = 3; pub const KVM_IRQ_ROUTING_HV_SINT: u32 = 4; +pub const KVM_IRQ_ROUTING_XEN_EVTCHN: u32 = 5; pub const KVM_IRQFD_FLAG_DEASSIGN: u32 = 1; pub const KVM_IRQFD_FLAG_RESAMPLE: u32 = 2; pub const KVM_CLOCK_TSC_STABLE: u32 = 2; +pub const KVM_CLOCK_REALTIME: u32 = 4; +pub const KVM_CLOCK_HOST_TSC: u32 = 8; pub const KVM_MMU_FSL_BOOKE_NOHV: u32 = 0; pub const KVM_MMU_FSL_BOOKE_HV: u32 = 1; pub const KVM_REG_ARCH_MASK: i64 = -72057594037927936; @@ -681,6 +733,7 @@ pub const KVM_REG_S390: u64 = 5764607523034234880; pub const KVM_REG_ARM64: u64 = 6917529027641081856; pub const KVM_REG_MIPS: u64 = 8070450532247928832; pub const KVM_REG_RISCV: i64 = -9223372036854775808; +pub const KVM_REG_LOONGARCH: i64 = -8070450532247928832; pub const KVM_REG_SIZE_SHIFT: u32 = 52; pub const KVM_REG_SIZE_MASK: u64 = 67553994410557440; pub const KVM_REG_SIZE_U8: u32 = 0; @@ -694,46 +747,45 @@ pub const KVM_REG_SIZE_U1024: u64 = 31525197391593472; pub const KVM_REG_SIZE_U2048: u64 = 36028797018963968; pub const KVM_MSI_VALID_DEVID: u32 = 1; pub const KVM_CREATE_DEVICE_TEST: u32 = 1; +pub const KVM_DEV_VFIO_FILE: u32 = 1; +pub const KVM_DEV_VFIO_FILE_ADD: u32 = 1; +pub const KVM_DEV_VFIO_FILE_DEL: u32 = 2; pub const KVM_DEV_VFIO_GROUP: u32 = 1; pub const KVM_DEV_VFIO_GROUP_ADD: u32 = 1; pub const KVM_DEV_VFIO_GROUP_DEL: u32 = 2; pub const KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE: u32 = 3; pub const KVM_S390_STORE_STATUS_NOADDR: i32 = -1; pub const KVM_S390_STORE_STATUS_PREFIXED: i32 = -2; -pub const KVM_XEN_ATTR_TYPE_LONG_MODE: u32 = 0; -pub const KVM_XEN_ATTR_TYPE_SHARED_INFO: u32 = 1; -pub const KVM_XEN_ATTR_TYPE_UPCALL_VECTOR: u32 = 2; -pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO: u32 = 0; -pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO: u32 = 1; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR: u32 = 2; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT: u32 = 3; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA: u32 = 4; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST: u32 = 5; -pub const KVM_DEV_ASSIGN_ENABLE_IOMMU: u32 = 1; -pub const KVM_DEV_ASSIGN_PCI_2_3: u32 = 2; -pub const KVM_DEV_ASSIGN_MASK_INTX: u32 = 4; -pub const KVM_DEV_IRQ_HOST_INTX: u32 = 1; -pub const KVM_DEV_IRQ_HOST_MSI: u32 = 2; -pub const KVM_DEV_IRQ_HOST_MSIX: u32 = 4; -pub const KVM_DEV_IRQ_GUEST_INTX: u32 = 256; -pub const KVM_DEV_IRQ_GUEST_MSI: u32 = 512; -pub const KVM_DEV_IRQ_GUEST_MSIX: u32 = 1024; -pub const KVM_DEV_IRQ_HOST_MASK: u32 = 255; -pub const KVM_DEV_IRQ_GUEST_MASK: u32 = 65280; -pub const KVM_MAX_MSIX_PER_DEV: u32 = 256; -pub const KVM_X2APIC_API_USE_32BIT_IDS: u32 = 1; -pub const KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK: u32 = 2; -pub const KVM_ARM_DEV_EL1_VTIMER: u32 = 1; -pub const KVM_ARM_DEV_EL1_PTIMER: u32 = 2; -pub const KVM_ARM_DEV_PMU: u32 = 4; -pub const KVM_HYPERV_CONN_ID_MASK: u32 = 16777215; -pub const KVM_HYPERV_EVENTFD_DEASSIGN: u32 = 1; pub const KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE: u32 = 1; pub const KVM_DIRTY_LOG_INITIALLY_SET: u32 = 2; -pub const KVM_DIRTY_LOG_PAGE_OFFSET: u32 = 0; pub const KVM_DIRTY_GFN_F_MASK: u32 = 3; pub const KVM_BUS_LOCK_DETECTION_OFF: u32 = 1; pub const KVM_BUS_LOCK_DETECTION_EXIT: u32 = 2; +pub const KVM_PMU_CAP_DISABLE: u32 = 1; +pub const KVM_STATS_TYPE_SHIFT: u32 = 0; +pub const KVM_STATS_TYPE_MASK: u32 = 15; +pub const KVM_STATS_TYPE_CUMULATIVE: u32 = 0; +pub const KVM_STATS_TYPE_INSTANT: u32 = 1; +pub const KVM_STATS_TYPE_PEAK: u32 = 2; +pub const KVM_STATS_TYPE_LINEAR_HIST: u32 = 3; +pub const KVM_STATS_TYPE_LOG_HIST: u32 = 4; +pub const KVM_STATS_TYPE_MAX: u32 = 4; +pub const KVM_STATS_UNIT_SHIFT: u32 = 4; +pub const KVM_STATS_UNIT_MASK: u32 = 240; +pub const KVM_STATS_UNIT_NONE: u32 = 0; +pub const KVM_STATS_UNIT_BYTES: u32 = 16; +pub const KVM_STATS_UNIT_SECONDS: u32 = 32; +pub const KVM_STATS_UNIT_CYCLES: u32 = 48; +pub const KVM_STATS_UNIT_BOOLEAN: u32 = 64; +pub const KVM_STATS_UNIT_MAX: u32 = 64; +pub const KVM_STATS_BASE_SHIFT: u32 = 8; +pub const KVM_STATS_BASE_MASK: u32 = 3840; +pub const KVM_STATS_BASE_POW10: u32 = 0; +pub const KVM_STATS_BASE_POW2: u32 = 256; +pub const KVM_STATS_BASE_MAX: u32 = 256; +pub const KVM_X86_NOTIFY_VMEXIT_ENABLED: u32 = 1; +pub const KVM_X86_NOTIFY_VMEXIT_USER: u32 = 2; +pub const KVM_MEMORY_ATTRIBUTE_PRIVATE: u32 = 8; pub type __s8 = ::std::os::raw::c_schar; pub type __u8 = ::std::os::raw::c_uchar; pub type __s16 = ::std::os::raw::c_short; @@ -749,6 +801,8 @@ pub struct __kernel_fd_set { } #[test] fn bindgen_test_layout___kernel_fd_set() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fd_set> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<__kernel_fd_set>(), 128usize, @@ -760,7 +814,7 @@ fn bindgen_test_layout___kernel_fd_set() { concat!("Alignment of ", stringify!(__kernel_fd_set)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<__kernel_fd_set>())).fds_bits as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -799,6 +853,8 @@ pub struct __kernel_fsid_t { } #[test] fn bindgen_test_layout___kernel_fsid_t() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fsid_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<__kernel_fsid_t>(), 8usize, @@ -810,7 +866,7 @@ fn bindgen_test_layout___kernel_fsid_t() { concat!("Alignment of ", stringify!(__kernel_fsid_t)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<__kernel_fsid_t>())).val as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -831,6 +887,8 @@ pub type __kernel_clockid_t = ::std::os::raw::c_int; pub type __kernel_caddr_t = *mut ::std::os::raw::c_char; pub type __kernel_uid16_t = ::std::os::raw::c_ushort; pub type __kernel_gid16_t = ::std::os::raw::c_ushort; +pub type __s128 = i128; +pub type __u128 = u128; pub type __le16 = __u16; pub type __be16 = __u16; pub type __le32 = __u32; @@ -842,6 +900,10 @@ pub type __wsum = __u32; pub type __poll_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct user_pt_regs { pub regs: [__u64; 31usize], pub sp: __u64, @@ -850,6 +912,8 @@ pub struct user_pt_regs { } #[test] fn bindgen_test_layout_user_pt_regs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 272usize, @@ -861,7 +925,7 @@ fn bindgen_test_layout_user_pt_regs() { concat!("Alignment of ", stringify!(user_pt_regs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -871,7 +935,7 @@ fn bindgen_test_layout_user_pt_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sp as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sp) as usize - ptr as usize }, 248usize, concat!( "Offset of field: ", @@ -881,7 +945,7 @@ fn bindgen_test_layout_user_pt_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pc as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pc) as usize - ptr as usize }, 256usize, concat!( "Offset of field: ", @@ -891,7 +955,7 @@ fn bindgen_test_layout_user_pt_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pstate as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pstate) as usize - ptr as usize }, 264usize, concat!( "Offset of field: ", @@ -904,6 +968,10 @@ fn bindgen_test_layout_user_pt_regs() { #[repr(C)] #[repr(align(16))] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct user_fpsimd_state { pub vregs: [__uint128_t; 32usize], pub fpsr: __u32, @@ -912,6 +980,8 @@ pub struct user_fpsimd_state { } #[test] fn bindgen_test_layout_user_fpsimd_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 528usize, @@ -923,7 +993,7 @@ fn bindgen_test_layout_user_fpsimd_state() { concat!("Alignment of ", stringify!(user_fpsimd_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vregs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vregs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -933,7 +1003,7 @@ fn bindgen_test_layout_user_fpsimd_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fpsr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fpsr) as usize - ptr as usize }, 512usize, concat!( "Offset of field: ", @@ -943,7 +1013,7 @@ fn bindgen_test_layout_user_fpsimd_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fpcr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fpcr) as usize - ptr as usize }, 516usize, concat!( "Offset of field: ", @@ -953,7 +1023,7 @@ fn bindgen_test_layout_user_fpsimd_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).__reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).__reserved) as usize - ptr as usize }, 520usize, concat!( "Offset of field: ", @@ -979,6 +1049,9 @@ pub struct user_hwdebug_state__bindgen_ty_1 { } #[test] fn bindgen_test_layout_user_hwdebug_state__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -993,9 +1066,7 @@ fn bindgen_test_layout_user_hwdebug_state__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1005,9 +1076,7 @@ fn bindgen_test_layout_user_hwdebug_state__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ctrl as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ctrl) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1017,9 +1086,7 @@ fn bindgen_test_layout_user_hwdebug_state__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -1031,6 +1098,8 @@ fn bindgen_test_layout_user_hwdebug_state__bindgen_ty_1() { } #[test] fn bindgen_test_layout_user_hwdebug_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 264usize, @@ -1042,7 +1111,7 @@ fn bindgen_test_layout_user_hwdebug_state() { concat!("Alignment of ", stringify!(user_hwdebug_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dbg_info as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dbg_info) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1052,7 +1121,7 @@ fn bindgen_test_layout_user_hwdebug_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1062,7 +1131,7 @@ fn bindgen_test_layout_user_hwdebug_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dbg_regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dbg_regs) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1084,6 +1153,8 @@ pub struct user_sve_header { } #[test] fn bindgen_test_layout_user_sve_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1095,7 +1166,7 @@ fn bindgen_test_layout_user_sve_header() { concat!("Alignment of ", stringify!(user_sve_header)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1105,7 +1176,7 @@ fn bindgen_test_layout_user_sve_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_size) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1115,7 +1186,7 @@ fn bindgen_test_layout_user_sve_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vl) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1125,7 +1196,7 @@ fn bindgen_test_layout_user_sve_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_vl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_vl) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -1135,7 +1206,7 @@ fn bindgen_test_layout_user_sve_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -1145,7 +1216,7 @@ fn bindgen_test_layout_user_sve_header() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).__reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).__reserved) as usize - ptr as usize }, 14usize, concat!( "Offset of field: ", @@ -1163,6 +1234,8 @@ pub struct user_pac_mask { } #[test] fn bindgen_test_layout_user_pac_mask() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1174,7 +1247,7 @@ fn bindgen_test_layout_user_pac_mask() { concat!("Alignment of ", stringify!(user_pac_mask)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_mask as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data_mask) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1184,7 +1257,7 @@ fn bindgen_test_layout_user_pac_mask() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).insn_mask as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).insn_mask) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1205,6 +1278,9 @@ pub struct user_pac_address_keys { } #[test] fn bindgen_test_layout_user_pac_address_keys() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -1216,7 +1292,7 @@ fn bindgen_test_layout_user_pac_address_keys() { concat!("Alignment of ", stringify!(user_pac_address_keys)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apiakey as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apiakey) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1226,7 +1302,7 @@ fn bindgen_test_layout_user_pac_address_keys() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apibkey as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apibkey) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -1236,7 +1312,7 @@ fn bindgen_test_layout_user_pac_address_keys() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apdakey as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apdakey) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -1246,7 +1322,7 @@ fn bindgen_test_layout_user_pac_address_keys() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apdbkey as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apdbkey) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -1264,6 +1340,9 @@ pub struct user_pac_generic_keys { } #[test] fn bindgen_test_layout_user_pac_generic_keys() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1275,7 +1354,7 @@ fn bindgen_test_layout_user_pac_generic_keys() { concat!("Alignment of ", stringify!(user_pac_generic_keys)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apgakey as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apgakey) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1286,8 +1365,97 @@ fn bindgen_test_layout_user_pac_generic_keys() { ); } #[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct user_za_header { + pub size: __u32, + pub max_size: __u32, + pub vl: __u16, + pub max_vl: __u16, + pub flags: __u16, + pub __reserved: __u16, +} +#[test] +fn bindgen_test_layout_user_za_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(user_za_header)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(user_za_header)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(user_za_header), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_size) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(user_za_header), + "::", + stringify!(max_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vl) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(user_za_header), + "::", + stringify!(vl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_vl) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(user_za_header), + "::", + stringify!(max_vl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(user_za_header), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__reserved) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(user_za_header), + "::", + stringify!(__reserved) + ) + ); +} +#[repr(C)] #[repr(align(16))] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_regs { pub regs: user_pt_regs, pub sp_el1: __u64, @@ -1298,6 +1466,8 @@ pub struct kvm_regs { } #[test] fn bindgen_test_layout_kvm_regs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 864usize, @@ -1309,7 +1479,7 @@ fn bindgen_test_layout_kvm_regs() { concat!("Alignment of ", stringify!(kvm_regs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1319,7 +1489,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sp_el1 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sp_el1) as usize - ptr as usize }, 272usize, concat!( "Offset of field: ", @@ -1329,7 +1499,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).elr_el1 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).elr_el1) as usize - ptr as usize }, 280usize, concat!( "Offset of field: ", @@ -1339,7 +1509,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).spsr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).spsr) as usize - ptr as usize }, 288usize, concat!( "Offset of field: ", @@ -1349,7 +1519,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fp_regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fp_regs) as usize - ptr as usize }, 336usize, concat!( "Offset of field: ", @@ -1361,12 +1531,18 @@ fn bindgen_test_layout_kvm_regs() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_vcpu_init { pub target: __u32, pub features: [__u32; 7usize], } #[test] fn bindgen_test_layout_kvm_vcpu_init() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -1378,7 +1554,7 @@ fn bindgen_test_layout_kvm_vcpu_init() { concat!("Alignment of ", stringify!(kvm_vcpu_init)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).target as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).target) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1388,7 +1564,7 @@ fn bindgen_test_layout_kvm_vcpu_init() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).features as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).features) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1440,6 +1616,8 @@ pub struct kvm_guest_debug_arch { } #[test] fn bindgen_test_layout_kvm_guest_debug_arch() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 512usize, @@ -1451,7 +1629,7 @@ fn bindgen_test_layout_kvm_guest_debug_arch() { concat!("Alignment of ", stringify!(kvm_guest_debug_arch)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dbg_bcr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dbg_bcr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1461,7 +1639,7 @@ fn bindgen_test_layout_kvm_guest_debug_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dbg_bvr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dbg_bvr) as usize - ptr as usize }, 128usize, concat!( "Offset of field: ", @@ -1471,7 +1649,7 @@ fn bindgen_test_layout_kvm_guest_debug_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dbg_wcr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dbg_wcr) as usize - ptr as usize }, 256usize, concat!( "Offset of field: ", @@ -1481,7 +1659,7 @@ fn bindgen_test_layout_kvm_guest_debug_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dbg_wvr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dbg_wvr) as usize - ptr as usize }, 384usize, concat!( "Offset of field: ", @@ -1495,10 +1673,13 @@ fn bindgen_test_layout_kvm_guest_debug_arch() { #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_debug_exit_arch { pub hsr: __u32, + pub hsr_high: __u32, pub far: __u64, } #[test] fn bindgen_test_layout_kvm_debug_exit_arch() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1510,7 +1691,7 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { concat!("Alignment of ", stringify!(kvm_debug_exit_arch)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hsr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hsr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1520,7 +1701,17 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).far as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hsr_high) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_debug_exit_arch), + "::", + stringify!(hsr_high) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).far) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1537,6 +1728,8 @@ pub struct kvm_sync_regs { } #[test] fn bindgen_test_layout_kvm_sync_regs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1548,7 +1741,7 @@ fn bindgen_test_layout_kvm_sync_regs() { concat!("Alignment of ", stringify!(kvm_sync_regs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).device_irq_level as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).device_irq_level) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1568,6 +1761,8 @@ pub struct kvm_pmu_event_filter { } #[test] fn bindgen_test_layout_kvm_pmu_event_filter() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1579,7 +1774,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { concat!("Alignment of ", stringify!(kvm_pmu_event_filter)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).base_event as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).base_event) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1589,7 +1784,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nevents as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nevents) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1599,7 +1794,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).action as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1609,7 +1804,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 5usize, concat!( "Offset of field: ", @@ -1636,6 +1831,9 @@ pub struct kvm_vcpu_events__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1647,10 +1845,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_vcpu_events__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serror_pending as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).serror_pending) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1660,10 +1855,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serror_has_esr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).serror_has_esr) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -1673,10 +1865,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ext_dabt_pending as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_dabt_pending) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -1686,9 +1875,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -1698,10 +1885,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serror_esr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).serror_esr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1713,6 +1897,8 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { } #[test] fn bindgen_test_layout_kvm_vcpu_events() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -1724,7 +1910,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { concat!("Alignment of ", stringify!(kvm_vcpu_events)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).exception as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exception) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1734,7 +1920,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -1745,215 +1931,254 @@ fn bindgen_test_layout_kvm_vcpu_events() { ); } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_user_trace_setup { - pub buf_size: __u32, - pub buf_nr: __u32, +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_arm_copy_mte_tags { + pub guest_ipa: __u64, + pub length: __u64, + pub addr: *mut ::std::os::raw::c_void, + pub flags: __u64, + pub reserved: [__u64; 2usize], } #[test] -fn bindgen_test_layout_kvm_user_trace_setup() { +fn bindgen_test_layout_kvm_arm_copy_mte_tags() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_user_trace_setup)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_arm_copy_mte_tags)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_user_trace_setup)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_arm_copy_mte_tags)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).guest_ipa) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_user_trace_setup), + stringify!(kvm_arm_copy_mte_tags), "::", - stringify!(buf_size) + stringify!(guest_ipa) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_nr as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_arm_copy_mte_tags), + "::", + stringify!(length) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_arm_copy_mte_tags), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_arm_copy_mte_tags), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_user_trace_setup), + stringify!(kvm_arm_copy_mte_tags), "::", - stringify!(buf_nr) + stringify!(reserved) ) ); } +impl Default for kvm_arm_copy_mte_tags { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_breakpoint { - pub enabled: __u32, - pub padding: __u32, - pub address: __u64, +pub struct kvm_arm_counter_offset { + pub counter_offset: __u64, + pub reserved: __u64, } #[test] -fn bindgen_test_layout_kvm_breakpoint() { +fn bindgen_test_layout_kvm_arm_counter_offset() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(kvm_breakpoint)) + concat!("Size of: ", stringify!(kvm_arm_counter_offset)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_breakpoint)) + concat!("Alignment of ", stringify!(kvm_arm_counter_offset)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).counter_offset) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_breakpoint), - "::", - stringify!(enabled) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_breakpoint), + stringify!(kvm_arm_counter_offset), "::", - stringify!(padding) + stringify!(counter_offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_breakpoint), + stringify!(kvm_arm_counter_offset), "::", - stringify!(address) + stringify!(reserved) ) ); } +pub const KVM_REG_ARM_STD_BIT_TRNG_V1_0: _bindgen_ty_1 = 0; +pub type _bindgen_ty_1 = ::std::os::raw::c_uint; +pub const KVM_REG_ARM_STD_HYP_BIT_PV_TIME: _bindgen_ty_2 = 0; +pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +pub const KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT: _bindgen_ty_3 = 0; +pub const KVM_REG_ARM_VENDOR_HYP_BIT_PTP: _bindgen_ty_3 = 1; +pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +pub const kvm_smccc_filter_action_KVM_SMCCC_FILTER_HANDLE: kvm_smccc_filter_action = 0; +pub const kvm_smccc_filter_action_KVM_SMCCC_FILTER_DENY: kvm_smccc_filter_action = 1; +pub const kvm_smccc_filter_action_KVM_SMCCC_FILTER_FWD_TO_USER: kvm_smccc_filter_action = 2; +pub type kvm_smccc_filter_action = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_debug_guest { - pub enabled: __u32, - pub pad: __u32, - pub breakpoints: [kvm_breakpoint; 4usize], - pub singlestep: __u32, +pub struct kvm_smccc_filter { + pub base: __u32, + pub nr_functions: __u32, + pub action: __u8, + pub pad: [__u8; 15usize], } #[test] -fn bindgen_test_layout_kvm_debug_guest() { +fn bindgen_test_layout_kvm_smccc_filter() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 80usize, - concat!("Size of: ", stringify!(kvm_debug_guest)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_smccc_filter)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_debug_guest)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_smccc_filter)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).base) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_debug_guest), + stringify!(kvm_smccc_filter), "::", - stringify!(enabled) + stringify!(base) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr_functions) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_debug_guest), + stringify!(kvm_smccc_filter), "::", - stringify!(pad) + stringify!(nr_functions) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).breakpoints as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_debug_guest), + stringify!(kvm_smccc_filter), "::", - stringify!(breakpoints) + stringify!(action) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).singlestep as *const _ as usize }, - 72usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 9usize, concat!( "Offset of field: ", - stringify!(kvm_debug_guest), + stringify!(kvm_smccc_filter), "::", - stringify!(singlestep) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_memory_region { - pub slot: __u32, - pub flags: __u32, - pub guest_phys_addr: __u64, - pub memory_size: __u64, +pub struct reg_mask_range { + pub addr: __u64, + pub range: __u32, + pub reserved: [__u32; 13usize], } #[test] -fn bindgen_test_layout_kvm_memory_region() { +fn bindgen_test_layout_reg_mask_range() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_memory_region)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(reg_mask_range)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_memory_region)) + concat!("Alignment of ", stringify!(reg_mask_range)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), - "::", - stringify!(slot) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_memory_region), + stringify!(reg_mask_range), "::", - stringify!(flags) + stringify!(addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_phys_addr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).range) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), + stringify!(reg_mask_range), "::", - stringify!(guest_phys_addr) + stringify!(range) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).memory_size as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), + stringify!(reg_mask_range), "::", - stringify!(memory_size) + stringify!(reserved) ) ); } @@ -1968,6 +2193,9 @@ pub struct kvm_userspace_memory_region { } #[test] fn bindgen_test_layout_kvm_userspace_memory_region() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -1979,9 +2207,7 @@ fn bindgen_test_layout_kvm_userspace_memory_region() { concat!("Alignment of ", stringify!(kvm_userspace_memory_region)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).slot as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1991,9 +2217,7 @@ fn bindgen_test_layout_kvm_userspace_memory_region() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flags as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2003,10 +2227,7 @@ fn bindgen_test_layout_kvm_userspace_memory_region() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_phys_addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).guest_phys_addr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2016,9 +2237,7 @@ fn bindgen_test_layout_kvm_userspace_memory_region() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).memory_size as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2028,10 +2247,7 @@ fn bindgen_test_layout_kvm_userspace_memory_region() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).userspace_addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2042,76 +2258,203 @@ fn bindgen_test_layout_kvm_userspace_memory_region() { ); } #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_irq_level { - pub __bindgen_anon_1: kvm_irq_level__bindgen_ty_1, - pub level: __u32, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_irq_level__bindgen_ty_1 { - pub irq: __u32, - pub status: __s32, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_userspace_memory_region2 { + pub slot: __u32, + pub flags: __u32, + pub guest_phys_addr: __u64, + pub memory_size: __u64, + pub userspace_addr: __u64, + pub guest_memfd_offset: __u64, + pub guest_memfd: __u32, + pub pad1: __u32, + pub pad2: [__u64; 14usize], } #[test] -fn bindgen_test_layout_kvm_irq_level__bindgen_ty_1() { +fn bindgen_test_layout_kvm_userspace_memory_region2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_irq_level__bindgen_ty_1)) + ::std::mem::size_of::(), + 160usize, + concat!("Size of: ", stringify!(kvm_userspace_memory_region2)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_level__bindgen_ty_1)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_userspace_memory_region2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irq as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_level__bindgen_ty_1), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(irq) + stringify!(slot) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).status as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_irq_level__bindgen_ty_1), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(status) + stringify!(flags) ) ); -} -impl Default for kvm_irq_level__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_irq_level() { assert_eq!( - ::std::mem::size_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).guest_phys_addr) as usize - ptr as usize }, 8usize, - concat!("Size of: ", stringify!(kvm_irq_level)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_level)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).level as *const _ as usize }, - 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(guest_phys_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(memory_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(userspace_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).guest_memfd_offset) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(guest_memfd_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).guest_memfd) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(guest_memfd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(pad2) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_level { + pub __bindgen_anon_1: kvm_irq_level__bindgen_ty_1, + pub level: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_level__bindgen_ty_1 { + pub irq: __u32, + pub status: __s32, +} +#[test] +fn bindgen_test_layout_kvm_irq_level__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_irq_level__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_level__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_level__bindgen_ty_1), + "::", + stringify!(irq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_level__bindgen_ty_1), + "::", + stringify!(status) + ) + ); +} +impl Default for kvm_irq_level__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_level__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_level__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_irq_level() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_level)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_level)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", stringify!(kvm_irq_level), @@ -2129,6 +2472,15 @@ impl Default for kvm_irq_level { } } } +impl ::std::fmt::Debug for kvm_irq_level { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_level {{ __bindgen_anon_1: {:?}, level: {:?} }}", + self.__bindgen_anon_1, self.level + ) + } +} #[repr(C)] #[derive(Copy, Clone)] pub struct kvm_irqchip { @@ -2143,6 +2495,9 @@ pub union kvm_irqchip__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_irqchip__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 512usize, @@ -2154,7 +2509,7 @@ fn bindgen_test_layout_kvm_irqchip__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_irqchip__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dummy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dummy) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2173,8 +2528,15 @@ impl Default for kvm_irqchip__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_irqchip__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irqchip__bindgen_ty_1 {{ union }}") + } +} #[test] fn bindgen_test_layout_kvm_irqchip() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 520usize, @@ -2186,7 +2548,7 @@ fn bindgen_test_layout_kvm_irqchip() { concat!("Alignment of ", stringify!(kvm_irqchip)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).chip_id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).chip_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2196,7 +2558,7 @@ fn bindgen_test_layout_kvm_irqchip() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2206,7 +2568,7 @@ fn bindgen_test_layout_kvm_irqchip() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).chip as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).chip) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2225,6 +2587,15 @@ impl Default for kvm_irqchip { } } } +impl ::std::fmt::Debug for kvm_irqchip { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irqchip {{ chip_id: {:?}, pad: {:?}, chip: {:?} }}", + self.chip_id, self.pad, self.chip + ) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_pit_config { @@ -2233,6 +2604,8 @@ pub struct kvm_pit_config { } #[test] fn bindgen_test_layout_kvm_pit_config() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -2244,7 +2617,7 @@ fn bindgen_test_layout_kvm_pit_config() { concat!("Alignment of ", stringify!(kvm_pit_config)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2254,7 +2627,7 @@ fn bindgen_test_layout_kvm_pit_config() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2265,384 +2638,156 @@ fn bindgen_test_layout_kvm_pit_config() { ); } #[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_hyperv_exit { + pub type_: __u32, + pub pad1: __u32, + pub u: kvm_hyperv_exit__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_hyperv_exit__bindgen_ty_1 { + pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, + pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, + pub syndbg: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3, +} +#[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_skeys { - pub start_gfn: __u64, - pub count: __u64, - pub skeydata_addr: __u64, - pub flags: __u32, - pub reserved: [__u32; 9usize], +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { + pub msr: __u32, + pub pad2: __u32, + pub control: __u64, + pub evt_page: __u64, + pub msg_page: __u64, } #[test] -fn bindgen_test_layout_kvm_s390_skeys() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_s390_skeys)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_skeys)) - ); +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).start_gfn as *const _ as usize }, - 0usize, + ::std::mem::size_of::(), + 32usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_skeys), - "::", - stringify!(start_gfn) + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, + ::std::mem::align_of::(), 8usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_skeys), - "::", - stringify!(count) + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).skeydata_addr as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(skeydata_addr) + stringify!(msr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(flags) + stringify!(pad2) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 28usize, + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(reserved) + stringify!(control) ) ); -} -#[doc = " kvm_s390_cmma_log - Used for CMMA migration."] -#[doc = ""] -#[doc = " Used both for input and output."] -#[doc = ""] -#[doc = " @start_gfn: Guest page number to start from."] -#[doc = " @count: Size of the result buffer."] -#[doc = " @flags: Control operation mode via KVM_S390_CMMA_* flags"] -#[doc = " @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty"] -#[doc = " pages are still remaining."] -#[doc = " @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set"] -#[doc = " in the PGSTE."] -#[doc = " @values: Pointer to the values buffer."] -#[doc = ""] -#[doc = " Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls."] -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_s390_cmma_log { - pub start_gfn: __u64, - pub count: __u32, - pub flags: __u32, - pub __bindgen_anon_1: kvm_s390_cmma_log__bindgen_ty_1, - pub values: __u64, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_s390_cmma_log__bindgen_ty_1 { - pub remaining: __u64, - pub mask: __u64, -} -#[test] -fn bindgen_test_layout_kvm_s390_cmma_log__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_s390_cmma_log__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_cmma_log__bindgen_ty_1)) - ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).remaining as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).evt_page) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log__bindgen_ty_1), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(remaining) + stringify!(evt_page) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mask as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).msg_page) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log__bindgen_ty_1), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(mask) + stringify!(msg_page) ) ); } -impl Default for kvm_s390_cmma_log__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { + pub input: __u64, + pub result: __u64, + pub params: [__u64; 2usize], } #[test] -fn bindgen_test_layout_kvm_s390_cmma_log() { +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 32usize, - concat!("Size of: ", stringify!(kvm_s390_cmma_log)) + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_cmma_log)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).start_gfn as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_cmma_log), - "::", - stringify!(start_gfn) + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(count) + stringify!(input) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(flags) + stringify!(result) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).values as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(values) - ) - ); -} -impl Default for kvm_s390_cmma_log { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_hyperv_exit { - pub type_: __u32, - pub pad1: __u32, - pub u: kvm_hyperv_exit__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_hyperv_exit__bindgen_ty_1 { - pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, - pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, - pub syndbg: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { - pub msr: __u32, - pub pad2: __u32, - pub control: __u64, - pub evt_page: __u64, - pub msg_page: __u64, -} -#[test] -fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!( - "Size of: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msr as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(msr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad2 as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(pad2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).control - as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(control) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).evt_page - as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(evt_page) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msg_page - as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(msg_page) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { - pub input: __u64, - pub result: __u64, - pub params: [__u64; 2usize], -} -#[test] -fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!( - "Size of: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input - as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(input) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).result - as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(result) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).params - as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(params) + stringify!(params) ) ); } @@ -2659,6 +2804,9 @@ pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3 { } #[test] fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 48usize, @@ -2676,10 +2824,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2689,10 +2834,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad2 as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2702,10 +2844,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).control - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2715,10 +2854,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).status - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2728,10 +2864,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).send_page - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).send_page) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2741,10 +2874,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).recv_page - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).recv_page) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -2754,10 +2884,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pending_page - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pending_page) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -2769,6 +2896,9 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { } #[test] fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 48usize, @@ -2780,9 +2910,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).synic as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).synic) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2792,9 +2920,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hcall as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hcall) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2804,9 +2930,7 @@ fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).syndbg as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).syndbg) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2825,8 +2949,15 @@ impl Default for kvm_hyperv_exit__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_hyperv_exit__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_hyperv_exit__bindgen_ty_1 {{ union }}") + } +} #[test] fn bindgen_test_layout_kvm_hyperv_exit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 56usize, @@ -2838,7 +2969,7 @@ fn bindgen_test_layout_kvm_hyperv_exit() { concat!("Alignment of ", stringify!(kvm_hyperv_exit)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2848,7 +2979,7 @@ fn bindgen_test_layout_kvm_hyperv_exit() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad1 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2858,7 +2989,7 @@ fn bindgen_test_layout_kvm_hyperv_exit() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2877,6 +3008,15 @@ impl Default for kvm_hyperv_exit { } } } +impl ::std::fmt::Debug for kvm_hyperv_exit { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_hyperv_exit {{ type: {:?}, pad1: {:?}, u: {:?} }}", + self.type_, self.pad1, self.u + ) + } +} #[repr(C)] #[derive(Copy, Clone)] pub struct kvm_xen_exit { @@ -2899,6 +3039,9 @@ pub struct kvm_xen_exit__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 72usize, @@ -2916,10 +3059,7 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).longmode - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).longmode) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2929,10 +3069,7 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).cpl as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).cpl) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2942,10 +3079,7 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2955,10 +3089,7 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).result as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2968,10 +3099,7 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).params as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2983,6 +3111,9 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { } #[test] fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 72usize, @@ -2994,9 +3125,7 @@ fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_xen_exit__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hcall as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hcall) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3015,8 +3144,15 @@ impl Default for kvm_xen_exit__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_xen_exit__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_xen_exit__bindgen_ty_1 {{ union }}") + } +} #[test] fn bindgen_test_layout_kvm_xen_exit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 80usize, @@ -3028,7 +3164,7 @@ fn bindgen_test_layout_kvm_xen_exit() { concat!("Alignment of ", stringify!(kvm_xen_exit)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3038,7 +3174,7 @@ fn bindgen_test_layout_kvm_xen_exit() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3057,6 +3193,15 @@ impl Default for kvm_xen_exit { } } } +impl ::std::fmt::Debug for kvm_xen_exit { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_exit {{ type: {:?}, u: {:?} }}", + self.type_, self.u + ) + } +} #[repr(C)] #[derive(Copy, Clone)] pub struct kvm_run { @@ -3083,24 +3228,30 @@ pub union kvm_run__bindgen_ty_1 { pub io: kvm_run__bindgen_ty_1__bindgen_ty_4, pub debug: kvm_run__bindgen_ty_1__bindgen_ty_5, pub mmio: kvm_run__bindgen_ty_1__bindgen_ty_6, - pub hypercall: kvm_run__bindgen_ty_1__bindgen_ty_7, - pub tpr_access: kvm_run__bindgen_ty_1__bindgen_ty_8, - pub s390_sieic: kvm_run__bindgen_ty_1__bindgen_ty_9, + pub iocsr_io: kvm_run__bindgen_ty_1__bindgen_ty_7, + pub hypercall: kvm_run__bindgen_ty_1__bindgen_ty_8, + pub tpr_access: kvm_run__bindgen_ty_1__bindgen_ty_9, + pub s390_sieic: kvm_run__bindgen_ty_1__bindgen_ty_10, pub s390_reset_flags: __u64, - pub s390_ucontrol: kvm_run__bindgen_ty_1__bindgen_ty_10, - pub dcr: kvm_run__bindgen_ty_1__bindgen_ty_11, - pub internal: kvm_run__bindgen_ty_1__bindgen_ty_12, - pub osi: kvm_run__bindgen_ty_1__bindgen_ty_13, - pub papr_hcall: kvm_run__bindgen_ty_1__bindgen_ty_14, - pub s390_tsch: kvm_run__bindgen_ty_1__bindgen_ty_15, - pub epr: kvm_run__bindgen_ty_1__bindgen_ty_16, - pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_17, - pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_18, - pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_19, + pub s390_ucontrol: kvm_run__bindgen_ty_1__bindgen_ty_11, + pub dcr: kvm_run__bindgen_ty_1__bindgen_ty_12, + pub internal: kvm_run__bindgen_ty_1__bindgen_ty_13, + pub emulation_failure: kvm_run__bindgen_ty_1__bindgen_ty_14, + pub osi: kvm_run__bindgen_ty_1__bindgen_ty_15, + pub papr_hcall: kvm_run__bindgen_ty_1__bindgen_ty_16, + pub s390_tsch: kvm_run__bindgen_ty_1__bindgen_ty_17, + pub epr: kvm_run__bindgen_ty_1__bindgen_ty_18, + pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_19, + pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_20, + pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_21, pub hyperv: kvm_hyperv_exit, - pub arm_nisv: kvm_run__bindgen_ty_1__bindgen_ty_20, - pub msr: kvm_run__bindgen_ty_1__bindgen_ty_21, + pub arm_nisv: kvm_run__bindgen_ty_1__bindgen_ty_22, + pub msr: kvm_run__bindgen_ty_1__bindgen_ty_23, pub xen: kvm_xen_exit, + pub riscv_sbi: kvm_run__bindgen_ty_1__bindgen_ty_24, + pub riscv_csr: kvm_run__bindgen_ty_1__bindgen_ty_25, + pub notify: kvm_run__bindgen_ty_1__bindgen_ty_26, + pub memory_fault: kvm_run__bindgen_ty_1__bindgen_ty_27, pub padding: [::std::os::raw::c_char; 256usize], } #[repr(C)] @@ -3110,6 +3261,9 @@ pub struct kvm_run__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -3124,10 +3278,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hardware_exit_reason - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hardware_exit_reason) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3145,6 +3296,9 @@ pub struct kvm_run__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -3160,8 +3314,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_2() { ); assert_eq!( unsafe { - &(*(::std::ptr::null::())) - .hardware_entry_failure_reason as *const _ as usize + ::std::ptr::addr_of!((*ptr).hardware_entry_failure_reason) as usize - ptr as usize }, 0usize, concat!( @@ -3172,9 +3325,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).cpu as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).cpu) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3192,6 +3343,9 @@ pub struct kvm_run__bindgen_ty_1__bindgen_ty_3 { } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -3206,10 +3360,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).exception as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).exception) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3219,10 +3370,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).error_code as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).error_code) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3243,6 +3391,9 @@ pub struct kvm_run__bindgen_ty_1__bindgen_ty_4 { } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -3257,10 +3408,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).direction as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3270,10 +3418,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).size as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3283,10 +3428,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).port as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3296,10 +3438,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).count as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3309,10 +3448,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data_offset as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).data_offset) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3329,6 +3465,9 @@ pub struct kvm_run__bindgen_ty_1__bindgen_ty_5 { } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_5() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -3343,10 +3482,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_5() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).arch as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3366,6 +3502,9 @@ pub struct kvm_run__bindgen_ty_1__bindgen_ty_6 { } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -3380,10 +3519,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).phys_addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3393,10 +3529,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3406,9 +3539,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).len as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3418,10 +3549,7 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).is_write as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -3434,17 +3562,19 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_7 { - pub nr: __u64, - pub args: [__u64; 6usize], - pub ret: __u64, - pub longmode: __u32, - pub pad: __u32, + pub phys_addr: __u64, + pub data: [__u8; 8usize], + pub len: __u32, + pub is_write: __u8, } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_7() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 72usize, + 24usize, concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7)) ); assert_eq!( @@ -3456,80 +3586,127 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_7() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", - stringify!(nr) + stringify!(phys_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).args as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", - stringify!(args) + stringify!(data) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ret as *const _ as usize - }, - 56usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", - stringify!(ret) + stringify!(len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).longmode as *const _ - as usize - }, - 64usize, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", + stringify!(is_write) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_8 { + pub nr: __u64, + pub args: [__u64; 6usize], + pub ret: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + pub longmode: __u32, + pub flags: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).longmode) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1), + "::", stringify!(longmode) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 68usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1), "::", - stringify!(pad) + stringify!(flags) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_8 { - pub rip: __u64, - pub is_write: __u32, - pub pad: __u32, +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 {{ union }}" + ) + } } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 16usize, + 72usize, concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8)) ); assert_eq!( @@ -3541,114 +3718,121 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rip as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), "::", - stringify!(rip) + stringify!(nr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).is_write as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), "::", - stringify!(is_write) + stringify!(args) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 56usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), "::", - stringify!(pad) + stringify!(ret) ) ); } +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_8 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_8 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_8 {{ nr: {:?}, args: {:?}, ret: {:?}, __bindgen_anon_1: {:?} }}" , self . nr , self . args , self . ret , self . __bindgen_anon_1) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_9 { - pub icptcode: __u8, - pub ipa: __u16, - pub ipb: __u32, + pub rip: __u64, + pub is_write: __u32, + pub pad: __u32, } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_9() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 8usize, + 16usize, concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9)) ); assert_eq!( ::std::mem::align_of::(), - 4usize, + 8usize, concat!( "Alignment of ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).icptcode as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rip) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), "::", - stringify!(icptcode) + stringify!(rip) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipa as *const _ as usize - }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), "::", - stringify!(ipa) + stringify!(is_write) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipb as *const _ as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), "::", - stringify!(ipb) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_10 { - pub trans_exc_code: __u64, - pub pgm_code: __u32, + pub icptcode: __u8, + pub ipa: __u16, + pub ipb: __u32, } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_10() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 16usize, + 8usize, concat!( "Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) @@ -3656,51 +3840,57 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_10() { ); assert_eq!( ::std::mem::align_of::(), - 8usize, + 4usize, concat!( "Alignment of ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_exc_code - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).icptcode) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), "::", - stringify!(trans_exc_code) + stringify!(icptcode) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pgm_code as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).ipa) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), "::", - stringify!(pgm_code) + stringify!(ipa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipb) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), + "::", + stringify!(ipb) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_11 { - pub dcrn: __u32, - pub data: __u32, - pub is_write: __u8, + pub trans_exc_code: __u64, + pub pgm_code: __u32, } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_11() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 12usize, + 16usize, concat!( "Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) @@ -3708,64 +3898,48 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_11() { ); assert_eq!( ::std::mem::align_of::(), - 4usize, + 8usize, concat!( "Alignment of ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dcrn as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).trans_exc_code) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), "::", - stringify!(dcrn) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), - "::", - stringify!(data) + stringify!(trans_exc_code) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).is_write as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pgm_code) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), "::", - stringify!(is_write) + stringify!(pgm_code) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_12 { - pub suberror: __u32, - pub ndata: __u32, - pub data: [__u64; 16usize], + pub dcrn: __u32, + pub data: __u32, + pub is_write: __u8, } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_12() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 136usize, + 12usize, concat!( "Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) @@ -3773,62 +3947,58 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_12() { ); assert_eq!( ::std::mem::align_of::(), - 8usize, + 4usize, concat!( "Alignment of ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).suberror as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dcrn) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), "::", - stringify!(suberror) + stringify!(dcrn) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ndata as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), "::", - stringify!(ndata) + stringify!(data) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), "::", - stringify!(data) + stringify!(is_write) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_13 { - pub gprs: [__u64; 32usize], + pub suberror: __u32, + pub ndata: __u32, + pub data: [__u64; 16usize], } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_13() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 256usize, + 136usize, concat!( "Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) @@ -3843,200 +4013,252 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_13() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gprs as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).suberror) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), "::", - stringify!(gprs) + stringify!(suberror) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), + "::", + stringify!(ndata) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), + "::", + stringify!(data) ) ); } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[derive(Copy, Clone)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_14 { - pub nr: __u64, - pub ret: __u64, - pub args: [__u64; 9usize], + pub suberror: __u32, + pub ndata: __u32, + pub flags: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1 { + pub insn_size: __u8, + pub insn_bytes: [__u8; 15usize], } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit< + kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1, + > = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 88usize, + ::std::mem::size_of::(), + 16usize, concat!( "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, + ::std::mem::align_of::(), + 1usize, concat!( "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).insn_size) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(nr) + stringify!(insn_size) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ret as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).insn_bytes) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(ret) + stringify!(insn_bytes) ) ); +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1() { assert_eq!( - unsafe { - &(*(::std::ptr::null::())).args as *const _ - as usize - }, + ::std::mem::size_of::(), 16usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), - "::", - stringify!(args) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_15 { - pub subchannel_id: __u16, - pub subchannel_nr: __u16, - pub io_int_parm: __u32, - pub io_int_word: __u32, - pub ipb: __u32, - pub dequeued: __u8, +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 {{ union }}" + ) + } } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_15() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 20usize, + ::std::mem::size_of::(), + 32usize, concat!( "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + ::std::mem::align_of::(), + 8usize, concat!( "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).subchannel_id - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).suberror) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), "::", - stringify!(subchannel_id) + stringify!(suberror) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).subchannel_nr - as *const _ as usize - }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), "::", - stringify!(subchannel_nr) + stringify!(ndata) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).io_int_parm as *const _ - as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), "::", - stringify!(io_int_parm) + stringify!(flags) ) ); - assert_eq!( +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_14 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).io_int_word as *const _ - as usize - }, - 8usize, + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_14 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_14 {{ suberror: {:?}, ndata: {:?}, flags: {:?}, __bindgen_anon_1: {:?} }}" , self . suberror , self . ndata , self . flags , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_15 { + pub gprs: [__u64; 32usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_15() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), - "::", - stringify!(io_int_word) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipb as *const _ - as usize - }, - 12usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), - "::", - stringify!(ipb) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dequeued as *const _ - as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).gprs) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), "::", - stringify!(dequeued) + stringify!(gprs) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct kvm_run__bindgen_ty_1__bindgen_ty_16 { - pub epr: __u32, + pub nr: __u64, + pub ret: __u64, + pub args: [__u64; 9usize], } #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_16() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 4usize, + 88usize, concat!( "Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) @@ -4044,3498 +4266,1328 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_16() { ); assert_eq!( ::std::mem::align_of::(), - 4usize, + 8usize, concat!( "Alignment of ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).epr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), "::", - stringify!(epr) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_17 { - pub type_: __u32, - pub flags: __u64, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_17() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) + stringify!(nr) ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_ as *const _ - as usize - }, - 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), "::", - stringify!(type_) + stringify!(ret) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flags as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), "::", - stringify!(flags) + stringify!(args) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_18 { - pub addr: __u64, - pub ar: __u8, - pub reserved: __u8, - pub fc: __u8, - pub sel1: __u8, - pub sel2: __u16, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_17 { + pub subchannel_id: __u16, + pub subchannel_nr: __u16, + pub io_int_parm: __u32, + pub io_int_word: __u32, + pub ipb: __u32, + pub dequeued: __u8, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_18() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_17() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, + ::std::mem::size_of::(), + 20usize, concat!( "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, + ::std::mem::align_of::(), + 4usize, concat!( "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).subchannel_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(addr) + stringify!(subchannel_id) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ar as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).subchannel_nr) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(ar) + stringify!(subchannel_nr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ - as usize - }, - 9usize, + unsafe { ::std::ptr::addr_of!((*ptr).io_int_parm) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(reserved) + stringify!(io_int_parm) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fc as *const _ as usize - }, - 10usize, + unsafe { ::std::ptr::addr_of!((*ptr).io_int_word) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(fc) + stringify!(io_int_word) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sel1 as *const _ - as usize - }, - 11usize, + unsafe { ::std::ptr::addr_of!((*ptr).ipb) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(sel1) + stringify!(ipb) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sel2 as *const _ - as usize - }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).dequeued) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(sel2) + stringify!(dequeued) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_19 { - pub vector: __u8, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_18 { + pub epr: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_18() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 1usize, + ::std::mem::size_of::(), + 4usize, concat!( "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) ) ); assert_eq!( - ::std::mem::align_of::(), - 1usize, + ::std::mem::align_of::(), + 4usize, concat!( "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vector as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).epr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), "::", - stringify!(vector) + stringify!(epr) ) ); } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_20 { - pub esr_iss: __u64, - pub fault_ipa: __u64, +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_19 { + pub type_: __u32, + pub ndata: __u32, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + pub flags: __u64, + pub data: [__u64; 16usize], } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_20() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, + ::std::mem::size_of::(), + 128usize, concat!( "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1) ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, concat!( "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).esr_iss as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1), "::", - stringify!(esr_iss) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fault_ipa as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1), "::", - stringify!(fault_ipa) + stringify!(data) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_21 { - pub error: __u8, - pub pad: [__u8; 7usize], - pub reason: __u32, - pub index: __u32, - pub data: __u64, +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 {{ union }}" + ) + } } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_21() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, + ::std::mem::size_of::(), + 136usize, concat!( "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, concat!( "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).error as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), - "::", - stringify!(error) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ - as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), "::", - stringify!(pad) + stringify!(type_) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reason as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), "::", - stringify!(reason) + stringify!(ndata) ) ); - assert_eq!( +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_19 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).index as *const _ - as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), - "::", - stringify!(index) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_19 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_19 {{ type: {:?}, ndata: {:?}, __bindgen_anon_1: {:?} }}" , self . type_ , self . ndata , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_20 { + pub addr: __u64, + pub ar: __u8, + pub reserved: __u8, + pub fc: __u8, + pub sel1: __u8, + pub sel2: __u16, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_20() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, + ::std::mem::size_of::(), 16usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), - "::", - stringify!(data) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) ) ); -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 256usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1)) - ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_1)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hw as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(hw) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fail_entry as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(fail_entry) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ex as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).ar) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(ex) + stringify!(ar) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).io as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 9usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(io) + stringify!(reserved) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).debug as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).fc) as usize - ptr as usize }, + 10usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(debug) + stringify!(fc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mmio as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).sel1) as usize - ptr as usize }, + 11usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(mmio) + stringify!(sel1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hypercall as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).sel2) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(hypercall) + stringify!(sel2) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_21 { + pub vector: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_21() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tpr_access as *const _ as usize - }, - 0usize, + ::std::mem::size_of::(), + 1usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(tpr_access) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).s390_sieic as *const _ as usize - }, - 0usize, + ::std::mem::align_of::(), + 1usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(s390_sieic) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).s390_reset_flags as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), "::", - stringify!(s390_reset_flags) + stringify!(vector) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_22 { + pub esr_iss: __u64, + pub fault_ipa: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_22() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).s390_ucontrol as *const _ as usize - }, - 0usize, + ::std::mem::size_of::(), + 16usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(s390_ucontrol) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcr as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(dcr) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).internal as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).esr_iss) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22), "::", - stringify!(internal) + stringify!(esr_iss) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).osi as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).fault_ipa) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22), "::", - stringify!(osi) + stringify!(fault_ipa) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).papr_hcall as *const _ as usize - }, - 0usize, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_23 { + pub error: __u8, + pub pad: [__u8; 7usize], + pub reason: __u32, + pub index: __u32, + pub data: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_23() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(papr_hcall) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).s390_tsch as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(s390_tsch) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).epr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).error) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(epr) + stringify!(error) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).system_event as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(system_event) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).s390_stsi as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).reason) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(s390_stsi) + stringify!(reason) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).eoi as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(eoi) + stringify!(index) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hyperv as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(hyperv) + stringify!(data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_24 { + pub extension_id: ::std::os::raw::c_ulong, + pub function_id: ::std::os::raw::c_ulong, + pub args: [::std::os::raw::c_ulong; 6usize], + pub ret: [::std::os::raw::c_ulong; 2usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_24() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).arm_nisv as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).extension_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(arm_nisv) + stringify!(extension_id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).msr as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).function_id) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(msr) + stringify!(function_id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xen as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(xen) + stringify!(args) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 64usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(padding) + stringify!(ret) ) ); } -impl Default for kvm_run__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} #[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_run__bindgen_ty_2 { - pub regs: kvm_sync_regs, - pub padding: [::std::os::raw::c_char; 2048usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_25 { + pub csr_num: ::std::os::raw::c_ulong, + pub new_value: ::std::os::raw::c_ulong, + pub write_mask: ::std::os::raw::c_ulong, + pub ret_value: ::std::os::raw::c_ulong, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_2() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_25() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 2048usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_2)) + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_2)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).csr_num) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_2), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), "::", - stringify!(regs) + stringify!(csr_num) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).new_value) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_2), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), "::", - stringify!(padding) + stringify!(new_value) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).write_mask) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), + "::", + stringify!(write_mask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret_value) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), + "::", + stringify!(ret_value) ) ); } -impl Default for kvm_run__bindgen_ty_2 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_26 { + pub flags: __u32, } #[test] -fn bindgen_test_layout_kvm_run() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_26() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 2352usize, - concat!("Size of: ", stringify!(kvm_run)) + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_run)) + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).request_interrupt_window as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26), "::", - stringify!(request_interrupt_window) + stringify!(flags) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_27 { + pub flags: __u64, + pub gpa: __u64, + pub size: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_27() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).immediate_exit as *const _ as usize }, - 1usize, + ::std::mem::size_of::(), + 24usize, concat!( - "Offset of field: ", - stringify!(kvm_run), - "::", - stringify!(immediate_exit) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding1 as *const _ as usize }, - 2usize, + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), "::", - stringify!(padding1) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).exit_reason as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gpa) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), "::", - stringify!(exit_reason) + stringify!(gpa) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ready_for_interrupt_injection as *const _ as usize - }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), "::", - stringify!(ready_for_interrupt_injection) + stringify!(size) ) ); +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1)) + ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).if_flag as *const _ as usize }, - 13usize, + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hw) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(if_flag) + stringify!(hw) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 14usize, + unsafe { ::std::ptr::addr_of!((*ptr).fail_entry) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(flags) + stringify!(fail_entry) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr8 as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).ex) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(cr8) + stringify!(ex) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apic_base as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).io) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(apic_base) + stringify!(io) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kvm_valid_regs as *const _ as usize }, - 288usize, + unsafe { ::std::ptr::addr_of!((*ptr).debug) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(kvm_valid_regs) + stringify!(debug) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kvm_dirty_regs as *const _ as usize }, - 296usize, + unsafe { ::std::ptr::addr_of!((*ptr).mmio) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(kvm_dirty_regs) + stringify!(mmio) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).s as *const _ as usize }, - 304usize, + unsafe { ::std::ptr::addr_of!((*ptr).iocsr_io) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(s) + stringify!(iocsr_io) ) ); -} -impl Default for kvm_run { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_coalesced_mmio_zone { - pub addr: __u64, - pub size: __u32, - pub __bindgen_anon_1: kvm_coalesced_mmio_zone__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_coalesced_mmio_zone__bindgen_ty_1 { - pub pad: __u32, - pub pio: __u32, -} -#[test] -fn bindgen_test_layout_kvm_coalesced_mmio_zone__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!( - "Size of: ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), - "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pio as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), - "::", - stringify!(pio) - ) - ); -} -impl Default for kvm_coalesced_mmio_zone__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_coalesced_mmio_zone() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio_zone)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_coalesced_mmio_zone)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone), - "::", - stringify!(size) - ) - ); -} -impl Default for kvm_coalesced_mmio_zone { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_coalesced_mmio { - pub phys_addr: __u64, - pub len: __u32, - pub __bindgen_anon_1: kvm_coalesced_mmio__bindgen_ty_1, - pub data: [__u8; 8usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_coalesced_mmio__bindgen_ty_1 { - pub pad: __u32, - pub pio: __u32, -} -#[test] -fn bindgen_test_layout_kvm_coalesced_mmio__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(kvm_coalesced_mmio__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio__bindgen_ty_1), - "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pio as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio__bindgen_ty_1), - "::", - stringify!(pio) - ) - ); -} -impl Default for kvm_coalesced_mmio__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_coalesced_mmio() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_coalesced_mmio)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).phys_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio), - "::", - stringify!(phys_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio), - "::", - stringify!(data) - ) - ); -} -impl Default for kvm_coalesced_mmio { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -pub struct kvm_coalesced_mmio_ring { - pub first: __u32, - pub last: __u32, - pub coalesced_mmio: __IncompleteArrayField, -} -#[test] -fn bindgen_test_layout_kvm_coalesced_mmio_ring() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio_ring)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_coalesced_mmio_ring)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).first as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_ring), - "::", - stringify!(first) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).last as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_ring), - "::", - stringify!(last) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).coalesced_mmio as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_coalesced_mmio_ring), - "::", - stringify!(coalesced_mmio) - ) - ); -} -impl Default for kvm_coalesced_mmio_ring { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_translation { - pub linear_address: __u64, - pub physical_address: __u64, - pub valid: __u8, - pub writeable: __u8, - pub usermode: __u8, - pub pad: [__u8; 5usize], -} -#[test] -fn bindgen_test_layout_kvm_translation() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_translation)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_translation)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).linear_address as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(linear_address) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).physical_address as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(physical_address) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).valid as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(valid) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).writeable as *const _ as usize }, - 17usize, - concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(writeable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).usermode as *const _ as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(usermode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 19usize, - concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(pad) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_s390_mem_op { - pub gaddr: __u64, - pub flags: __u64, - pub size: __u32, - pub op: __u32, - pub buf: __u64, - pub __bindgen_anon_1: kvm_s390_mem_op__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_s390_mem_op__bindgen_ty_1 { - pub ar: __u8, - pub sida_offset: __u32, - pub reserved: [__u8; 32usize], -} -#[test] -fn bindgen_test_layout_kvm_s390_mem_op__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_s390_mem_op__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_mem_op__bindgen_ty_1)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ar as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op__bindgen_ty_1), - "::", - stringify!(ar) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sida_offset as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op__bindgen_ty_1), - "::", - stringify!(sida_offset) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op__bindgen_ty_1), - "::", - stringify!(reserved) - ) - ); -} -impl Default for kvm_s390_mem_op__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_s390_mem_op() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_s390_mem_op)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_mem_op)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).gaddr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(gaddr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(op) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(buf) - ) - ); -} -impl Default for kvm_s390_mem_op { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_interrupt { - pub irq: __u32, -} -#[test] -fn bindgen_test_layout_kvm_interrupt() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_interrupt)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_interrupt)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).irq as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_interrupt), - "::", - stringify!(irq) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_dirty_log { - pub slot: __u32, - pub padding1: __u32, - pub __bindgen_anon_1: kvm_dirty_log__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_dirty_log__bindgen_ty_1 { - pub dirty_bitmap: *mut ::std::os::raw::c_void, - pub padding2: __u64, -} -#[test] -fn bindgen_test_layout_kvm_dirty_log__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_dirty_log__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_log__bindgen_ty_1)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dirty_bitmap as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_dirty_log__bindgen_ty_1), - "::", - stringify!(dirty_bitmap) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).padding2 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_dirty_log__bindgen_ty_1), - "::", - stringify!(padding2) - ) - ); -} -impl Default for kvm_dirty_log__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_dirty_log() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_dirty_log)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_log)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_dirty_log), - "::", - stringify!(slot) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding1 as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_dirty_log), - "::", - stringify!(padding1) - ) - ); -} -impl Default for kvm_dirty_log { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_clear_dirty_log { - pub slot: __u32, - pub num_pages: __u32, - pub first_page: __u64, - pub __bindgen_anon_1: kvm_clear_dirty_log__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_clear_dirty_log__bindgen_ty_1 { - pub dirty_bitmap: *mut ::std::os::raw::c_void, - pub padding2: __u64, -} -#[test] -fn bindgen_test_layout_kvm_clear_dirty_log__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_clear_dirty_log__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(kvm_clear_dirty_log__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dirty_bitmap as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log__bindgen_ty_1), - "::", - stringify!(dirty_bitmap) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).padding2 as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log__bindgen_ty_1), - "::", - stringify!(padding2) - ) - ); -} -impl Default for kvm_clear_dirty_log__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_clear_dirty_log() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_clear_dirty_log)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_clear_dirty_log)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log), - "::", - stringify!(slot) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_pages as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log), - "::", - stringify!(num_pages) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).first_page as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log), - "::", - stringify!(first_page) - ) - ); -} -impl Default for kvm_clear_dirty_log { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct kvm_signal_mask { - pub len: __u32, - pub sigset: __IncompleteArrayField<__u8>, -} -#[test] -fn bindgen_test_layout_kvm_signal_mask() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_signal_mask)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_signal_mask)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_signal_mask), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sigset as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_signal_mask), - "::", - stringify!(sigset) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_tpr_access_ctl { - pub enabled: __u32, - pub flags: __u32, - pub reserved: [__u32; 8usize], -} -#[test] -fn bindgen_test_layout_kvm_tpr_access_ctl() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_tpr_access_ctl)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_tpr_access_ctl)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_tpr_access_ctl), - "::", - stringify!(enabled) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_tpr_access_ctl), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_tpr_access_ctl), - "::", - stringify!(reserved) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_vapic_addr { - pub vapic_addr: __u64, -} -#[test] -fn bindgen_test_layout_kvm_vapic_addr() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_vapic_addr)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_vapic_addr)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vapic_addr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_vapic_addr), - "::", - stringify!(vapic_addr) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_mp_state { - pub mp_state: __u32, -} -#[test] -fn bindgen_test_layout_kvm_mp_state() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_mp_state)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_mp_state)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mp_state as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_mp_state), - "::", - stringify!(mp_state) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_psw { - pub mask: __u64, - pub addr: __u64, -} -#[test] -fn bindgen_test_layout_kvm_s390_psw() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_s390_psw)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_psw)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_psw), - "::", - stringify!(mask) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_psw), - "::", - stringify!(addr) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_interrupt { - pub type_: __u32, - pub parm: __u32, - pub parm64: __u64, -} -#[test] -fn bindgen_test_layout_kvm_s390_interrupt() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_s390_interrupt)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_interrupt)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_interrupt), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).parm as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_interrupt), - "::", - stringify!(parm) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).parm64 as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_interrupt), - "::", - stringify!(parm64) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_io_info { - pub subchannel_id: __u16, - pub subchannel_nr: __u16, - pub io_int_parm: __u32, - pub io_int_word: __u32, -} -#[test] -fn bindgen_test_layout_kvm_s390_io_info() { - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(kvm_s390_io_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_io_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).subchannel_id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_io_info), - "::", - stringify!(subchannel_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).subchannel_nr as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_io_info), - "::", - stringify!(subchannel_nr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).io_int_parm as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_io_info), - "::", - stringify!(io_int_parm) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).io_int_word as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_io_info), - "::", - stringify!(io_int_word) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_ext_info { - pub ext_params: __u32, - pub pad: __u32, - pub ext_params2: __u64, -} -#[test] -fn bindgen_test_layout_kvm_s390_ext_info() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_s390_ext_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_ext_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_params as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_ext_info), - "::", - stringify!(ext_params) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_ext_info), - "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_params2 as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_ext_info), - "::", - stringify!(ext_params2) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_pgm_info { - pub trans_exc_code: __u64, - pub mon_code: __u64, - pub per_address: __u64, - pub data_exc_code: __u32, - pub code: __u16, - pub mon_class_nr: __u16, - pub per_code: __u8, - pub per_atmid: __u8, - pub exc_access_id: __u8, - pub per_access_id: __u8, - pub op_access_id: __u8, - pub flags: __u8, - pub pad: [__u8; 2usize], -} -#[test] -fn bindgen_test_layout_kvm_s390_pgm_info() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_s390_pgm_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_pgm_info)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_exc_code as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(trans_exc_code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mon_code as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(mon_code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_address as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(per_address) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_exc_code as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(data_exc_code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mon_class_nr as *const _ as usize }, - 30usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(mon_class_nr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_code as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(per_code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_atmid as *const _ as usize }, - 33usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(per_atmid) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).exc_access_id as *const _ as usize }, - 34usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(exc_access_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_access_id as *const _ as usize }, - 35usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(per_access_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).op_access_id as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(op_access_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 37usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 38usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(pad) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_prefix_info { - pub address: __u32, -} -#[test] -fn bindgen_test_layout_kvm_s390_prefix_info() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_s390_prefix_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_prefix_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).address as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_prefix_info), - "::", - stringify!(address) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_extcall_info { - pub code: __u16, -} -#[test] -fn bindgen_test_layout_kvm_s390_extcall_info() { - assert_eq!( - ::std::mem::size_of::(), - 2usize, - concat!("Size of: ", stringify!(kvm_s390_extcall_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(kvm_s390_extcall_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_extcall_info), - "::", - stringify!(code) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_emerg_info { - pub code: __u16, -} -#[test] -fn bindgen_test_layout_kvm_s390_emerg_info() { - assert_eq!( - ::std::mem::size_of::(), - 2usize, - concat!("Size of: ", stringify!(kvm_s390_emerg_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(kvm_s390_emerg_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_emerg_info), - "::", - stringify!(code) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_stop_info { - pub flags: __u32, -} -#[test] -fn bindgen_test_layout_kvm_s390_stop_info() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_s390_stop_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_stop_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_stop_info), - "::", - stringify!(flags) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_mchk_info { - pub cr14: __u64, - pub mcic: __u64, - pub failing_storage_address: __u64, - pub ext_damage_code: __u32, - pub pad: __u32, - pub fixed_logout: [__u8; 16usize], -} -#[test] -fn bindgen_test_layout_kvm_s390_mchk_info() { - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_s390_mchk_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_mchk_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr14 as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(cr14) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mcic as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(mcic) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).failing_storage_address as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(failing_storage_address) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ext_damage_code as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(ext_damage_code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fixed_logout as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(fixed_logout) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_s390_irq { - pub type_: __u64, - pub u: kvm_s390_irq__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_s390_irq__bindgen_ty_1 { - pub io: kvm_s390_io_info, - pub ext: kvm_s390_ext_info, - pub pgm: kvm_s390_pgm_info, - pub emerg: kvm_s390_emerg_info, - pub extcall: kvm_s390_extcall_info, - pub prefix: kvm_s390_prefix_info, - pub stop: kvm_s390_stop_info, - pub mchk: kvm_s390_mchk_info, - pub reserved: [::std::os::raw::c_char; 64usize], -} -#[test] -fn bindgen_test_layout_kvm_s390_irq__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_s390_irq__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_irq__bindgen_ty_1)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).io as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(io) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(ext) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pgm as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(pgm) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).emerg as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(emerg) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).extcall as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(extcall) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).prefix as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(prefix) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).stop as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(stop) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mchk as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(mchk) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(reserved) - ) - ); -} -impl Default for kvm_s390_irq__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_s390_irq() { - assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_s390_irq)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_irq)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq), - "::", - stringify!(u) - ) - ); -} -impl Default for kvm_s390_irq { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_irq_state { - pub buf: __u64, - pub flags: __u32, - pub len: __u32, - pub reserved: [__u32; 4usize], -} -#[test] -fn bindgen_test_layout_kvm_s390_irq_state() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_s390_irq_state)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_irq_state)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq_state), - "::", - stringify!(buf) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq_state), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq_state), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq_state), - "::", - stringify!(reserved) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_guest_debug { - pub control: __u32, - pub pad: __u32, - pub arch: kvm_guest_debug_arch, -} -#[test] -fn bindgen_test_layout_kvm_guest_debug() { - assert_eq!( - ::std::mem::size_of::(), - 520usize, - concat!("Size of: ", stringify!(kvm_guest_debug)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_guest_debug)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).control as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_guest_debug), - "::", - stringify!(control) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_guest_debug), - "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).arch as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_guest_debug), - "::", - stringify!(arch) - ) - ); -} -pub const kvm_ioeventfd_flag_nr_datamatch: ::std::os::raw::c_uint = 0; -pub const kvm_ioeventfd_flag_nr_pio: ::std::os::raw::c_uint = 1; -pub const kvm_ioeventfd_flag_nr_deassign: ::std::os::raw::c_uint = 2; -pub const kvm_ioeventfd_flag_nr_virtio_ccw_notify: ::std::os::raw::c_uint = 3; -pub const kvm_ioeventfd_flag_nr_fast_mmio: ::std::os::raw::c_uint = 4; -pub const kvm_ioeventfd_flag_nr_max: ::std::os::raw::c_uint = 5; -pub type _bindgen_ty_1 = ::std::os::raw::c_uint; -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct kvm_ioeventfd { - pub datamatch: __u64, - pub addr: __u64, - pub len: __u32, - pub fd: __s32, - pub flags: __u32, - pub pad: [__u8; 36usize], -} -#[test] -fn bindgen_test_layout_kvm_ioeventfd() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_ioeventfd)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_ioeventfd)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).datamatch as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_ioeventfd), - "::", - stringify!(datamatch) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_ioeventfd), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_ioeventfd), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(kvm_ioeventfd), - "::", - stringify!(fd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_ioeventfd), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(kvm_ioeventfd), - "::", - stringify!(pad) - ) - ); -} -impl Default for kvm_ioeventfd { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct kvm_enable_cap { - pub cap: __u32, - pub flags: __u32, - pub args: [__u64; 4usize], - pub pad: [__u8; 64usize], -} -#[test] -fn bindgen_test_layout_kvm_enable_cap() { - assert_eq!( - ::std::mem::size_of::(), - 104usize, - concat!("Size of: ", stringify!(kvm_enable_cap)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_enable_cap)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cap as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_enable_cap), - "::", - stringify!(cap) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_enable_cap), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).args as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_enable_cap), - "::", - stringify!(args) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(kvm_enable_cap), - "::", - stringify!(pad) - ) - ); -} -impl Default for kvm_enable_cap { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct kvm_ppc_pvinfo { - pub flags: __u32, - pub hcall: [__u32; 4usize], - pub pad: [__u8; 108usize], -} -#[test] -fn bindgen_test_layout_kvm_ppc_pvinfo() { - assert_eq!( - ::std::mem::size_of::(), - 128usize, - concat!("Size of: ", stringify!(kvm_ppc_pvinfo)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_ppc_pvinfo)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_ppc_pvinfo), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hcall as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_ppc_pvinfo), - "::", - stringify!(hcall) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(kvm_ppc_pvinfo), - "::", - stringify!(pad) - ) - ); -} -impl Default for kvm_ppc_pvinfo { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_one_page_size { - pub page_shift: __u32, - pub pte_enc: __u32, -} -#[test] -fn bindgen_test_layout_kvm_ppc_one_page_size() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_ppc_one_page_size)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_ppc_one_page_size)) - ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).page_shift as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hypercall) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_page_size), - "::", - stringify!(page_shift) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pte_enc as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_ppc_one_page_size), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pte_enc) + stringify!(hypercall) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_one_seg_page_size { - pub page_shift: __u32, - pub slb_enc: __u32, - pub enc: [kvm_ppc_one_page_size; 8usize], -} -#[test] -fn bindgen_test_layout_kvm_ppc_one_seg_page_size() { - assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_ppc_one_seg_page_size)) - ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_ppc_one_seg_page_size)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).page_shift as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).tpr_access) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_seg_page_size), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(page_shift) + stringify!(tpr_access) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).slb_enc as *const _ as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_sieic) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_seg_page_size), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(slb_enc) + stringify!(s390_sieic) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).enc as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_reset_flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_seg_page_size), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(enc) + stringify!(s390_reset_flags) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_smmu_info { - pub flags: __u64, - pub slb_size: __u32, - pub data_keys: __u16, - pub instr_keys: __u16, - pub sps: [kvm_ppc_one_seg_page_size; 8usize], -} -#[test] -fn bindgen_test_layout_kvm_ppc_smmu_info() { - assert_eq!( - ::std::mem::size_of::(), - 592usize, - concat!("Size of: ", stringify!(kvm_ppc_smmu_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_ppc_smmu_info)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).s390_ucontrol) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(flags) + stringify!(s390_ucontrol) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slb_size as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).dcr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(slb_size) + stringify!(dcr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_keys as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).internal) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(data_keys) + stringify!(internal) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).instr_keys as *const _ as usize }, - 14usize, + unsafe { ::std::ptr::addr_of!((*ptr).emulation_failure) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(instr_keys) + stringify!(emulation_failure) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sps as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).osi) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(sps) + stringify!(osi) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_resize_hpt { - pub flags: __u64, - pub shift: __u32, - pub pad: __u32, -} -#[test] -fn bindgen_test_layout_kvm_ppc_resize_hpt() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_ppc_resize_hpt)) - ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_ppc_resize_hpt)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).papr_hcall) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_resize_hpt), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(flags) + stringify!(papr_hcall) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).shift as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_tsch) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_resize_hpt), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(shift) + stringify!(s390_tsch) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).epr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_resize_hpt), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pad) + stringify!(epr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irq_routing_irqchip { - pub irqchip: __u32, - pub pin: __u32, -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_irqchip() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_routing_irqchip)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_irqchip)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irqchip as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).system_event) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_irqchip), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(irqchip) + stringify!(system_event) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pin as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_stsi) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_irqchip), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pin) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_irq_routing_msi { - pub address_lo: __u32, - pub address_hi: __u32, - pub data: __u32, - pub __bindgen_anon_1: kvm_irq_routing_msi__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_irq_routing_msi__bindgen_ty_1 { - pub pad: __u32, - pub devid: __u32, -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_msi__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_irq_routing_msi__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(kvm_irq_routing_msi__bindgen_ty_1) + stringify!(s390_stsi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).eoi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pad) + stringify!(eoi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).devid as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hyperv) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(devid) + stringify!(hyperv) ) ); -} -impl Default for kvm_irq_routing_msi__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_msi() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_irq_routing_msi)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_msi)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_lo as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).arm_nisv) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(address_lo) + stringify!(arm_nisv) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_hi as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(address_hi) + stringify!(msr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).xen) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(data) + stringify!(xen) ) ); -} -impl Default for kvm_irq_routing_msi { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irq_routing_s390_adapter { - pub ind_addr: __u64, - pub summary_addr: __u64, - pub ind_offset: __u64, - pub summary_offset: __u32, - pub adapter_id: __u32, -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_s390_adapter() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_irq_routing_s390_adapter)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_s390_adapter)) - ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ind_addr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).riscv_sbi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(ind_addr) + stringify!(riscv_sbi) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).summary_addr as *const _ - as usize - }, - 8usize, + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).riscv_csr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(summary_addr) + stringify!(riscv_csr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ind_offset as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).notify) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(ind_offset) + stringify!(notify) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).summary_offset as *const _ - as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).memory_fault) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(summary_offset) + stringify!(memory_fault) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).adapter_id as *const _ as usize - }, - 28usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(adapter_id) + stringify!(padding) ) ); } +impl Default for kvm_run__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_run__bindgen_ty_1 {{ union }}") + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irq_routing_hv_sint { - pub vcpu: __u32, - pub sint: __u32, +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_2 { + pub regs: kvm_sync_regs, + pub padding: [::std::os::raw::c_char; 2048usize], } #[test] -fn bindgen_test_layout_kvm_irq_routing_hv_sint() { +fn bindgen_test_layout_kvm_run__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_routing_hv_sint)) + ::std::mem::size_of::(), + 2048usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_2)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_hv_sint)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vcpu as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_hv_sint), + stringify!(kvm_run__bindgen_ty_2), "::", - stringify!(vcpu) + stringify!(regs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sint as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_hv_sint), + stringify!(kvm_run__bindgen_ty_2), "::", - stringify!(sint) + stringify!(padding) ) ); } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_irq_routing_entry { - pub gsi: __u32, - pub type_: __u32, - pub flags: __u32, - pub pad: __u32, - pub u: kvm_irq_routing_entry__bindgen_ty_1, +impl Default for kvm_run__bindgen_ty_2 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_irq_routing_entry__bindgen_ty_1 { - pub irqchip: kvm_irq_routing_irqchip, - pub msi: kvm_irq_routing_msi, - pub adapter: kvm_irq_routing_s390_adapter, - pub hv_sint: kvm_irq_routing_hv_sint, - pub pad: [__u32; 8usize], +impl ::std::fmt::Debug for kvm_run__bindgen_ty_2 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_run__bindgen_ty_2 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_irq_routing_entry__bindgen_ty_1() { +fn bindgen_test_layout_kvm_run() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_irq_routing_entry__bindgen_ty_1)) + ::std::mem::size_of::(), + 2352usize, + concat!("Size of: ", stringify!(kvm_run)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1) - ) + concat!("Alignment of ", stringify!(kvm_run)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).irqchip as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).request_interrupt_window) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run), "::", - stringify!(irqchip) + stringify!(request_interrupt_window) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msi as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).immediate_exit) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run), "::", - stringify!(msi) + stringify!(immediate_exit) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).adapter as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding1) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run), "::", - stringify!(adapter) + stringify!(padding1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hv_sint as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).exit_reason) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run), "::", - stringify!(hv_sint) + stringify!(exit_reason) ) ); assert_eq!( unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize + ::std::ptr::addr_of!((*ptr).ready_for_interrupt_injection) as usize - ptr as usize }, - 0usize, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run), "::", - stringify!(pad) + stringify!(ready_for_interrupt_injection) ) ); -} -impl Default for kvm_irq_routing_entry__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_entry() { assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_irq_routing_entry)) + unsafe { ::std::ptr::addr_of!((*ptr).if_flag) as usize - ptr as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(if_flag) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_entry)) + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(flags) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gsi as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).cr8) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run), "::", - stringify!(gsi) + stringify!(cr8) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).apic_base) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run), "::", - stringify!(type_) + stringify!(apic_base) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).kvm_valid_regs) as usize - ptr as usize }, + 288usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run), "::", - stringify!(flags) + stringify!(kvm_valid_regs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).kvm_dirty_regs) as usize - ptr as usize }, + 296usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run), "::", - stringify!(pad) + stringify!(kvm_dirty_regs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).s) as usize - ptr as usize }, + 304usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run), "::", - stringify!(u) + stringify!(s) ) ); } -impl Default for kvm_irq_routing_entry { +impl Default for kvm_run { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7544,56 +5596,67 @@ impl Default for kvm_irq_routing_entry { } } } +impl ::std::fmt::Debug for kvm_run { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run {{ request_interrupt_window: {:?}, immediate_exit: {:?}, padding1: {:?}, exit_reason: {:?}, ready_for_interrupt_injection: {:?}, if_flag: {:?}, flags: {:?}, cr8: {:?}, apic_base: {:?}, __bindgen_anon_1: {:?}, kvm_valid_regs: {:?}, kvm_dirty_regs: {:?}, s: {:?} }}" , self . request_interrupt_window , self . immediate_exit , self . padding1 , self . exit_reason , self . ready_for_interrupt_injection , self . if_flag , self . flags , self . cr8 , self . apic_base , self . __bindgen_anon_1 , self . kvm_valid_regs , self . kvm_dirty_regs , self . s) + } +} #[repr(C)] -pub struct kvm_irq_routing { - pub nr: __u32, - pub flags: __u32, - pub entries: __IncompleteArrayField, +#[derive(Copy, Clone)] +pub struct kvm_coalesced_mmio_zone { + pub addr: __u64, + pub size: __u32, + pub __bindgen_anon_1: kvm_coalesced_mmio_zone__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_coalesced_mmio_zone__bindgen_ty_1 { + pub pad: __u32, + pub pio: __u32, } #[test] -fn bindgen_test_layout_kvm_irq_routing() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_routing)) - ); +fn bindgen_test_layout_kvm_coalesced_mmio_zone__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_irq_routing)) + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_irq_routing), - "::", - stringify!(nr) + "Alignment of ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing), + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), "::", - stringify!(flags) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pio) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing), + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), "::", - stringify!(entries) + stringify!(pio) ) ); } -impl Default for kvm_irq_routing { +impl Default for kvm_coalesced_mmio_zone__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7602,975 +5665,1096 @@ impl Default for kvm_irq_routing { } } } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irqfd { - pub fd: __u32, - pub gsi: __u32, - pub flags: __u32, - pub resamplefd: __u32, - pub pad: [__u8; 16usize], +impl ::std::fmt::Debug for kvm_coalesced_mmio_zone__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_coalesced_mmio_zone__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_irqfd() { +fn bindgen_test_layout_kvm_coalesced_mmio_zone() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_irqfd)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio_zone)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irqfd)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_coalesced_mmio_zone)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqfd), - "::", - stringify!(fd) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).gsi as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_irqfd), + stringify!(kvm_coalesced_mmio_zone), "::", - stringify!(gsi) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_irqfd), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).resamplefd as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(kvm_irqfd), + stringify!(kvm_coalesced_mmio_zone), "::", - stringify!(resamplefd) + stringify!(size) ) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_irqfd), - "::", - stringify!(pad) +} +impl Default for kvm_coalesced_mmio_zone { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_zone { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_coalesced_mmio_zone {{ addr: {:?}, size: {:?}, __bindgen_anon_1: {:?} }}", + self.addr, self.size, self.__bindgen_anon_1 ) - ); + } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_clock_data { - pub clock: __u64, - pub flags: __u32, - pub pad: [__u32; 9usize], +#[derive(Copy, Clone)] +pub struct kvm_coalesced_mmio { + pub phys_addr: __u64, + pub len: __u32, + pub __bindgen_anon_1: kvm_coalesced_mmio__bindgen_ty_1, + pub data: [__u8; 8usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_coalesced_mmio__bindgen_ty_1 { + pub pad: __u32, + pub pio: __u32, } #[test] -fn bindgen_test_layout_kvm_clock_data() { - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_clock_data)) - ); +fn bindgen_test_layout_kvm_coalesced_mmio__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_clock_data)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).clock as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_clock_data), - "::", - stringify!(clock) + "Alignment of ", + stringify!(kvm_coalesced_mmio__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_clock_data), + stringify!(kvm_coalesced_mmio__bindgen_ty_1), "::", - stringify!(flags) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).pio) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_clock_data), + stringify!(kvm_coalesced_mmio__bindgen_ty_1), "::", - stringify!(pad) + stringify!(pio) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_config_tlb { - pub params: __u64, - pub array: __u64, - pub mmu_type: __u32, - pub array_len: __u32, +impl Default for kvm_coalesced_mmio__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_coalesced_mmio__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_config_tlb() { +fn bindgen_test_layout_kvm_coalesced_mmio() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 24usize, - concat!("Size of: ", stringify!(kvm_config_tlb)) + concat!("Size of: ", stringify!(kvm_coalesced_mmio)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_config_tlb)) + concat!("Alignment of ", stringify!(kvm_coalesced_mmio)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).params as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_config_tlb), + stringify!(kvm_coalesced_mmio), "::", - stringify!(params) + stringify!(phys_addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).array as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_config_tlb), + stringify!(kvm_coalesced_mmio), "::", - stringify!(array) + stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mmu_type as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_config_tlb), - "::", - stringify!(mmu_type) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).array_len as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(kvm_config_tlb), + stringify!(kvm_coalesced_mmio), "::", - stringify!(array_len) + stringify!(data) ) ); } +impl Default for kvm_coalesced_mmio { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_coalesced_mmio {{ phys_addr: {:?}, len: {:?}, __bindgen_anon_1: {:?}, data: {:?} }}" , self . phys_addr , self . len , self . __bindgen_anon_1 , self . data) + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_dirty_tlb { - pub bitmap: __u64, - pub num_dirty: __u32, +pub struct kvm_coalesced_mmio_ring { + pub first: __u32, + pub last: __u32, + pub coalesced_mmio: __IncompleteArrayField, } #[test] -fn bindgen_test_layout_kvm_dirty_tlb() { +fn bindgen_test_layout_kvm_coalesced_mmio_ring() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_dirty_tlb)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio_ring)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_tlb)) + concat!("Alignment of ", stringify!(kvm_coalesced_mmio_ring)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bitmap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).first) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_tlb), + stringify!(kvm_coalesced_mmio_ring), "::", - stringify!(bitmap) + stringify!(first) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_ring), + "::", + stringify!(last) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_dirty as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).coalesced_mmio) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_tlb), + stringify!(kvm_coalesced_mmio_ring), "::", - stringify!(num_dirty) + stringify!(coalesced_mmio) ) ); } +impl Default for kvm_coalesced_mmio_ring { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_ring { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_coalesced_mmio_ring {{ first: {:?}, last: {:?}, coalesced_mmio: {:?} }}", + self.first, self.last, self.coalesced_mmio + ) + } +} #[repr(C)] -#[derive(Debug, Default)] -pub struct kvm_reg_list { - pub n: __u64, - pub reg: __IncompleteArrayField<__u64>, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_translation { + pub linear_address: __u64, + pub physical_address: __u64, + pub valid: __u8, + pub writeable: __u8, + pub usermode: __u8, + pub pad: [__u8; 5usize], } #[test] -fn bindgen_test_layout_kvm_reg_list() { +fn bindgen_test_layout_kvm_translation() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_reg_list)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_translation)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_reg_list)) + concat!("Alignment of ", stringify!(kvm_translation)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).n as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).linear_address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_reg_list), + stringify!(kvm_translation), "::", - stringify!(n) + stringify!(linear_address) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).physical_address) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_reg_list), + stringify!(kvm_translation), "::", - stringify!(reg) + stringify!(physical_address) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_one_reg { - pub id: __u64, - pub addr: __u64, -} -#[test] -fn bindgen_test_layout_kvm_one_reg() { assert_eq!( - ::std::mem::size_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).valid) as usize - ptr as usize }, 16usize, - concat!("Size of: ", stringify!(kvm_one_reg)) + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(valid) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_one_reg)) + unsafe { ::std::ptr::addr_of!((*ptr).writeable) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(writeable) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).usermode) as usize - ptr as usize }, + 18usize, concat!( "Offset of field: ", - stringify!(kvm_one_reg), + stringify!(kvm_translation), "::", - stringify!(id) + stringify!(usermode) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 19usize, concat!( "Offset of field: ", - stringify!(kvm_one_reg), + stringify!(kvm_translation), "::", - stringify!(addr) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_msi { - pub address_lo: __u32, - pub address_hi: __u32, - pub data: __u32, - pub flags: __u32, - pub devid: __u32, - pub pad: [__u8; 12usize], +pub struct kvm_interrupt { + pub irq: __u32, } #[test] -fn bindgen_test_layout_kvm_msi() { +fn bindgen_test_layout_kvm_interrupt() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_msi)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_interrupt)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_msi)) + concat!("Alignment of ", stringify!(kvm_interrupt)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_lo as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_msi), - "::", - stringify!(address_lo) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_hi as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_msi), + stringify!(kvm_interrupt), "::", - stringify!(address_hi) + stringify!(irq) ) ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_dirty_log { + pub slot: __u32, + pub padding1: __u32, + pub __bindgen_anon_1: kvm_dirty_log__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_dirty_log__bindgen_ty_1 { + pub dirty_bitmap: *mut ::std::os::raw::c_void, + pub padding2: __u64, +} +#[test] +fn bindgen_test_layout_kvm_dirty_log__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, + ::std::mem::size_of::(), 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_msi), - "::", - stringify!(data) - ) + concat!("Size of: ", stringify!(kvm_dirty_log__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(kvm_msi), - "::", - stringify!(flags) - ) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_log__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).devid as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).dirty_bitmap) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_msi), + stringify!(kvm_dirty_log__bindgen_ty_1), "::", - stringify!(devid) + stringify!(dirty_bitmap) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding2) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_msi), + stringify!(kvm_dirty_log__bindgen_ty_1), "::", - stringify!(pad) + stringify!(padding2) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_arm_device_addr { - pub id: __u64, - pub addr: __u64, +impl Default for kvm_dirty_log__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_dirty_log__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_dirty_log__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_arm_device_addr() { +fn bindgen_test_layout_kvm_dirty_log() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(kvm_arm_device_addr)) + concat!("Size of: ", stringify!(kvm_dirty_log)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_arm_device_addr)) + concat!("Alignment of ", stringify!(kvm_dirty_log)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_arm_device_addr), + stringify!(kvm_dirty_log), "::", - stringify!(id) + stringify!(slot) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding1) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_arm_device_addr), + stringify!(kvm_dirty_log), "::", - stringify!(addr) + stringify!(padding1) ) ); } +impl Default for kvm_dirty_log { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_dirty_log { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_dirty_log {{ slot: {:?}, padding1: {:?}, __bindgen_anon_1: {:?} }}", + self.slot, self.padding1, self.__bindgen_anon_1 + ) + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_create_device { - pub type_: __u32, - pub fd: __u32, - pub flags: __u32, +#[derive(Copy, Clone)] +pub struct kvm_clear_dirty_log { + pub slot: __u32, + pub num_pages: __u32, + pub first_page: __u64, + pub __bindgen_anon_1: kvm_clear_dirty_log__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_clear_dirty_log__bindgen_ty_1 { + pub dirty_bitmap: *mut ::std::os::raw::c_void, + pub padding2: __u64, } #[test] -fn bindgen_test_layout_kvm_create_device() { - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(kvm_create_device)) - ); +fn bindgen_test_layout_kvm_clear_dirty_log__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_create_device)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_clear_dirty_log__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_create_device), - "::", - stringify!(type_) + "Alignment of ", + stringify!(kvm_clear_dirty_log__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).dirty_bitmap) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_create_device), + stringify!(kvm_clear_dirty_log__bindgen_ty_1), "::", - stringify!(fd) + stringify!(dirty_bitmap) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding2) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_create_device), + stringify!(kvm_clear_dirty_log__bindgen_ty_1), "::", - stringify!(flags) + stringify!(padding2) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_device_attr { - pub flags: __u32, - pub group: __u32, - pub attr: __u64, - pub addr: __u64, +impl Default for kvm_clear_dirty_log__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_clear_dirty_log__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_clear_dirty_log__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_device_attr() { +fn bindgen_test_layout_kvm_clear_dirty_log() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 24usize, - concat!("Size of: ", stringify!(kvm_device_attr)) + concat!("Size of: ", stringify!(kvm_clear_dirty_log)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_device_attr)) + concat!("Alignment of ", stringify!(kvm_clear_dirty_log)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_device_attr), + stringify!(kvm_clear_dirty_log), "::", - stringify!(flags) + stringify!(slot) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).group as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).num_pages) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_device_attr), + stringify!(kvm_clear_dirty_log), "::", - stringify!(group) + stringify!(num_pages) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).attr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).first_page) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_device_attr), - "::", - stringify!(attr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_device_attr), + stringify!(kvm_clear_dirty_log), "::", - stringify!(addr) + stringify!(first_page) ) ); } -pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20: kvm_device_type = 1; -pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_42: kvm_device_type = 2; -pub const kvm_device_type_KVM_DEV_TYPE_XICS: kvm_device_type = 3; -pub const kvm_device_type_KVM_DEV_TYPE_VFIO: kvm_device_type = 4; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2: kvm_device_type = 5; -pub const kvm_device_type_KVM_DEV_TYPE_FLIC: kvm_device_type = 6; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3: kvm_device_type = 7; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS: kvm_device_type = 8; -pub const kvm_device_type_KVM_DEV_TYPE_XIVE: kvm_device_type = 9; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_PV_TIME: kvm_device_type = 10; -pub const kvm_device_type_KVM_DEV_TYPE_MAX: kvm_device_type = 11; -pub type kvm_device_type = ::std::os::raw::c_uint; +impl Default for kvm_clear_dirty_log { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_clear_dirty_log { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_clear_dirty_log {{ slot: {:?}, num_pages: {:?}, first_page: {:?}, __bindgen_anon_1: {:?} }}" , self . slot , self . num_pages , self . first_page , self . __bindgen_anon_1) + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_vfio_spapr_tce { - pub groupfd: __s32, - pub tablefd: __s32, +#[derive(Debug, Default)] +pub struct kvm_signal_mask { + pub len: __u32, + pub sigset: __IncompleteArrayField<__u8>, } #[test] -fn bindgen_test_layout_kvm_vfio_spapr_tce() { +fn bindgen_test_layout_kvm_signal_mask() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_vfio_spapr_tce)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_signal_mask)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_vfio_spapr_tce)) + concat!("Alignment of ", stringify!(kvm_signal_mask)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).groupfd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_vfio_spapr_tce), + stringify!(kvm_signal_mask), "::", - stringify!(groupfd) + stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tablefd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sigset) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_vfio_spapr_tce), + stringify!(kvm_signal_mask), "::", - stringify!(tablefd) + stringify!(sigset) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_ucas_mapping { - pub user_addr: __u64, - pub vcpu_addr: __u64, - pub length: __u64, +pub struct kvm_tpr_access_ctl { + pub enabled: __u32, + pub flags: __u32, + pub reserved: [__u32; 8usize], } #[test] -fn bindgen_test_layout_kvm_s390_ucas_mapping() { +fn bindgen_test_layout_kvm_tpr_access_ctl() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_s390_ucas_mapping)) + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(kvm_tpr_access_ctl)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_ucas_mapping)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_tpr_access_ctl)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).user_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).enabled) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ucas_mapping), + stringify!(kvm_tpr_access_ctl), "::", - stringify!(user_addr) + stringify!(enabled) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vcpu_addr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ucas_mapping), + stringify!(kvm_tpr_access_ctl), "::", - stringify!(vcpu_addr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ucas_mapping), + stringify!(kvm_tpr_access_ctl), "::", - stringify!(length) + stringify!(reserved) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_enc_region { - pub addr: __u64, - pub size: __u64, +pub struct kvm_vapic_addr { + pub vapic_addr: __u64, } #[test] -fn bindgen_test_layout_kvm_enc_region() { +fn bindgen_test_layout_kvm_vapic_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_enc_region)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_vapic_addr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_enc_region)) + concat!("Alignment of ", stringify!(kvm_vapic_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vapic_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_enc_region), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_enc_region), + stringify!(kvm_vapic_addr), "::", - stringify!(size) + stringify!(vapic_addr) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_pv_sec_parm { - pub origin: __u64, - pub length: __u64, +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_mp_state { + pub mp_state: __u32, } #[test] -fn bindgen_test_layout_kvm_s390_pv_sec_parm() { +fn bindgen_test_layout_kvm_mp_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_s390_pv_sec_parm)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_mp_state)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_pv_sec_parm)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_mp_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).origin as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mp_state) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_sec_parm), - "::", - stringify!(origin) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pv_sec_parm), + stringify!(kvm_mp_state), "::", - stringify!(length) + stringify!(mp_state) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_pv_unp { - pub addr: __u64, - pub size: __u64, - pub tweak: __u64, +pub struct kvm_guest_debug { + pub control: __u32, + pub pad: __u32, + pub arch: kvm_guest_debug_arch, } #[test] -fn bindgen_test_layout_kvm_s390_pv_unp() { +fn bindgen_test_layout_kvm_guest_debug() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_s390_pv_unp)) + ::std::mem::size_of::(), + 520usize, + concat!("Size of: ", stringify!(kvm_guest_debug)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_pv_unp)) + concat!("Alignment of ", stringify!(kvm_guest_debug)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_unp), + stringify!(kvm_guest_debug), "::", - stringify!(addr) + stringify!(control) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_unp), + stringify!(kvm_guest_debug), "::", - stringify!(size) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tweak as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_unp), + stringify!(kvm_guest_debug), "::", - stringify!(tweak) + stringify!(arch) ) ); } -pub const pv_cmd_id_KVM_PV_ENABLE: pv_cmd_id = 0; -pub const pv_cmd_id_KVM_PV_DISABLE: pv_cmd_id = 1; -pub const pv_cmd_id_KVM_PV_SET_SEC_PARMS: pv_cmd_id = 2; -pub const pv_cmd_id_KVM_PV_UNPACK: pv_cmd_id = 3; -pub const pv_cmd_id_KVM_PV_VERIFY: pv_cmd_id = 4; -pub const pv_cmd_id_KVM_PV_PREP_RESET: pv_cmd_id = 5; -pub const pv_cmd_id_KVM_PV_UNSHARE_ALL: pv_cmd_id = 6; -pub type pv_cmd_id = ::std::os::raw::c_uint; +pub const kvm_ioeventfd_flag_nr_datamatch: _bindgen_ty_4 = 0; +pub const kvm_ioeventfd_flag_nr_pio: _bindgen_ty_4 = 1; +pub const kvm_ioeventfd_flag_nr_deassign: _bindgen_ty_4 = 2; +pub const kvm_ioeventfd_flag_nr_virtio_ccw_notify: _bindgen_ty_4 = 3; +pub const kvm_ioeventfd_flag_nr_fast_mmio: _bindgen_ty_4 = 4; +pub const kvm_ioeventfd_flag_nr_max: _bindgen_ty_4 = 5; +pub type _bindgen_ty_4 = ::std::os::raw::c_uint; #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_pv_cmd { - pub cmd: __u32, - pub rc: __u16, - pub rrc: __u16, - pub data: __u64, +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_ioeventfd { + pub datamatch: __u64, + pub addr: __u64, + pub len: __u32, + pub fd: __s32, pub flags: __u32, - pub reserved: [__u32; 3usize], + pub pad: [__u8; 36usize], } #[test] -fn bindgen_test_layout_kvm_pv_cmd() { +fn bindgen_test_layout_kvm_ioeventfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_pv_cmd)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_ioeventfd)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_pv_cmd)) + concat!("Alignment of ", stringify!(kvm_ioeventfd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cmd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).datamatch) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(cmd) + stringify!(datamatch) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rc as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(rc) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rrc as *const _ as usize }, - 6usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(rrc) + stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(data) + stringify!(fd) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 28usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(reserved) + stringify!(pad) ) ); } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_xen_hvm_attr { - pub type_: __u16, - pub pad: [__u16; 3usize], - pub u: kvm_xen_hvm_attr__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_xen_hvm_attr__bindgen_ty_1 { - pub long_mode: __u8, - pub vector: __u8, - pub shared_info: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1, - pub pad: [__u64; 8usize], +impl Default for kvm_ioeventfd { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1 { - pub gfn: __u64, +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_enable_cap { + pub cap: __u32, + pub flags: __u32, + pub args: [__u64; 4usize], + pub pad: [__u8; 64usize], } #[test] -fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_enable_cap() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 104usize, + concat!("Size of: ", stringify!(kvm_enable_cap)) + ); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::align_of::(), 8usize, + concat!("Alignment of ", stringify!(kvm_enable_cap)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cap) as usize - ptr as usize }, + 0usize, concat!( - "Size of: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(cap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(flags) ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, 8usize, concat!( - "Alignment of ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(args) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gfn as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_enable_cap), "::", - stringify!(gfn) + stringify!(pad) ) ); } +impl Default for kvm_enable_cap { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_irqchip { + pub irqchip: __u32, + pub pin: __u32, +} #[test] -fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1() { +fn bindgen_test_layout_kvm_irq_routing_irqchip() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_xen_hvm_attr__bindgen_ty_1)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing_irqchip)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_hvm_attr__bindgen_ty_1)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_irqchip)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).long_mode as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).irqchip) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_irqchip), "::", - stringify!(long_mode) + stringify!(irqchip) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vector as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pin) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_irqchip), "::", - stringify!(vector) + stringify!(pin) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_routing_msi { + pub address_lo: __u32, + pub address_hi: __u32, + pub data: __u32, + pub __bindgen_anon_1: kvm_irq_routing_msi__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_routing_msi__bindgen_ty_1 { + pub pad: __u32, + pub devid: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_msi__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_irq_routing_msi__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_irq_routing_msi__bindgen_ty_1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).shared_info as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_msi__bindgen_ty_1), "::", - stringify!(shared_info) + stringify!(pad) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_msi__bindgen_ty_1), "::", - stringify!(pad) + stringify!(devid) ) ); } -impl Default for kvm_xen_hvm_attr__bindgen_ty_1 { +impl Default for kvm_irq_routing_msi__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -8579,50 +6763,57 @@ impl Default for kvm_xen_hvm_attr__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_irq_routing_msi__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_routing_msi__bindgen_ty_1 {{ union }}") + } +} #[test] -fn bindgen_test_layout_kvm_xen_hvm_attr() { +fn bindgen_test_layout_kvm_irq_routing_msi() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_xen_hvm_attr)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_irq_routing_msi)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_hvm_attr)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_msi)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).address_lo) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr), + stringify!(kvm_irq_routing_msi), "::", - stringify!(type_) + stringify!(address_lo) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).address_hi) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr), + stringify!(kvm_irq_routing_msi), "::", - stringify!(pad) + stringify!(address_hi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr), + stringify!(kvm_irq_routing_msi), "::", - stringify!(u) + stringify!(data) ) ); } -impl Default for kvm_xen_hvm_attr { +impl Default for kvm_irq_routing_msi { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -8631,1598 +6822,1469 @@ impl Default for kvm_xen_hvm_attr { } } } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_xen_vcpu_attr { - pub type_: __u16, - pub pad: [__u16; 3usize], - pub u: kvm_xen_vcpu_attr__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_xen_vcpu_attr__bindgen_ty_1 { - pub gpa: __u64, - pub pad: [__u64; 8usize], - pub runstate: kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1, +impl ::std::fmt::Debug for kvm_irq_routing_msi { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_irq_routing_msi {{ address_lo: {:?}, address_hi: {:?}, data: {:?}, __bindgen_anon_1: {:?} }}" , self . address_lo , self . address_hi , self . data , self . __bindgen_anon_1) + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1 { - pub state: __u64, - pub state_entry_time: __u64, - pub time_running: __u64, - pub time_runnable: __u64, - pub time_blocked: __u64, - pub time_offline: __u64, +pub struct kvm_irq_routing_s390_adapter { + pub ind_addr: __u64, + pub summary_addr: __u64, + pub ind_offset: __u64, + pub summary_offset: __u32, + pub adapter_id: __u32, } #[test] -fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_irq_routing_s390_adapter() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!( - "Size of: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1) - ) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irq_routing_s390_adapter)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1) - ) + concat!("Alignment of ", stringify!(kvm_irq_routing_s390_adapter)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).state - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ind_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(state) + stringify!(ind_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())) - .state_entry_time as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).summary_addr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(state_entry_time) + stringify!(summary_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_running - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ind_offset) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(time_running) + stringify!(ind_offset) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_runnable - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).summary_offset) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(time_runnable) + stringify!(summary_offset) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_blocked - as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).adapter_id) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_s390_adapter), + "::", + stringify!(adapter_id) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_hv_sint { + pub vcpu: __u32, + pub sint: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_hv_sint() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing_hv_sint)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_hv_sint)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_hv_sint), "::", - stringify!(time_blocked) + stringify!(vcpu) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_offline - as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).sint) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_hv_sint), "::", - stringify!(time_offline) + stringify!(sint) ) ); } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_xen_evtchn { + pub port: __u32, + pub vcpu: __u32, + pub priority: __u32, +} #[test] -fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1() { +fn bindgen_test_layout_kvm_irq_routing_xen_evtchn() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_xen_vcpu_attr__bindgen_ty_1)) + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_irq_routing_xen_evtchn)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_vcpu_attr__bindgen_ty_1)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_xen_evtchn)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gpa as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_xen_evtchn), "::", - stringify!(gpa) + stringify!(port) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_xen_evtchn), "::", - stringify!(pad) + stringify!(vcpu) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).runstate as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_xen_evtchn), "::", - stringify!(runstate) + stringify!(priority) ) ); } -impl Default for kvm_xen_vcpu_attr__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_routing_entry { + pub gsi: __u32, + pub type_: __u32, + pub flags: __u32, + pub pad: __u32, + pub u: kvm_irq_routing_entry__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_routing_entry__bindgen_ty_1 { + pub irqchip: kvm_irq_routing_irqchip, + pub msi: kvm_irq_routing_msi, + pub adapter: kvm_irq_routing_s390_adapter, + pub hv_sint: kvm_irq_routing_hv_sint, + pub xen_evtchn: kvm_irq_routing_xen_evtchn, + pub pad: [__u32; 8usize], } #[test] -fn bindgen_test_layout_kvm_xen_vcpu_attr() { +fn bindgen_test_layout_kvm_irq_routing_entry__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_xen_vcpu_attr)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irq_routing_entry__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_xen_vcpu_attr)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_xen_vcpu_attr), - "::", - stringify!(type_) + "Alignment of ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).irqchip) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(pad) + stringify!(irqchip) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).msi) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(u) + stringify!(msi) ) ); -} -impl Default for kvm_xen_vcpu_attr { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub const sev_cmd_id_KVM_SEV_INIT: sev_cmd_id = 0; -pub const sev_cmd_id_KVM_SEV_ES_INIT: sev_cmd_id = 1; -pub const sev_cmd_id_KVM_SEV_LAUNCH_START: sev_cmd_id = 2; -pub const sev_cmd_id_KVM_SEV_LAUNCH_UPDATE_DATA: sev_cmd_id = 3; -pub const sev_cmd_id_KVM_SEV_LAUNCH_UPDATE_VMSA: sev_cmd_id = 4; -pub const sev_cmd_id_KVM_SEV_LAUNCH_SECRET: sev_cmd_id = 5; -pub const sev_cmd_id_KVM_SEV_LAUNCH_MEASURE: sev_cmd_id = 6; -pub const sev_cmd_id_KVM_SEV_LAUNCH_FINISH: sev_cmd_id = 7; -pub const sev_cmd_id_KVM_SEV_SEND_START: sev_cmd_id = 8; -pub const sev_cmd_id_KVM_SEV_SEND_UPDATE_DATA: sev_cmd_id = 9; -pub const sev_cmd_id_KVM_SEV_SEND_UPDATE_VMSA: sev_cmd_id = 10; -pub const sev_cmd_id_KVM_SEV_SEND_FINISH: sev_cmd_id = 11; -pub const sev_cmd_id_KVM_SEV_RECEIVE_START: sev_cmd_id = 12; -pub const sev_cmd_id_KVM_SEV_RECEIVE_UPDATE_DATA: sev_cmd_id = 13; -pub const sev_cmd_id_KVM_SEV_RECEIVE_UPDATE_VMSA: sev_cmd_id = 14; -pub const sev_cmd_id_KVM_SEV_RECEIVE_FINISH: sev_cmd_id = 15; -pub const sev_cmd_id_KVM_SEV_GUEST_STATUS: sev_cmd_id = 16; -pub const sev_cmd_id_KVM_SEV_DBG_DECRYPT: sev_cmd_id = 17; -pub const sev_cmd_id_KVM_SEV_DBG_ENCRYPT: sev_cmd_id = 18; -pub const sev_cmd_id_KVM_SEV_CERT_EXPORT: sev_cmd_id = 19; -pub const sev_cmd_id_KVM_SEV_GET_ATTESTATION_REPORT: sev_cmd_id = 20; -pub const sev_cmd_id_KVM_SEV_SEND_CANCEL: sev_cmd_id = 21; -pub const sev_cmd_id_KVM_SEV_NR_MAX: sev_cmd_id = 22; -pub type sev_cmd_id = ::std::os::raw::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_cmd { - pub id: __u32, - pub data: __u64, - pub error: __u32, - pub sev_fd: __u32, -} -#[test] -fn bindgen_test_layout_kvm_sev_cmd() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_sev_cmd)) - ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_cmd)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).adapter) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(id) + stringify!(adapter) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).hv_sint) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(data) + stringify!(hv_sint) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).error as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).xen_evtchn) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(error) + stringify!(xen_evtchn) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sev_fd as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(sev_fd) + stringify!(pad) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_start { - pub handle: __u32, - pub policy: __u32, - pub dh_uaddr: __u64, - pub dh_len: __u32, - pub session_uaddr: __u64, - pub session_len: __u32, +impl Default for kvm_irq_routing_entry__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_entry__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_routing_entry__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_sev_launch_start() { +fn bindgen_test_layout_kvm_irq_routing_entry() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_sev_launch_start)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_irq_routing_entry)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_start)) + concat!("Alignment of ", stringify!(kvm_irq_routing_entry)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handle as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gsi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry), "::", - stringify!(handle) + stringify!(gsi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry), "::", - stringify!(policy) + stringify!(type_) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dh_uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry), "::", - stringify!(dh_uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dh_len as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry), "::", - stringify!(dh_len) + stringify!(pad) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_uaddr as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry), "::", - stringify!(session_uaddr) + stringify!(u) ) ); - assert_eq!( +} +impl Default for kvm_irq_routing_entry { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).session_len as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_launch_start), - "::", - stringify!(session_len) + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_entry { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_routing_entry {{ gsi: {:?}, type: {:?}, flags: {:?}, pad: {:?}, u: {:?} }}", + self.gsi, self.type_, self.flags, self.pad, self.u ) - ); + } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_update_data { - pub uaddr: __u64, - pub len: __u32, +pub struct kvm_irq_routing { + pub nr: __u32, + pub flags: __u32, + pub entries: __IncompleteArrayField, } #[test] -fn bindgen_test_layout_kvm_sev_launch_update_data() { +fn bindgen_test_layout_kvm_irq_routing() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_sev_launch_update_data)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_update_data)) + concat!("Alignment of ", stringify!(kvm_irq_routing)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_update_data), + stringify!(kvm_irq_routing), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing), "::", - stringify!(uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_update_data), + stringify!(kvm_irq_routing), "::", - stringify!(len) + stringify!(entries) ) ); } +impl Default for kvm_irq_routing { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_routing {{ nr: {:?}, flags: {:?}, entries: {:?} }}", + self.nr, self.flags, self.entries + ) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_secret { - pub hdr_uaddr: __u64, - pub hdr_len: __u32, - pub guest_uaddr: __u64, - pub guest_len: __u32, - pub trans_uaddr: __u64, - pub trans_len: __u32, +pub struct kvm_irqfd { + pub fd: __u32, + pub gsi: __u32, + pub flags: __u32, + pub resamplefd: __u32, + pub pad: [__u8; 16usize], } #[test] -fn bindgen_test_layout_kvm_sev_launch_secret() { +fn bindgen_test_layout_kvm_irqfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_sev_launch_secret)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irqfd)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_secret)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irqfd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr_uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), - "::", - stringify!(hdr_uaddr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr_len as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irqfd), "::", - stringify!(hdr_len) + stringify!(fd) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_uaddr as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).gsi) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irqfd), "::", - stringify!(guest_uaddr) + stringify!(gsi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).guest_len as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irqfd), "::", - stringify!(guest_len) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_uaddr as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).resamplefd) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irqfd), "::", - stringify!(trans_uaddr) + stringify!(resamplefd) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).trans_len as *const _ as usize }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irqfd), "::", - stringify!(trans_len) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_measure { - pub uaddr: __u64, - pub len: __u32, +pub struct kvm_clock_data { + pub clock: __u64, + pub flags: __u32, + pub pad0: __u32, + pub realtime: __u64, + pub host_tsc: __u64, + pub pad: [__u32; 4usize], } #[test] -fn bindgen_test_layout_kvm_sev_launch_measure() { +fn bindgen_test_layout_kvm_clock_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_sev_launch_measure)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_clock_data)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_measure)) + concat!("Alignment of ", stringify!(kvm_clock_data)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).clock) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_measure), + stringify!(kvm_clock_data), "::", - stringify!(uaddr) + stringify!(clock) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_measure), + stringify!(kvm_clock_data), "::", - stringify!(len) + stringify!(flags) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_guest_status { - pub handle: __u32, - pub policy: __u32, - pub state: __u32, -} -#[test] -fn bindgen_test_layout_kvm_sev_guest_status() { assert_eq!( - ::std::mem::size_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, 12usize, - concat!("Size of: ", stringify!(kvm_sev_guest_status)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_sev_guest_status)) + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(pad0) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handle as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).realtime) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_guest_status), + stringify!(kvm_clock_data), "::", - stringify!(handle) + stringify!(realtime) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).host_tsc) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_sev_guest_status), + stringify!(kvm_clock_data), "::", - stringify!(policy) + stringify!(host_tsc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).state as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_sev_guest_status), + stringify!(kvm_clock_data), "::", - stringify!(state) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_dbg { - pub src_uaddr: __u64, - pub dst_uaddr: __u64, - pub len: __u32, +pub struct kvm_config_tlb { + pub params: __u64, + pub array: __u64, + pub mmu_type: __u32, + pub array_len: __u32, } #[test] -fn bindgen_test_layout_kvm_sev_dbg() { +fn bindgen_test_layout_kvm_config_tlb() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 24usize, - concat!("Size of: ", stringify!(kvm_sev_dbg)) + concat!("Size of: ", stringify!(kvm_config_tlb)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_dbg)) + concat!("Alignment of ", stringify!(kvm_config_tlb)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_dbg), - "::", - stringify!(src_uaddr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_uaddr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_dbg), - "::", - stringify!(dst_uaddr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_dbg), + stringify!(kvm_config_tlb), "::", - stringify!(len) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_attestation_report { - pub mnonce: [__u8; 16usize], - pub uaddr: __u64, - pub len: __u32, -} -#[test] -fn bindgen_test_layout_kvm_sev_attestation_report() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_sev_attestation_report)) + stringify!(params) + ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).array) as usize - ptr as usize }, 8usize, - concat!("Alignment of ", stringify!(kvm_sev_attestation_report)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mnonce as *const _ as usize - }, - 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_attestation_report), + stringify!(kvm_config_tlb), "::", - stringify!(mnonce) + stringify!(array) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).mmu_type) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_attestation_report), + stringify!(kvm_config_tlb), "::", - stringify!(uaddr) + stringify!(mmu_type) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).array_len) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_sev_attestation_report), + stringify!(kvm_config_tlb), "::", - stringify!(len) + stringify!(array_len) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_send_start { - pub policy: __u32, - pub pdh_cert_uaddr: __u64, - pub pdh_cert_len: __u32, - pub plat_certs_uaddr: __u64, - pub plat_certs_len: __u32, - pub amd_certs_uaddr: __u64, - pub amd_certs_len: __u32, - pub session_uaddr: __u64, - pub session_len: __u32, +pub struct kvm_dirty_tlb { + pub bitmap: __u64, + pub num_dirty: __u32, } #[test] -fn bindgen_test_layout_kvm_sev_send_start() { +fn bindgen_test_layout_kvm_dirty_tlb() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_sev_send_start)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_tlb)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_send_start)) + concat!("Alignment of ", stringify!(kvm_dirty_tlb)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).bitmap) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_dirty_tlb), "::", - stringify!(policy) + stringify!(bitmap) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pdh_cert_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).num_dirty) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_dirty_tlb), "::", - stringify!(pdh_cert_uaddr) + stringify!(num_dirty) ) ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct kvm_reg_list { + pub n: __u64, + pub reg: __IncompleteArrayField<__u64>, +} +#[test] +fn bindgen_test_layout_kvm_reg_list() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdh_cert_len as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_send_start), - "::", - stringify!(pdh_cert_len) - ) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_reg_list)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).plat_certs_uaddr as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_send_start), - "::", - stringify!(plat_certs_uaddr) - ) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_reg_list)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).plat_certs_len as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).n) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_reg_list), "::", - stringify!(plat_certs_len) + stringify!(n) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).amd_certs_uaddr as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).reg) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_reg_list), "::", - stringify!(amd_certs_uaddr) + stringify!(reg) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_one_reg { + pub id: __u64, + pub addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_one_reg() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).amd_certs_len as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_send_start), - "::", - stringify!(amd_certs_len) - ) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_one_reg)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_uaddr as *const _ as usize - }, - 56usize, + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_one_reg)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_one_reg), "::", - stringify!(session_uaddr) + stringify!(id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).session_len as *const _ as usize }, - 64usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_one_reg), "::", - stringify!(session_len) + stringify!(addr) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_send_update_data { - pub hdr_uaddr: __u64, - pub hdr_len: __u32, - pub guest_uaddr: __u64, - pub guest_len: __u32, - pub trans_uaddr: __u64, - pub trans_len: __u32, +pub struct kvm_msi { + pub address_lo: __u32, + pub address_hi: __u32, + pub data: __u32, + pub flags: __u32, + pub devid: __u32, + pub pad: [__u8; 12usize], } #[test] -fn bindgen_test_layout_kvm_sev_send_update_data() { +fn bindgen_test_layout_kvm_msi() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_sev_send_update_data)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_msi)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_send_update_data)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_msi)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).address_lo) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(hdr_uaddr) + stringify!(address_lo) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_len as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).address_hi) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(hdr_len) + stringify!(address_hi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_uaddr as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(guest_uaddr) + stringify!(data) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_len as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(guest_len) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_uaddr as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(trans_uaddr) + stringify!(devid) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_len as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(trans_len) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_receive_start { - pub handle: __u32, - pub policy: __u32, - pub pdh_uaddr: __u64, - pub pdh_len: __u32, - pub session_uaddr: __u64, - pub session_len: __u32, +pub struct kvm_arm_device_addr { + pub id: __u64, + pub addr: __u64, } #[test] -fn bindgen_test_layout_kvm_sev_receive_start() { +fn bindgen_test_layout_kvm_arm_device_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_sev_receive_start)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_arm_device_addr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_receive_start)) + concat!("Alignment of ", stringify!(kvm_arm_device_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handle as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_arm_device_addr), "::", - stringify!(handle) + stringify!(id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_arm_device_addr), "::", - stringify!(policy) + stringify!(addr) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_create_device { + pub type_: __u32, + pub fd: __u32, + pub flags: __u32, +} +#[test] +fn bindgen_test_layout_kvm_create_device() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdh_uaddr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_receive_start), - "::", - stringify!(pdh_uaddr) - ) + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_create_device)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdh_len as *const _ as usize }, - 16usize, + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_create_device)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_create_device), "::", - stringify!(pdh_len) + stringify!(type_) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_uaddr as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_create_device), "::", - stringify!(session_uaddr) + stringify!(fd) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_len as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_create_device), "::", - stringify!(session_len) + stringify!(flags) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_receive_update_data { - pub hdr_uaddr: __u64, - pub hdr_len: __u32, - pub guest_uaddr: __u64, - pub guest_len: __u32, - pub trans_uaddr: __u64, - pub trans_len: __u32, +pub struct kvm_device_attr { + pub flags: __u32, + pub group: __u32, + pub attr: __u64, + pub addr: __u64, } #[test] -fn bindgen_test_layout_kvm_sev_receive_update_data() { +fn bindgen_test_layout_kvm_device_attr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_sev_receive_update_data)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_device_attr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_receive_update_data)) + concat!("Alignment of ", stringify!(kvm_device_attr)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), - "::", - stringify!(hdr_uaddr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_len as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_receive_update_data), - "::", - stringify!(hdr_len) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_uaddr as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(guest_uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_len as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).group) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(guest_len) + stringify!(group) ) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_uaddr as *const _ as usize - }, - 32usize, + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).attr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(trans_uaddr) + stringify!(attr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_len as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(trans_len) + stringify!(addr) ) ); } +pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20: kvm_device_type = 1; +pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_42: kvm_device_type = 2; +pub const kvm_device_type_KVM_DEV_TYPE_XICS: kvm_device_type = 3; +pub const kvm_device_type_KVM_DEV_TYPE_VFIO: kvm_device_type = 4; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2: kvm_device_type = 5; +pub const kvm_device_type_KVM_DEV_TYPE_FLIC: kvm_device_type = 6; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3: kvm_device_type = 7; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS: kvm_device_type = 8; +pub const kvm_device_type_KVM_DEV_TYPE_XIVE: kvm_device_type = 9; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_PV_TIME: kvm_device_type = 10; +pub const kvm_device_type_KVM_DEV_TYPE_RISCV_AIA: kvm_device_type = 11; +pub const kvm_device_type_KVM_DEV_TYPE_MAX: kvm_device_type = 12; +pub type kvm_device_type = ::std::os::raw::c_uint; #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_assigned_pci_dev { - pub assigned_dev_id: __u32, - pub busnr: __u32, - pub devfn: __u32, - pub flags: __u32, - pub segnr: __u32, - pub __bindgen_anon_1: kvm_assigned_pci_dev__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_assigned_pci_dev__bindgen_ty_1 { - pub reserved: [__u32; 11usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_vfio_spapr_tce { + pub groupfd: __s32, + pub tablefd: __s32, } #[test] -fn bindgen_test_layout_kvm_assigned_pci_dev__bindgen_ty_1() { +fn bindgen_test_layout_kvm_vfio_spapr_tce() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 44usize, - concat!("Size of: ", stringify!(kvm_assigned_pci_dev__bindgen_ty_1)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_vfio_spapr_tce)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, + concat!("Alignment of ", stringify!(kvm_vfio_spapr_tce)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).groupfd) as usize - ptr as usize }, + 0usize, concat!( - "Alignment of ", - stringify!(kvm_assigned_pci_dev__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_vfio_spapr_tce), + "::", + stringify!(groupfd) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).tablefd) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev__bindgen_ty_1), + stringify!(kvm_vfio_spapr_tce), "::", - stringify!(reserved) + stringify!(tablefd) ) ); } -impl Default for kvm_assigned_pci_dev__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_enc_region { + pub addr: __u64, + pub size: __u64, } #[test] -fn bindgen_test_layout_kvm_assigned_pci_dev() { +fn bindgen_test_layout_kvm_enc_region() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_assigned_pci_dev)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_enc_region)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_pci_dev)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_enc_region)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_enc_region), "::", - stringify!(assigned_dev_id) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).busnr as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_enc_region), "::", - stringify!(busnr) + stringify!(size) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_dirty_gfn { + pub flags: __u32, + pub slot: __u32, + pub offset: __u64, +} +#[test] +fn bindgen_test_layout_kvm_dirty_gfn() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_gfn)) + ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).devfn as *const _ as usize }, + ::std::mem::align_of::(), 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_gfn)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_dirty_gfn), "::", - stringify!(devfn) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_dirty_gfn), "::", - stringify!(flags) + stringify!(slot) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).segnr as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_dirty_gfn), "::", - stringify!(segnr) + stringify!(offset) ) ); } -impl Default for kvm_assigned_pci_dev { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} +#[doc = " struct kvm_stats_header - Header of per vm/vcpu binary statistics data.\n @flags: Some extra information for header, always 0 for now.\n @name_size: The size in bytes of the memory which contains statistics\n name string including trailing '\\0'. The memory is allocated\n at the send of statistics descriptor.\n @num_desc: The number of statistics the vm or vcpu has.\n @id_offset: The offset of the vm/vcpu stats' id string in the file pointed\n by vm/vcpu stats fd.\n @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file\n pointd by vm/vcpu stats fd.\n @data_offset: The offset of the vm/vcpu stats' data block in the file\n pointed by vm/vcpu stats fd.\n\n This is the header userspace needs to read from stats fd before any other\n readings. It is used by userspace to discover all the information about the\n vm/vcpu's binary statistics.\n Userspace reads this header from the start of the vm/vcpu's stats fd."] #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_assigned_irq { - pub assigned_dev_id: __u32, - pub host_irq: __u32, - pub guest_irq: __u32, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_stats_header { pub flags: __u32, - pub __bindgen_anon_1: kvm_assigned_irq__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_assigned_irq__bindgen_ty_1 { - pub reserved: [__u32; 12usize], + pub name_size: __u32, + pub num_desc: __u32, + pub id_offset: __u32, + pub desc_offset: __u32, + pub data_offset: __u32, } #[test] -fn bindgen_test_layout_kvm_assigned_irq__bindgen_ty_1() { +fn bindgen_test_layout_kvm_stats_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_assigned_irq__bindgen_ty_1)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_stats_header)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_irq__bindgen_ty_1)) + concat!("Alignment of ", stringify!(kvm_stats_header)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq__bindgen_ty_1), + stringify!(kvm_stats_header), "::", - stringify!(reserved) + stringify!(flags) ) ); -} -impl Default for kvm_assigned_irq__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_assigned_irq() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_assigned_irq)) - ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).name_size) as usize - ptr as usize }, 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_irq)) + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(name_size) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).num_desc) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(assigned_dev_id) + stringify!(num_desc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).host_irq as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).id_offset) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(host_irq) + stringify!(id_offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).guest_irq as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).desc_offset) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(guest_irq) + stringify!(desc_offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).data_offset) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(flags) + stringify!(data_offset) ) ); } -impl Default for kvm_assigned_irq { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} +#[doc = " struct kvm_stats_desc - Descriptor of a KVM statistics.\n @flags: Annotations of the stats, like type, unit, etc.\n @exponent: Used together with @flags to determine the unit.\n @size: The number of data items for this stats.\n Every data item is of type __u64.\n @offset: The offset of the stats to the start of stat structure in\n structure kvm or kvm_vcpu.\n @bucket_size: A parameter value used for histogram stats. It is only used\n\t\tfor linear histogram stats, specifying the size of the bucket;\n @name: The name string for the stats. Its size is indicated by the\n &kvm_stats_header->name_size."] #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_assigned_msix_nr { - pub assigned_dev_id: __u32, - pub entry_nr: __u16, - pub padding: __u16, +#[derive(Debug, Default)] +pub struct kvm_stats_desc { + pub flags: __u32, + pub exponent: __s16, + pub size: __u16, + pub offset: __u32, + pub bucket_size: __u32, + pub name: __IncompleteArrayField<::std::os::raw::c_char>, } #[test] -fn bindgen_test_layout_kvm_assigned_msix_nr() { +fn bindgen_test_layout_kvm_stats_desc() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_assigned_msix_nr)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_stats_desc)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_msix_nr)) + concat!("Alignment of ", stringify!(kvm_stats_desc)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_nr), + stringify!(kvm_stats_desc), "::", - stringify!(assigned_dev_id) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entry_nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exponent) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_nr), + stringify!(kvm_stats_desc), "::", - stringify!(entry_nr) + stringify!(exponent) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_nr), - "::", - stringify!(padding) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_assigned_msix_entry { - pub assigned_dev_id: __u32, - pub gsi: __u32, - pub entry: __u16, - pub padding: [__u16; 3usize], -} -#[test] -fn bindgen_test_layout_kvm_assigned_msix_entry() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_assigned_msix_entry)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_msix_entry)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(assigned_dev_id) + stringify!(size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gsi as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(gsi) + stringify!(offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entry as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).bucket_size) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(entry) + stringify!(bucket_size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 10usize, + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(padding) + stringify!(name) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_eventfd { - pub conn_id: __u32, - pub fd: __s32, - pub flags: __u32, - pub padding: [__u32; 3usize], +pub struct kvm_memory_attributes { + pub address: __u64, + pub size: __u64, + pub attributes: __u64, + pub flags: __u64, } #[test] -fn bindgen_test_layout_kvm_hyperv_eventfd() { +fn bindgen_test_layout_kvm_memory_attributes() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_hyperv_eventfd)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_memory_attributes)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_hyperv_eventfd)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_memory_attributes)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).conn_id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(conn_id) + stringify!(address) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(fd) + stringify!(size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).attributes) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(flags) + stringify!(attributes) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(padding) + stringify!(flags) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_dirty_gfn { - pub flags: __u32, - pub slot: __u32, - pub offset: __u64, +pub struct kvm_create_guest_memfd { + pub size: __u64, + pub flags: __u64, + pub reserved: [__u64; 6usize], } #[test] -fn bindgen_test_layout_kvm_dirty_gfn() { +fn bindgen_test_layout_kvm_create_guest_memfd() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_dirty_gfn)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_create_guest_memfd)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_gfn)) + concat!("Alignment of ", stringify!(kvm_create_guest_memfd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_gfn), + stringify!(kvm_create_guest_memfd), "::", - stringify!(flags) + stringify!(size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_gfn), + stringify!(kvm_create_guest_memfd), "::", - stringify!(slot) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_gfn), + stringify!(kvm_create_guest_memfd), "::", - stringify!(offset) + stringify!(reserved) ) ); } diff --git a/vendor/kvm-bindings/src/arm64/mod.rs b/vendor/kvm-bindings/src/arm64/mod.rs index 75f9cce..50f4703 100644 --- a/vendor/kvm-bindings/src/arm64/mod.rs +++ b/vendor/kvm-bindings/src/arm64/mod.rs @@ -3,12 +3,13 @@ #[allow(clippy::all)] #[allow(clippy::undocumented_unsafe_blocks)] -// Keep this until https://github.com/rust-lang/rust-bindgen/issues/1651 is fixed. -#[cfg_attr(test, allow(deref_nullptr))] pub mod bindings; #[cfg(feature = "fam-wrappers")] pub mod fam_wrappers; +#[cfg(feature = "serde")] +mod serialize; + pub use self::bindings::*; #[cfg(feature = "fam-wrappers")] pub use self::fam_wrappers::*; diff --git a/vendor/kvm-bindings/src/arm64/serialize.rs b/vendor/kvm-bindings/src/arm64/serialize.rs new file mode 100644 index 0000000..9d30201 --- /dev/null +++ b/vendor/kvm-bindings/src/arm64/serialize.rs @@ -0,0 +1,79 @@ +use bindings::{ + kvm_mp_state, kvm_one_reg, kvm_regs, kvm_vcpu_init, user_fpsimd_state, user_pt_regs, +}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use zerocopy::{transmute, AsBytes}; + +serde_impls! { + user_pt_regs, + user_fpsimd_state, + kvm_regs, + kvm_vcpu_init, + kvm_mp_state, + kvm_one_reg +} + +#[cfg(test)] +mod tests { + use bindings::*; + use serde::{Deserialize, Serialize}; + + fn is_serde Deserialize<'de> + Default>() { + let serialized = bincode::serialize(&T::default()).unwrap(); + let deserialized = bincode::deserialize::(serialized.as_ref()).unwrap(); + let serialized_again = bincode::serialize(&deserialized).unwrap(); + // Compare the serialized state after a roundtrip, to work around issues with + // bindings not implementing `PartialEq`. + assert_eq!(serialized, serialized_again); + } + + #[test] + fn static_assert_serde_implementations() { + // This test statically (= at compile-time) asserts that various bindgen generated + // structures implement serde's `Serialize` and `Deserialize` traits. + // This is to make sure that we do not accidentally remove those implementations + // when regenerating bindings. If this test fails to compile, please add + // + // #[cfg_attr( + // feature = "serde", + // derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) + // )] + // + // to all structures causing compilation errors (we need the zerocopy traits, as the + // `Serialize` and `Deserialize` implementations are provided by the `serde_impls!` macro + // above, which implements serialization based on zerocopy's `FromBytes` and `AsBytes` + // traits that it expects to be derived). + // + // NOTE: This only include "top-level" items, and does not list out bindgen-anonymous types + // (e.g. types like `kvm_vcpu_events__bindgen_ty_5`). These types can change name across + // bindgen versions. If after re-adding the derives to all the below items you can compile + // errors about anonymous types not implementing `Serialize`/`Deserialize`, please also add + // the derives to all anonymous types references in the definitions of the below items. + + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + } + + fn is_serde_json Deserialize<'de> + Default>() { + let serialized = serde_json::to_string(&T::default()).unwrap(); + let deserialized = serde_json::from_str::(serialized.as_ref()).unwrap(); + let serialized_again = serde_json::to_string(&deserialized).unwrap(); + // Compare the serialized state after a roundtrip, to work around issues with + // bindings not implementing `PartialEq`. + assert_eq!(serialized, serialized_again); + } + + #[test] + fn test_json_serde() { + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + } +} diff --git a/vendor/kvm-bindings/src/lib.rs b/vendor/kvm-bindings/src/lib.rs index 005808b..c44c98e 100644 --- a/vendor/kvm-bindings/src/lib.rs +++ b/vendor/kvm-bindings/src/lib.rs @@ -6,17 +6,33 @@ #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] -#[macro_use] #[cfg(feature = "fam-wrappers")] +#[macro_use] extern crate vmm_sys_util; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -mod x86; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub use self::x86::*; +#[cfg(feature = "serde")] +extern crate serde; -#[cfg(any(target_arch = "aarch", target_arch = "aarch64"))] +#[cfg(feature = "serde")] +extern crate zerocopy; + +#[cfg(feature = "serde")] +#[macro_use] +mod serialize; + +#[cfg(target_arch = "x86_64")] +mod x86_64; +#[cfg(target_arch = "x86_64")] +pub use self::x86_64::*; + +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] mod arm64; -#[cfg(any(target_arch = "aarch", target_arch = "aarch64"))] +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] pub use self::arm64::*; + +#[cfg(target_arch = "riscv64")] +mod riscv64; +#[cfg(target_arch = "riscv64")] +pub use self::riscv64::*; diff --git a/vendor/kvm-bindings/src/riscv64/bindings.rs b/vendor/kvm-bindings/src/riscv64/bindings.rs new file mode 100644 index 0000000..4bb65fb --- /dev/null +++ b/vendor/kvm-bindings/src/riscv64/bindings.rs @@ -0,0 +1,8307 @@ +/* automatically generated by rust-bindgen 0.64.0 */ + +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +impl __IncompleteArrayField { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +pub const __BITS_PER_LONG_LONG: u32 = 64; +pub const __FD_SETSIZE: u32 = 1024; +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; +pub const _IOC_NRMASK: u32 = 255; +pub const _IOC_TYPEMASK: u32 = 255; +pub const _IOC_SIZEMASK: u32 = 16383; +pub const _IOC_DIRMASK: u32 = 3; +pub const _IOC_NRSHIFT: u32 = 0; +pub const _IOC_TYPESHIFT: u32 = 8; +pub const _IOC_SIZESHIFT: u32 = 16; +pub const _IOC_DIRSHIFT: u32 = 30; +pub const _IOC_NONE: u32 = 0; +pub const _IOC_WRITE: u32 = 1; +pub const _IOC_READ: u32 = 2; +pub const IOC_IN: u32 = 1073741824; +pub const IOC_OUT: u32 = 2147483648; +pub const IOC_INOUT: u32 = 3221225472; +pub const IOCSIZE_MASK: u32 = 1073676288; +pub const IOCSIZE_SHIFT: u32 = 16; +pub const PTRACE_GETFDPIC: u32 = 33; +pub const PTRACE_GETFDPIC_EXEC: u32 = 0; +pub const PTRACE_GETFDPIC_INTERP: u32 = 1; +pub const RISCV_MAX_VLENB: u32 = 8192; +pub const KVM_COALESCED_MMIO_PAGE_OFFSET: u32 = 1; +pub const KVM_INTERRUPT_SET: i32 = -1; +pub const KVM_INTERRUPT_UNSET: i32 = -2; +pub const KVM_RISCV_MODE_S: u32 = 1; +pub const KVM_RISCV_MODE_U: u32 = 0; +pub const KVM_RISCV_TIMER_STATE_OFF: u32 = 0; +pub const KVM_RISCV_TIMER_STATE_ON: u32 = 1; +pub const KVM_REG_RISCV_TYPE_MASK: u32 = 4278190080; +pub const KVM_REG_RISCV_TYPE_SHIFT: u32 = 24; +pub const KVM_REG_RISCV_SUBTYPE_MASK: u32 = 16711680; +pub const KVM_REG_RISCV_SUBTYPE_SHIFT: u32 = 16; +pub const KVM_REG_RISCV_CONFIG: u32 = 16777216; +pub const KVM_REG_RISCV_CORE: u32 = 33554432; +pub const KVM_REG_RISCV_CSR: u32 = 50331648; +pub const KVM_REG_RISCV_CSR_GENERAL: u32 = 0; +pub const KVM_REG_RISCV_CSR_AIA: u32 = 65536; +pub const KVM_REG_RISCV_CSR_SMSTATEEN: u32 = 131072; +pub const KVM_REG_RISCV_TIMER: u32 = 67108864; +pub const KVM_REG_RISCV_FP_F: u32 = 83886080; +pub const KVM_REG_RISCV_FP_D: u32 = 100663296; +pub const KVM_REG_RISCV_ISA_EXT: u32 = 117440512; +pub const KVM_REG_RISCV_ISA_SINGLE: u32 = 0; +pub const KVM_REG_RISCV_ISA_MULTI_EN: u32 = 65536; +pub const KVM_REG_RISCV_ISA_MULTI_DIS: u32 = 131072; +pub const KVM_REG_RISCV_SBI_EXT: u32 = 134217728; +pub const KVM_REG_RISCV_SBI_SINGLE: u32 = 0; +pub const KVM_REG_RISCV_SBI_MULTI_EN: u32 = 65536; +pub const KVM_REG_RISCV_SBI_MULTI_DIS: u32 = 131072; +pub const KVM_REG_RISCV_VECTOR: u32 = 150994944; +pub const KVM_REG_RISCV_SBI_STATE: u32 = 167772160; +pub const KVM_REG_RISCV_SBI_STA: u32 = 0; +pub const KVM_DEV_RISCV_APLIC_ALIGN: u32 = 4096; +pub const KVM_DEV_RISCV_APLIC_SIZE: u32 = 16384; +pub const KVM_DEV_RISCV_APLIC_MAX_HARTS: u32 = 16384; +pub const KVM_DEV_RISCV_IMSIC_ALIGN: u32 = 4096; +pub const KVM_DEV_RISCV_IMSIC_SIZE: u32 = 4096; +pub const KVM_DEV_RISCV_AIA_GRP_CONFIG: u32 = 0; +pub const KVM_DEV_RISCV_AIA_CONFIG_MODE: u32 = 0; +pub const KVM_DEV_RISCV_AIA_CONFIG_IDS: u32 = 1; +pub const KVM_DEV_RISCV_AIA_CONFIG_SRCS: u32 = 2; +pub const KVM_DEV_RISCV_AIA_CONFIG_GROUP_BITS: u32 = 3; +pub const KVM_DEV_RISCV_AIA_CONFIG_GROUP_SHIFT: u32 = 4; +pub const KVM_DEV_RISCV_AIA_CONFIG_HART_BITS: u32 = 5; +pub const KVM_DEV_RISCV_AIA_CONFIG_GUEST_BITS: u32 = 6; +pub const KVM_DEV_RISCV_AIA_MODE_EMUL: u32 = 0; +pub const KVM_DEV_RISCV_AIA_MODE_HWACCEL: u32 = 1; +pub const KVM_DEV_RISCV_AIA_MODE_AUTO: u32 = 2; +pub const KVM_DEV_RISCV_AIA_IDS_MIN: u32 = 63; +pub const KVM_DEV_RISCV_AIA_IDS_MAX: u32 = 2048; +pub const KVM_DEV_RISCV_AIA_SRCS_MAX: u32 = 1024; +pub const KVM_DEV_RISCV_AIA_GROUP_BITS_MAX: u32 = 8; +pub const KVM_DEV_RISCV_AIA_GROUP_SHIFT_MIN: u32 = 24; +pub const KVM_DEV_RISCV_AIA_GROUP_SHIFT_MAX: u32 = 56; +pub const KVM_DEV_RISCV_AIA_HART_BITS_MAX: u32 = 16; +pub const KVM_DEV_RISCV_AIA_GUEST_BITS_MAX: u32 = 8; +pub const KVM_DEV_RISCV_AIA_GRP_ADDR: u32 = 1; +pub const KVM_DEV_RISCV_AIA_ADDR_APLIC: u32 = 0; +pub const KVM_DEV_RISCV_AIA_ADDR_MAX: u32 = 16385; +pub const KVM_DEV_RISCV_AIA_GRP_CTRL: u32 = 2; +pub const KVM_DEV_RISCV_AIA_CTRL_INIT: u32 = 0; +pub const KVM_DEV_RISCV_AIA_GRP_APLIC: u32 = 3; +pub const KVM_DEV_RISCV_AIA_GRP_IMSIC: u32 = 4; +pub const KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS: u32 = 12; +pub const KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK: u32 = 4095; +pub const KVM_NR_IRQCHIPS: u32 = 1; +pub const KVM_API_VERSION: u32 = 12; +pub const KVM_MEM_LOG_DIRTY_PAGES: u32 = 1; +pub const KVM_MEM_READONLY: u32 = 2; +pub const KVM_MEM_GUEST_MEMFD: u32 = 4; +pub const KVM_PIT_SPEAKER_DUMMY: u32 = 1; +pub const KVM_EXIT_HYPERV_SYNIC: u32 = 1; +pub const KVM_EXIT_HYPERV_HCALL: u32 = 2; +pub const KVM_EXIT_HYPERV_SYNDBG: u32 = 3; +pub const KVM_EXIT_XEN_HCALL: u32 = 1; +pub const KVM_S390_GET_SKEYS_NONE: u32 = 1; +pub const KVM_S390_SKEYS_MAX: u32 = 1048576; +pub const KVM_EXIT_UNKNOWN: u32 = 0; +pub const KVM_EXIT_EXCEPTION: u32 = 1; +pub const KVM_EXIT_IO: u32 = 2; +pub const KVM_EXIT_HYPERCALL: u32 = 3; +pub const KVM_EXIT_DEBUG: u32 = 4; +pub const KVM_EXIT_HLT: u32 = 5; +pub const KVM_EXIT_MMIO: u32 = 6; +pub const KVM_EXIT_IRQ_WINDOW_OPEN: u32 = 7; +pub const KVM_EXIT_SHUTDOWN: u32 = 8; +pub const KVM_EXIT_FAIL_ENTRY: u32 = 9; +pub const KVM_EXIT_INTR: u32 = 10; +pub const KVM_EXIT_SET_TPR: u32 = 11; +pub const KVM_EXIT_TPR_ACCESS: u32 = 12; +pub const KVM_EXIT_S390_SIEIC: u32 = 13; +pub const KVM_EXIT_S390_RESET: u32 = 14; +pub const KVM_EXIT_DCR: u32 = 15; +pub const KVM_EXIT_NMI: u32 = 16; +pub const KVM_EXIT_INTERNAL_ERROR: u32 = 17; +pub const KVM_EXIT_OSI: u32 = 18; +pub const KVM_EXIT_PAPR_HCALL: u32 = 19; +pub const KVM_EXIT_S390_UCONTROL: u32 = 20; +pub const KVM_EXIT_WATCHDOG: u32 = 21; +pub const KVM_EXIT_S390_TSCH: u32 = 22; +pub const KVM_EXIT_EPR: u32 = 23; +pub const KVM_EXIT_SYSTEM_EVENT: u32 = 24; +pub const KVM_EXIT_S390_STSI: u32 = 25; +pub const KVM_EXIT_IOAPIC_EOI: u32 = 26; +pub const KVM_EXIT_HYPERV: u32 = 27; +pub const KVM_EXIT_ARM_NISV: u32 = 28; +pub const KVM_EXIT_X86_RDMSR: u32 = 29; +pub const KVM_EXIT_X86_WRMSR: u32 = 30; +pub const KVM_EXIT_DIRTY_RING_FULL: u32 = 31; +pub const KVM_EXIT_AP_RESET_HOLD: u32 = 32; +pub const KVM_EXIT_X86_BUS_LOCK: u32 = 33; +pub const KVM_EXIT_XEN: u32 = 34; +pub const KVM_EXIT_RISCV_SBI: u32 = 35; +pub const KVM_EXIT_RISCV_CSR: u32 = 36; +pub const KVM_EXIT_NOTIFY: u32 = 37; +pub const KVM_EXIT_LOONGARCH_IOCSR: u32 = 38; +pub const KVM_EXIT_MEMORY_FAULT: u32 = 39; +pub const KVM_INTERNAL_ERROR_EMULATION: u32 = 1; +pub const KVM_INTERNAL_ERROR_SIMUL_EX: u32 = 2; +pub const KVM_INTERNAL_ERROR_DELIVERY_EV: u32 = 3; +pub const KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON: u32 = 4; +pub const KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES: u32 = 1; +pub const KVM_EXIT_IO_IN: u32 = 0; +pub const KVM_EXIT_IO_OUT: u32 = 1; +pub const KVM_SYSTEM_EVENT_SHUTDOWN: u32 = 1; +pub const KVM_SYSTEM_EVENT_RESET: u32 = 2; +pub const KVM_SYSTEM_EVENT_CRASH: u32 = 3; +pub const KVM_SYSTEM_EVENT_WAKEUP: u32 = 4; +pub const KVM_SYSTEM_EVENT_SUSPEND: u32 = 5; +pub const KVM_SYSTEM_EVENT_SEV_TERM: u32 = 6; +pub const KVM_MSR_EXIT_REASON_INVAL: u32 = 1; +pub const KVM_MSR_EXIT_REASON_UNKNOWN: u32 = 2; +pub const KVM_MSR_EXIT_REASON_FILTER: u32 = 4; +pub const KVM_MSR_EXIT_REASON_VALID_MASK: u32 = 7; +pub const KVM_NOTIFY_CONTEXT_INVALID: u32 = 1; +pub const KVM_MEMORY_EXIT_FLAG_PRIVATE: u32 = 8; +pub const SYNC_REGS_SIZE_BYTES: u32 = 2048; +pub const KVM_MP_STATE_RUNNABLE: u32 = 0; +pub const KVM_MP_STATE_UNINITIALIZED: u32 = 1; +pub const KVM_MP_STATE_INIT_RECEIVED: u32 = 2; +pub const KVM_MP_STATE_HALTED: u32 = 3; +pub const KVM_MP_STATE_SIPI_RECEIVED: u32 = 4; +pub const KVM_MP_STATE_STOPPED: u32 = 5; +pub const KVM_MP_STATE_CHECK_STOP: u32 = 6; +pub const KVM_MP_STATE_OPERATING: u32 = 7; +pub const KVM_MP_STATE_LOAD: u32 = 8; +pub const KVM_MP_STATE_AP_RESET_HOLD: u32 = 9; +pub const KVM_MP_STATE_SUSPENDED: u32 = 10; +pub const KVM_GUESTDBG_ENABLE: u32 = 1; +pub const KVM_GUESTDBG_SINGLESTEP: u32 = 2; +pub const KVM_X86_DISABLE_EXITS_MWAIT: u32 = 1; +pub const KVM_X86_DISABLE_EXITS_HLT: u32 = 2; +pub const KVM_X86_DISABLE_EXITS_PAUSE: u32 = 4; +pub const KVM_X86_DISABLE_EXITS_CSTATE: u32 = 8; +pub const KVM_X86_DISABLE_VALID_EXITS: u32 = 15; +pub const KVMIO: u32 = 174; +pub const KVM_VM_S390_UCONTROL: u32 = 1; +pub const KVM_VM_PPC_HV: u32 = 1; +pub const KVM_VM_PPC_PR: u32 = 2; +pub const KVM_VM_MIPS_AUTO: u32 = 0; +pub const KVM_VM_MIPS_VZ: u32 = 1; +pub const KVM_VM_MIPS_TE: u32 = 2; +pub const KVM_S390_SIE_PAGE_OFFSET: u32 = 1; +pub const KVM_VM_TYPE_ARM_IPA_SIZE_MASK: u32 = 255; +pub const KVM_CAP_IRQCHIP: u32 = 0; +pub const KVM_CAP_HLT: u32 = 1; +pub const KVM_CAP_MMU_SHADOW_CACHE_CONTROL: u32 = 2; +pub const KVM_CAP_USER_MEMORY: u32 = 3; +pub const KVM_CAP_SET_TSS_ADDR: u32 = 4; +pub const KVM_CAP_VAPIC: u32 = 6; +pub const KVM_CAP_EXT_CPUID: u32 = 7; +pub const KVM_CAP_CLOCKSOURCE: u32 = 8; +pub const KVM_CAP_NR_VCPUS: u32 = 9; +pub const KVM_CAP_NR_MEMSLOTS: u32 = 10; +pub const KVM_CAP_PIT: u32 = 11; +pub const KVM_CAP_NOP_IO_DELAY: u32 = 12; +pub const KVM_CAP_PV_MMU: u32 = 13; +pub const KVM_CAP_MP_STATE: u32 = 14; +pub const KVM_CAP_COALESCED_MMIO: u32 = 15; +pub const KVM_CAP_SYNC_MMU: u32 = 16; +pub const KVM_CAP_IOMMU: u32 = 18; +pub const KVM_CAP_DESTROY_MEMORY_REGION_WORKS: u32 = 21; +pub const KVM_CAP_USER_NMI: u32 = 22; +pub const KVM_CAP_SET_GUEST_DEBUG: u32 = 23; +pub const KVM_CAP_IRQ_ROUTING: u32 = 25; +pub const KVM_CAP_IRQ_INJECT_STATUS: u32 = 26; +pub const KVM_CAP_ASSIGN_DEV_IRQ: u32 = 29; +pub const KVM_CAP_JOIN_MEMORY_REGIONS_WORKS: u32 = 30; +pub const KVM_CAP_IRQFD: u32 = 32; +pub const KVM_CAP_SET_BOOT_CPU_ID: u32 = 34; +pub const KVM_CAP_IOEVENTFD: u32 = 36; +pub const KVM_CAP_SET_IDENTITY_MAP_ADDR: u32 = 37; +pub const KVM_CAP_ADJUST_CLOCK: u32 = 39; +pub const KVM_CAP_INTERNAL_ERROR_DATA: u32 = 40; +pub const KVM_CAP_S390_PSW: u32 = 42; +pub const KVM_CAP_PPC_SEGSTATE: u32 = 43; +pub const KVM_CAP_HYPERV: u32 = 44; +pub const KVM_CAP_HYPERV_VAPIC: u32 = 45; +pub const KVM_CAP_HYPERV_SPIN: u32 = 46; +pub const KVM_CAP_PCI_SEGMENT: u32 = 47; +pub const KVM_CAP_PPC_PAIRED_SINGLES: u32 = 48; +pub const KVM_CAP_INTR_SHADOW: u32 = 49; +pub const KVM_CAP_X86_ROBUST_SINGLESTEP: u32 = 51; +pub const KVM_CAP_PPC_OSI: u32 = 52; +pub const KVM_CAP_PPC_UNSET_IRQ: u32 = 53; +pub const KVM_CAP_ENABLE_CAP: u32 = 54; +pub const KVM_CAP_PPC_GET_PVINFO: u32 = 57; +pub const KVM_CAP_PPC_IRQ_LEVEL: u32 = 58; +pub const KVM_CAP_ASYNC_PF: u32 = 59; +pub const KVM_CAP_TSC_CONTROL: u32 = 60; +pub const KVM_CAP_GET_TSC_KHZ: u32 = 61; +pub const KVM_CAP_PPC_BOOKE_SREGS: u32 = 62; +pub const KVM_CAP_SPAPR_TCE: u32 = 63; +pub const KVM_CAP_PPC_SMT: u32 = 64; +pub const KVM_CAP_PPC_RMA: u32 = 65; +pub const KVM_CAP_MAX_VCPUS: u32 = 66; +pub const KVM_CAP_PPC_HIOR: u32 = 67; +pub const KVM_CAP_PPC_PAPR: u32 = 68; +pub const KVM_CAP_SW_TLB: u32 = 69; +pub const KVM_CAP_ONE_REG: u32 = 70; +pub const KVM_CAP_S390_GMAP: u32 = 71; +pub const KVM_CAP_TSC_DEADLINE_TIMER: u32 = 72; +pub const KVM_CAP_S390_UCONTROL: u32 = 73; +pub const KVM_CAP_SYNC_REGS: u32 = 74; +pub const KVM_CAP_PCI_2_3: u32 = 75; +pub const KVM_CAP_KVMCLOCK_CTRL: u32 = 76; +pub const KVM_CAP_SIGNAL_MSI: u32 = 77; +pub const KVM_CAP_PPC_GET_SMMU_INFO: u32 = 78; +pub const KVM_CAP_S390_COW: u32 = 79; +pub const KVM_CAP_PPC_ALLOC_HTAB: u32 = 80; +pub const KVM_CAP_READONLY_MEM: u32 = 81; +pub const KVM_CAP_IRQFD_RESAMPLE: u32 = 82; +pub const KVM_CAP_PPC_BOOKE_WATCHDOG: u32 = 83; +pub const KVM_CAP_PPC_HTAB_FD: u32 = 84; +pub const KVM_CAP_S390_CSS_SUPPORT: u32 = 85; +pub const KVM_CAP_PPC_EPR: u32 = 86; +pub const KVM_CAP_ARM_PSCI: u32 = 87; +pub const KVM_CAP_ARM_SET_DEVICE_ADDR: u32 = 88; +pub const KVM_CAP_DEVICE_CTRL: u32 = 89; +pub const KVM_CAP_IRQ_MPIC: u32 = 90; +pub const KVM_CAP_PPC_RTAS: u32 = 91; +pub const KVM_CAP_IRQ_XICS: u32 = 92; +pub const KVM_CAP_ARM_EL1_32BIT: u32 = 93; +pub const KVM_CAP_SPAPR_MULTITCE: u32 = 94; +pub const KVM_CAP_EXT_EMUL_CPUID: u32 = 95; +pub const KVM_CAP_HYPERV_TIME: u32 = 96; +pub const KVM_CAP_IOAPIC_POLARITY_IGNORED: u32 = 97; +pub const KVM_CAP_ENABLE_CAP_VM: u32 = 98; +pub const KVM_CAP_S390_IRQCHIP: u32 = 99; +pub const KVM_CAP_IOEVENTFD_NO_LENGTH: u32 = 100; +pub const KVM_CAP_VM_ATTRIBUTES: u32 = 101; +pub const KVM_CAP_ARM_PSCI_0_2: u32 = 102; +pub const KVM_CAP_PPC_FIXUP_HCALL: u32 = 103; +pub const KVM_CAP_PPC_ENABLE_HCALL: u32 = 104; +pub const KVM_CAP_CHECK_EXTENSION_VM: u32 = 105; +pub const KVM_CAP_S390_USER_SIGP: u32 = 106; +pub const KVM_CAP_S390_VECTOR_REGISTERS: u32 = 107; +pub const KVM_CAP_S390_MEM_OP: u32 = 108; +pub const KVM_CAP_S390_USER_STSI: u32 = 109; +pub const KVM_CAP_S390_SKEYS: u32 = 110; +pub const KVM_CAP_MIPS_FPU: u32 = 111; +pub const KVM_CAP_MIPS_MSA: u32 = 112; +pub const KVM_CAP_S390_INJECT_IRQ: u32 = 113; +pub const KVM_CAP_S390_IRQ_STATE: u32 = 114; +pub const KVM_CAP_PPC_HWRNG: u32 = 115; +pub const KVM_CAP_DISABLE_QUIRKS: u32 = 116; +pub const KVM_CAP_X86_SMM: u32 = 117; +pub const KVM_CAP_MULTI_ADDRESS_SPACE: u32 = 118; +pub const KVM_CAP_GUEST_DEBUG_HW_BPS: u32 = 119; +pub const KVM_CAP_GUEST_DEBUG_HW_WPS: u32 = 120; +pub const KVM_CAP_SPLIT_IRQCHIP: u32 = 121; +pub const KVM_CAP_IOEVENTFD_ANY_LENGTH: u32 = 122; +pub const KVM_CAP_HYPERV_SYNIC: u32 = 123; +pub const KVM_CAP_S390_RI: u32 = 124; +pub const KVM_CAP_SPAPR_TCE_64: u32 = 125; +pub const KVM_CAP_ARM_PMU_V3: u32 = 126; +pub const KVM_CAP_VCPU_ATTRIBUTES: u32 = 127; +pub const KVM_CAP_MAX_VCPU_ID: u32 = 128; +pub const KVM_CAP_X2APIC_API: u32 = 129; +pub const KVM_CAP_S390_USER_INSTR0: u32 = 130; +pub const KVM_CAP_MSI_DEVID: u32 = 131; +pub const KVM_CAP_PPC_HTM: u32 = 132; +pub const KVM_CAP_SPAPR_RESIZE_HPT: u32 = 133; +pub const KVM_CAP_PPC_MMU_RADIX: u32 = 134; +pub const KVM_CAP_PPC_MMU_HASH_V3: u32 = 135; +pub const KVM_CAP_IMMEDIATE_EXIT: u32 = 136; +pub const KVM_CAP_MIPS_VZ: u32 = 137; +pub const KVM_CAP_MIPS_TE: u32 = 138; +pub const KVM_CAP_MIPS_64BIT: u32 = 139; +pub const KVM_CAP_S390_GS: u32 = 140; +pub const KVM_CAP_S390_AIS: u32 = 141; +pub const KVM_CAP_SPAPR_TCE_VFIO: u32 = 142; +pub const KVM_CAP_X86_DISABLE_EXITS: u32 = 143; +pub const KVM_CAP_ARM_USER_IRQ: u32 = 144; +pub const KVM_CAP_S390_CMMA_MIGRATION: u32 = 145; +pub const KVM_CAP_PPC_FWNMI: u32 = 146; +pub const KVM_CAP_PPC_SMT_POSSIBLE: u32 = 147; +pub const KVM_CAP_HYPERV_SYNIC2: u32 = 148; +pub const KVM_CAP_HYPERV_VP_INDEX: u32 = 149; +pub const KVM_CAP_S390_AIS_MIGRATION: u32 = 150; +pub const KVM_CAP_PPC_GET_CPU_CHAR: u32 = 151; +pub const KVM_CAP_S390_BPB: u32 = 152; +pub const KVM_CAP_GET_MSR_FEATURES: u32 = 153; +pub const KVM_CAP_HYPERV_EVENTFD: u32 = 154; +pub const KVM_CAP_HYPERV_TLBFLUSH: u32 = 155; +pub const KVM_CAP_S390_HPAGE_1M: u32 = 156; +pub const KVM_CAP_NESTED_STATE: u32 = 157; +pub const KVM_CAP_ARM_INJECT_SERROR_ESR: u32 = 158; +pub const KVM_CAP_MSR_PLATFORM_INFO: u32 = 159; +pub const KVM_CAP_PPC_NESTED_HV: u32 = 160; +pub const KVM_CAP_HYPERV_SEND_IPI: u32 = 161; +pub const KVM_CAP_COALESCED_PIO: u32 = 162; +pub const KVM_CAP_HYPERV_ENLIGHTENED_VMCS: u32 = 163; +pub const KVM_CAP_EXCEPTION_PAYLOAD: u32 = 164; +pub const KVM_CAP_ARM_VM_IPA_SIZE: u32 = 165; +pub const KVM_CAP_MANUAL_DIRTY_LOG_PROTECT: u32 = 166; +pub const KVM_CAP_HYPERV_CPUID: u32 = 167; +pub const KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2: u32 = 168; +pub const KVM_CAP_PPC_IRQ_XIVE: u32 = 169; +pub const KVM_CAP_ARM_SVE: u32 = 170; +pub const KVM_CAP_ARM_PTRAUTH_ADDRESS: u32 = 171; +pub const KVM_CAP_ARM_PTRAUTH_GENERIC: u32 = 172; +pub const KVM_CAP_PMU_EVENT_FILTER: u32 = 173; +pub const KVM_CAP_ARM_IRQ_LINE_LAYOUT_2: u32 = 174; +pub const KVM_CAP_HYPERV_DIRECT_TLBFLUSH: u32 = 175; +pub const KVM_CAP_PPC_GUEST_DEBUG_SSTEP: u32 = 176; +pub const KVM_CAP_ARM_NISV_TO_USER: u32 = 177; +pub const KVM_CAP_ARM_INJECT_EXT_DABT: u32 = 178; +pub const KVM_CAP_S390_VCPU_RESETS: u32 = 179; +pub const KVM_CAP_S390_PROTECTED: u32 = 180; +pub const KVM_CAP_PPC_SECURE_GUEST: u32 = 181; +pub const KVM_CAP_HALT_POLL: u32 = 182; +pub const KVM_CAP_ASYNC_PF_INT: u32 = 183; +pub const KVM_CAP_LAST_CPU: u32 = 184; +pub const KVM_CAP_SMALLER_MAXPHYADDR: u32 = 185; +pub const KVM_CAP_S390_DIAG318: u32 = 186; +pub const KVM_CAP_STEAL_TIME: u32 = 187; +pub const KVM_CAP_X86_USER_SPACE_MSR: u32 = 188; +pub const KVM_CAP_X86_MSR_FILTER: u32 = 189; +pub const KVM_CAP_ENFORCE_PV_FEATURE_CPUID: u32 = 190; +pub const KVM_CAP_SYS_HYPERV_CPUID: u32 = 191; +pub const KVM_CAP_DIRTY_LOG_RING: u32 = 192; +pub const KVM_CAP_X86_BUS_LOCK_EXIT: u32 = 193; +pub const KVM_CAP_PPC_DAWR1: u32 = 194; +pub const KVM_CAP_SET_GUEST_DEBUG2: u32 = 195; +pub const KVM_CAP_SGX_ATTRIBUTE: u32 = 196; +pub const KVM_CAP_VM_COPY_ENC_CONTEXT_FROM: u32 = 197; +pub const KVM_CAP_PTP_KVM: u32 = 198; +pub const KVM_CAP_HYPERV_ENFORCE_CPUID: u32 = 199; +pub const KVM_CAP_SREGS2: u32 = 200; +pub const KVM_CAP_EXIT_HYPERCALL: u32 = 201; +pub const KVM_CAP_PPC_RPT_INVALIDATE: u32 = 202; +pub const KVM_CAP_BINARY_STATS_FD: u32 = 203; +pub const KVM_CAP_EXIT_ON_EMULATION_FAILURE: u32 = 204; +pub const KVM_CAP_ARM_MTE: u32 = 205; +pub const KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM: u32 = 206; +pub const KVM_CAP_VM_GPA_BITS: u32 = 207; +pub const KVM_CAP_XSAVE2: u32 = 208; +pub const KVM_CAP_SYS_ATTRIBUTES: u32 = 209; +pub const KVM_CAP_PPC_AIL_MODE_3: u32 = 210; +pub const KVM_CAP_S390_MEM_OP_EXTENSION: u32 = 211; +pub const KVM_CAP_PMU_CAPABILITY: u32 = 212; +pub const KVM_CAP_DISABLE_QUIRKS2: u32 = 213; +pub const KVM_CAP_VM_TSC_CONTROL: u32 = 214; +pub const KVM_CAP_SYSTEM_EVENT_DATA: u32 = 215; +pub const KVM_CAP_ARM_SYSTEM_SUSPEND: u32 = 216; +pub const KVM_CAP_S390_PROTECTED_DUMP: u32 = 217; +pub const KVM_CAP_X86_TRIPLE_FAULT_EVENT: u32 = 218; +pub const KVM_CAP_X86_NOTIFY_VMEXIT: u32 = 219; +pub const KVM_CAP_VM_DISABLE_NX_HUGE_PAGES: u32 = 220; +pub const KVM_CAP_S390_ZPCI_OP: u32 = 221; +pub const KVM_CAP_S390_CPU_TOPOLOGY: u32 = 222; +pub const KVM_CAP_DIRTY_LOG_RING_ACQ_REL: u32 = 223; +pub const KVM_CAP_S390_PROTECTED_ASYNC_DISABLE: u32 = 224; +pub const KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP: u32 = 225; +pub const KVM_CAP_PMU_EVENT_MASKED_EVENTS: u32 = 226; +pub const KVM_CAP_COUNTER_OFFSET: u32 = 227; +pub const KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE: u32 = 228; +pub const KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES: u32 = 229; +pub const KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES: u32 = 230; +pub const KVM_CAP_USER_MEMORY2: u32 = 231; +pub const KVM_CAP_MEMORY_FAULT_INFO: u32 = 232; +pub const KVM_CAP_MEMORY_ATTRIBUTES: u32 = 233; +pub const KVM_CAP_GUEST_MEMFD: u32 = 234; +pub const KVM_CAP_VM_TYPES: u32 = 235; +pub const KVM_IRQ_ROUTING_IRQCHIP: u32 = 1; +pub const KVM_IRQ_ROUTING_MSI: u32 = 2; +pub const KVM_IRQ_ROUTING_S390_ADAPTER: u32 = 3; +pub const KVM_IRQ_ROUTING_HV_SINT: u32 = 4; +pub const KVM_IRQ_ROUTING_XEN_EVTCHN: u32 = 5; +pub const KVM_IRQFD_FLAG_DEASSIGN: u32 = 1; +pub const KVM_IRQFD_FLAG_RESAMPLE: u32 = 2; +pub const KVM_CLOCK_TSC_STABLE: u32 = 2; +pub const KVM_CLOCK_REALTIME: u32 = 4; +pub const KVM_CLOCK_HOST_TSC: u32 = 8; +pub const KVM_MMU_FSL_BOOKE_NOHV: u32 = 0; +pub const KVM_MMU_FSL_BOOKE_HV: u32 = 1; +pub const KVM_REG_ARCH_MASK: i64 = -72057594037927936; +pub const KVM_REG_GENERIC: u32 = 0; +pub const KVM_REG_PPC: u64 = 1152921504606846976; +pub const KVM_REG_X86: u64 = 2305843009213693952; +pub const KVM_REG_IA64: u64 = 3458764513820540928; +pub const KVM_REG_ARM: u64 = 4611686018427387904; +pub const KVM_REG_S390: u64 = 5764607523034234880; +pub const KVM_REG_ARM64: u64 = 6917529027641081856; +pub const KVM_REG_MIPS: u64 = 8070450532247928832; +pub const KVM_REG_RISCV: i64 = -9223372036854775808; +pub const KVM_REG_LOONGARCH: i64 = -8070450532247928832; +pub const KVM_REG_SIZE_SHIFT: u32 = 52; +pub const KVM_REG_SIZE_MASK: u64 = 67553994410557440; +pub const KVM_REG_SIZE_U8: u32 = 0; +pub const KVM_REG_SIZE_U16: u64 = 4503599627370496; +pub const KVM_REG_SIZE_U32: u64 = 9007199254740992; +pub const KVM_REG_SIZE_U64: u64 = 13510798882111488; +pub const KVM_REG_SIZE_U128: u64 = 18014398509481984; +pub const KVM_REG_SIZE_U256: u64 = 22517998136852480; +pub const KVM_REG_SIZE_U512: u64 = 27021597764222976; +pub const KVM_REG_SIZE_U1024: u64 = 31525197391593472; +pub const KVM_REG_SIZE_U2048: u64 = 36028797018963968; +pub const KVM_MSI_VALID_DEVID: u32 = 1; +pub const KVM_CREATE_DEVICE_TEST: u32 = 1; +pub const KVM_DEV_VFIO_FILE: u32 = 1; +pub const KVM_DEV_VFIO_FILE_ADD: u32 = 1; +pub const KVM_DEV_VFIO_FILE_DEL: u32 = 2; +pub const KVM_DEV_VFIO_GROUP: u32 = 1; +pub const KVM_DEV_VFIO_GROUP_ADD: u32 = 1; +pub const KVM_DEV_VFIO_GROUP_DEL: u32 = 2; +pub const KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE: u32 = 3; +pub const KVM_S390_STORE_STATUS_NOADDR: i32 = -1; +pub const KVM_S390_STORE_STATUS_PREFIXED: i32 = -2; +pub const KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE: u32 = 1; +pub const KVM_DIRTY_LOG_INITIALLY_SET: u32 = 2; +pub const KVM_DIRTY_LOG_PAGE_OFFSET: u32 = 0; +pub const KVM_DIRTY_GFN_F_MASK: u32 = 3; +pub const KVM_BUS_LOCK_DETECTION_OFF: u32 = 1; +pub const KVM_BUS_LOCK_DETECTION_EXIT: u32 = 2; +pub const KVM_PMU_CAP_DISABLE: u32 = 1; +pub const KVM_STATS_TYPE_SHIFT: u32 = 0; +pub const KVM_STATS_TYPE_MASK: u32 = 15; +pub const KVM_STATS_TYPE_CUMULATIVE: u32 = 0; +pub const KVM_STATS_TYPE_INSTANT: u32 = 1; +pub const KVM_STATS_TYPE_PEAK: u32 = 2; +pub const KVM_STATS_TYPE_LINEAR_HIST: u32 = 3; +pub const KVM_STATS_TYPE_LOG_HIST: u32 = 4; +pub const KVM_STATS_TYPE_MAX: u32 = 4; +pub const KVM_STATS_UNIT_SHIFT: u32 = 4; +pub const KVM_STATS_UNIT_MASK: u32 = 240; +pub const KVM_STATS_UNIT_NONE: u32 = 0; +pub const KVM_STATS_UNIT_BYTES: u32 = 16; +pub const KVM_STATS_UNIT_SECONDS: u32 = 32; +pub const KVM_STATS_UNIT_CYCLES: u32 = 48; +pub const KVM_STATS_UNIT_BOOLEAN: u32 = 64; +pub const KVM_STATS_UNIT_MAX: u32 = 64; +pub const KVM_STATS_BASE_SHIFT: u32 = 8; +pub const KVM_STATS_BASE_MASK: u32 = 3840; +pub const KVM_STATS_BASE_POW10: u32 = 0; +pub const KVM_STATS_BASE_POW2: u32 = 256; +pub const KVM_STATS_BASE_MAX: u32 = 256; +pub const KVM_X86_NOTIFY_VMEXIT_ENABLED: u32 = 1; +pub const KVM_X86_NOTIFY_VMEXIT_USER: u32 = 2; +pub const KVM_MEMORY_ATTRIBUTE_PRIVATE: u32 = 8; +pub type __s8 = ::std::os::raw::c_schar; +pub type __u8 = ::std::os::raw::c_uchar; +pub type __s16 = ::std::os::raw::c_short; +pub type __u16 = ::std::os::raw::c_ushort; +pub type __s32 = ::std::os::raw::c_int; +pub type __u32 = ::std::os::raw::c_uint; +pub type __s64 = ::std::os::raw::c_longlong; +pub type __u64 = ::std::os::raw::c_ulonglong; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct __kernel_fd_set { + pub fds_bits: [::std::os::raw::c_ulong; 16usize], +} +#[test] +fn bindgen_test_layout___kernel_fd_set() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fd_set> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__kernel_fd_set>(), + 128usize, + concat!("Size of: ", stringify!(__kernel_fd_set)) + ); + assert_eq!( + ::std::mem::align_of::<__kernel_fd_set>(), + 8usize, + concat!("Alignment of ", stringify!(__kernel_fd_set)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__kernel_fd_set), + "::", + stringify!(fds_bits) + ) + ); +} +pub type __kernel_sighandler_t = + ::std::option::Option; +pub type __kernel_key_t = ::std::os::raw::c_int; +pub type __kernel_mqd_t = ::std::os::raw::c_int; +pub type __kernel_long_t = ::std::os::raw::c_long; +pub type __kernel_ulong_t = ::std::os::raw::c_ulong; +pub type __kernel_ino_t = __kernel_ulong_t; +pub type __kernel_mode_t = ::std::os::raw::c_uint; +pub type __kernel_pid_t = ::std::os::raw::c_int; +pub type __kernel_ipc_pid_t = ::std::os::raw::c_int; +pub type __kernel_uid_t = ::std::os::raw::c_uint; +pub type __kernel_gid_t = ::std::os::raw::c_uint; +pub type __kernel_suseconds_t = __kernel_long_t; +pub type __kernel_daddr_t = ::std::os::raw::c_int; +pub type __kernel_uid32_t = ::std::os::raw::c_uint; +pub type __kernel_gid32_t = ::std::os::raw::c_uint; +pub type __kernel_old_uid_t = __kernel_uid_t; +pub type __kernel_old_gid_t = __kernel_gid_t; +pub type __kernel_old_dev_t = ::std::os::raw::c_uint; +pub type __kernel_size_t = __kernel_ulong_t; +pub type __kernel_ssize_t = __kernel_long_t; +pub type __kernel_ptrdiff_t = __kernel_long_t; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct __kernel_fsid_t { + pub val: [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___kernel_fsid_t() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fsid_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__kernel_fsid_t>(), + 8usize, + concat!("Size of: ", stringify!(__kernel_fsid_t)) + ); + assert_eq!( + ::std::mem::align_of::<__kernel_fsid_t>(), + 4usize, + concat!("Alignment of ", stringify!(__kernel_fsid_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__kernel_fsid_t), + "::", + stringify!(val) + ) + ); +} +pub type __kernel_off_t = __kernel_long_t; +pub type __kernel_loff_t = ::std::os::raw::c_longlong; +pub type __kernel_old_time_t = __kernel_long_t; +pub type __kernel_time_t = __kernel_long_t; +pub type __kernel_time64_t = ::std::os::raw::c_longlong; +pub type __kernel_clock_t = __kernel_long_t; +pub type __kernel_timer_t = ::std::os::raw::c_int; +pub type __kernel_clockid_t = ::std::os::raw::c_int; +pub type __kernel_caddr_t = *mut ::std::os::raw::c_char; +pub type __kernel_uid16_t = ::std::os::raw::c_ushort; +pub type __kernel_gid16_t = ::std::os::raw::c_ushort; +pub type __s128 = i128; +pub type __u128 = u128; +pub type __le16 = __u16; +pub type __be16 = __u16; +pub type __le32 = __u32; +pub type __be32 = __u32; +pub type __le64 = __u64; +pub type __be64 = __u64; +pub type __sum16 = __u16; +pub type __wsum = __u32; +pub type __poll_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct user_regs_struct { + pub pc: ::std::os::raw::c_ulong, + pub ra: ::std::os::raw::c_ulong, + pub sp: ::std::os::raw::c_ulong, + pub gp: ::std::os::raw::c_ulong, + pub tp: ::std::os::raw::c_ulong, + pub t0: ::std::os::raw::c_ulong, + pub t1: ::std::os::raw::c_ulong, + pub t2: ::std::os::raw::c_ulong, + pub s0: ::std::os::raw::c_ulong, + pub s1: ::std::os::raw::c_ulong, + pub a0: ::std::os::raw::c_ulong, + pub a1: ::std::os::raw::c_ulong, + pub a2: ::std::os::raw::c_ulong, + pub a3: ::std::os::raw::c_ulong, + pub a4: ::std::os::raw::c_ulong, + pub a5: ::std::os::raw::c_ulong, + pub a6: ::std::os::raw::c_ulong, + pub a7: ::std::os::raw::c_ulong, + pub s2: ::std::os::raw::c_ulong, + pub s3: ::std::os::raw::c_ulong, + pub s4: ::std::os::raw::c_ulong, + pub s5: ::std::os::raw::c_ulong, + pub s6: ::std::os::raw::c_ulong, + pub s7: ::std::os::raw::c_ulong, + pub s8: ::std::os::raw::c_ulong, + pub s9: ::std::os::raw::c_ulong, + pub s10: ::std::os::raw::c_ulong, + pub s11: ::std::os::raw::c_ulong, + pub t3: ::std::os::raw::c_ulong, + pub t4: ::std::os::raw::c_ulong, + pub t5: ::std::os::raw::c_ulong, + pub t6: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_user_regs_struct() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(user_regs_struct)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(user_regs_struct)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pc) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(pc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ra) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(ra) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sp) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(sp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gp) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(gp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tp) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(tp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t0) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t0) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t1) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t2) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s0) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s0) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s1) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a0) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a0) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a1) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a2) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a3) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a4) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a4) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a5) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a5) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a6) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a6) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a7) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(a7) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s2) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s3) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s4) as usize - ptr as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s4) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s5) as usize - ptr as usize }, + 168usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s5) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s6) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s6) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s7) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s7) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s8) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s9) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s9) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s10) as usize - ptr as usize }, + 208usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s10) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s11) as usize - ptr as usize }, + 216usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(s11) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t3) as usize - ptr as usize }, + 224usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t4) as usize - ptr as usize }, + 232usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t4) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t5) as usize - ptr as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t5) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t6) as usize - ptr as usize }, + 248usize, + concat!( + "Offset of field: ", + stringify!(user_regs_struct), + "::", + stringify!(t6) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct __riscv_f_ext_state { + pub f: [__u32; 32usize], + pub fcsr: __u32, +} +#[test] +fn bindgen_test_layout___riscv_f_ext_state() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_f_ext_state> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_f_ext_state>(), + 132usize, + concat!("Size of: ", stringify!(__riscv_f_ext_state)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_f_ext_state>(), + 4usize, + concat!("Alignment of ", stringify!(__riscv_f_ext_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_f_ext_state), + "::", + stringify!(f) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fcsr) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(__riscv_f_ext_state), + "::", + stringify!(fcsr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct __riscv_d_ext_state { + pub f: [__u64; 32usize], + pub fcsr: __u32, +} +#[test] +fn bindgen_test_layout___riscv_d_ext_state() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_d_ext_state> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_d_ext_state>(), + 264usize, + concat!("Size of: ", stringify!(__riscv_d_ext_state)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_d_ext_state>(), + 8usize, + concat!("Alignment of ", stringify!(__riscv_d_ext_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_d_ext_state), + "::", + stringify!(f) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fcsr) as usize - ptr as usize }, + 256usize, + concat!( + "Offset of field: ", + stringify!(__riscv_d_ext_state), + "::", + stringify!(fcsr) + ) + ); +} +#[repr(C)] +#[repr(align(16))] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct __riscv_q_ext_state { + pub f: [__u64; 64usize], + pub fcsr: __u32, + pub reserved: [__u32; 3usize], +} +#[test] +fn bindgen_test_layout___riscv_q_ext_state() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_q_ext_state> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_q_ext_state>(), + 528usize, + concat!("Size of: ", stringify!(__riscv_q_ext_state)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_q_ext_state>(), + 16usize, + concat!("Alignment of ", stringify!(__riscv_q_ext_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_q_ext_state), + "::", + stringify!(f) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fcsr) as usize - ptr as usize }, + 512usize, + concat!( + "Offset of field: ", + stringify!(__riscv_q_ext_state), + "::", + stringify!(fcsr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 516usize, + concat!( + "Offset of field: ", + stringify!(__riscv_q_ext_state), + "::", + stringify!(reserved) + ) + ); +} +impl Default for __riscv_q_ext_state { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct __riscv_ctx_hdr { + pub magic: __u32, + pub size: __u32, +} +#[test] +fn bindgen_test_layout___riscv_ctx_hdr() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_ctx_hdr> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_ctx_hdr>(), + 8usize, + concat!("Size of: ", stringify!(__riscv_ctx_hdr)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_ctx_hdr>(), + 4usize, + concat!("Alignment of ", stringify!(__riscv_ctx_hdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).magic) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_ctx_hdr), + "::", + stringify!(magic) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__riscv_ctx_hdr), + "::", + stringify!(size) + ) + ); +} +#[repr(C)] +#[repr(align(16))] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct __riscv_extra_ext_header { + pub __padding: [__u32; 129usize], + pub reserved: __u32, + pub hdr: __riscv_ctx_hdr, +} +#[test] +fn bindgen_test_layout___riscv_extra_ext_header() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_extra_ext_header> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_extra_ext_header>(), + 528usize, + concat!("Size of: ", stringify!(__riscv_extra_ext_header)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_extra_ext_header>(), + 16usize, + concat!("Alignment of ", stringify!(__riscv_extra_ext_header)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__padding) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_extra_ext_header), + "::", + stringify!(__padding) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 516usize, + concat!( + "Offset of field: ", + stringify!(__riscv_extra_ext_header), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, + 520usize, + concat!( + "Offset of field: ", + stringify!(__riscv_extra_ext_header), + "::", + stringify!(hdr) + ) + ); +} +impl Default for __riscv_extra_ext_header { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[repr(align(16))] +#[derive(Copy, Clone)] +pub union __riscv_fp_state { + pub f: __riscv_f_ext_state, + pub d: __riscv_d_ext_state, + pub q: __riscv_q_ext_state, +} +#[test] +fn bindgen_test_layout___riscv_fp_state() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_fp_state> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_fp_state>(), + 528usize, + concat!("Size of: ", stringify!(__riscv_fp_state)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_fp_state>(), + 16usize, + concat!("Alignment of ", stringify!(__riscv_fp_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_fp_state), + "::", + stringify!(f) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_fp_state), + "::", + stringify!(d) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).q) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_fp_state), + "::", + stringify!(q) + ) + ); +} +impl Default for __riscv_fp_state { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for __riscv_fp_state { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "__riscv_fp_state {{ union }}") + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct __riscv_v_ext_state { + pub vstart: ::std::os::raw::c_ulong, + pub vl: ::std::os::raw::c_ulong, + pub vtype: ::std::os::raw::c_ulong, + pub vcsr: ::std::os::raw::c_ulong, + pub vlenb: ::std::os::raw::c_ulong, + pub datap: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout___riscv_v_ext_state() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_v_ext_state> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_v_ext_state>(), + 48usize, + concat!("Size of: ", stringify!(__riscv_v_ext_state)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_v_ext_state>(), + 8usize, + concat!("Alignment of ", stringify!(__riscv_v_ext_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vstart) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_ext_state), + "::", + stringify!(vstart) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vl) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_ext_state), + "::", + stringify!(vl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vtype) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_ext_state), + "::", + stringify!(vtype) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vcsr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_ext_state), + "::", + stringify!(vcsr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vlenb) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_ext_state), + "::", + stringify!(vlenb) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).datap) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_ext_state), + "::", + stringify!(datap) + ) + ); +} +impl Default for __riscv_v_ext_state { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct __riscv_v_regset_state { + pub vstart: ::std::os::raw::c_ulong, + pub vl: ::std::os::raw::c_ulong, + pub vtype: ::std::os::raw::c_ulong, + pub vcsr: ::std::os::raw::c_ulong, + pub vlenb: ::std::os::raw::c_ulong, + pub vreg: __IncompleteArrayField<::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout___riscv_v_regset_state() { + const UNINIT: ::std::mem::MaybeUninit<__riscv_v_regset_state> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__riscv_v_regset_state>(), + 40usize, + concat!("Size of: ", stringify!(__riscv_v_regset_state)) + ); + assert_eq!( + ::std::mem::align_of::<__riscv_v_regset_state>(), + 8usize, + concat!("Alignment of ", stringify!(__riscv_v_regset_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vstart) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_regset_state), + "::", + stringify!(vstart) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vl) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_regset_state), + "::", + stringify!(vl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vtype) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_regset_state), + "::", + stringify!(vtype) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vcsr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_regset_state), + "::", + stringify!(vcsr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vlenb) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_regset_state), + "::", + stringify!(vlenb) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vreg) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(__riscv_v_regset_state), + "::", + stringify!(vreg) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_regs {} +#[test] +fn bindgen_test_layout_kvm_regs() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_regs)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_regs)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_fpu {} +#[test] +fn bindgen_test_layout_kvm_fpu() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_fpu)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_fpu)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_debug_exit_arch {} +#[test] +fn bindgen_test_layout_kvm_debug_exit_arch() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_debug_exit_arch)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_debug_exit_arch)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_guest_debug_arch {} +#[test] +fn bindgen_test_layout_kvm_guest_debug_arch() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_guest_debug_arch)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_guest_debug_arch)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_sync_regs {} +#[test] +fn bindgen_test_layout_kvm_sync_regs() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_sync_regs)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_sync_regs)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_sregs {} +#[test] +fn bindgen_test_layout_kvm_sregs() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_sregs)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_sregs)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_config { + pub isa: ::std::os::raw::c_ulong, + pub zicbom_block_size: ::std::os::raw::c_ulong, + pub mvendorid: ::std::os::raw::c_ulong, + pub marchid: ::std::os::raw::c_ulong, + pub mimpid: ::std::os::raw::c_ulong, + pub zicboz_block_size: ::std::os::raw::c_ulong, + pub satp_mode: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_riscv_config() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(kvm_riscv_config)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).isa) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(isa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).zicbom_block_size) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(zicbom_block_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mvendorid) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(mvendorid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).marchid) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(marchid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mimpid) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(mimpid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).zicboz_block_size) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(zicboz_block_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).satp_mode) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_config), + "::", + stringify!(satp_mode) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_core { + pub regs: user_regs_struct, + pub mode: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_riscv_core() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 264usize, + concat!("Size of: ", stringify!(kvm_riscv_core)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_core)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_core), + "::", + stringify!(regs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize }, + 256usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_core), + "::", + stringify!(mode) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_csr { + pub sstatus: ::std::os::raw::c_ulong, + pub sie: ::std::os::raw::c_ulong, + pub stvec: ::std::os::raw::c_ulong, + pub sscratch: ::std::os::raw::c_ulong, + pub sepc: ::std::os::raw::c_ulong, + pub scause: ::std::os::raw::c_ulong, + pub stval: ::std::os::raw::c_ulong, + pub sip: ::std::os::raw::c_ulong, + pub satp: ::std::os::raw::c_ulong, + pub scounteren: ::std::os::raw::c_ulong, + pub senvcfg: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_riscv_csr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 88usize, + concat!("Size of: ", stringify!(kvm_riscv_csr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_csr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sstatus) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(sstatus) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sie) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(sie) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).stvec) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(stvec) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sscratch) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(sscratch) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sepc) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(sepc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scause) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(scause) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).stval) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(stval) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sip) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(sip) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).satp) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(satp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scounteren) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(scounteren) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).senvcfg) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_csr), + "::", + stringify!(senvcfg) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_aia_csr { + pub siselect: ::std::os::raw::c_ulong, + pub iprio1: ::std::os::raw::c_ulong, + pub iprio2: ::std::os::raw::c_ulong, + pub sieh: ::std::os::raw::c_ulong, + pub siph: ::std::os::raw::c_ulong, + pub iprio1h: ::std::os::raw::c_ulong, + pub iprio2h: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_riscv_aia_csr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(kvm_riscv_aia_csr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_aia_csr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).siselect) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(siselect) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iprio1) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(iprio1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iprio2) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(iprio2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sieh) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(sieh) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).siph) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(siph) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iprio1h) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(iprio1h) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iprio2h) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_aia_csr), + "::", + stringify!(iprio2h) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_smstateen_csr { + pub sstateen0: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_riscv_smstateen_csr() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_riscv_smstateen_csr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_smstateen_csr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sstateen0) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_smstateen_csr), + "::", + stringify!(sstateen0) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_timer { + pub frequency: __u64, + pub time: __u64, + pub compare: __u64, + pub state: __u64, +} +#[test] +fn bindgen_test_layout_kvm_riscv_timer() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_riscv_timer)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_timer)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).frequency) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_timer), + "::", + stringify!(frequency) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).time) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_timer), + "::", + stringify!(time) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).compare) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_timer), + "::", + stringify!(compare) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_timer), + "::", + stringify!(state) + ) + ); +} +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_A: KVM_RISCV_ISA_EXT_ID = 0; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_C: KVM_RISCV_ISA_EXT_ID = 1; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_D: KVM_RISCV_ISA_EXT_ID = 2; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_F: KVM_RISCV_ISA_EXT_ID = 3; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_H: KVM_RISCV_ISA_EXT_ID = 4; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_I: KVM_RISCV_ISA_EXT_ID = 5; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_M: KVM_RISCV_ISA_EXT_ID = 6; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_SVPBMT: KVM_RISCV_ISA_EXT_ID = 7; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_SSTC: KVM_RISCV_ISA_EXT_ID = 8; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_SVINVAL: KVM_RISCV_ISA_EXT_ID = 9; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZIHINTPAUSE: KVM_RISCV_ISA_EXT_ID = 10; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZICBOM: KVM_RISCV_ISA_EXT_ID = 11; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZICBOZ: KVM_RISCV_ISA_EXT_ID = 12; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBB: KVM_RISCV_ISA_EXT_ID = 13; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_SSAIA: KVM_RISCV_ISA_EXT_ID = 14; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_V: KVM_RISCV_ISA_EXT_ID = 15; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_SVNAPOT: KVM_RISCV_ISA_EXT_ID = 16; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBA: KVM_RISCV_ISA_EXT_ID = 17; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBS: KVM_RISCV_ISA_EXT_ID = 18; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZICNTR: KVM_RISCV_ISA_EXT_ID = 19; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZICSR: KVM_RISCV_ISA_EXT_ID = 20; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZIFENCEI: KVM_RISCV_ISA_EXT_ID = 21; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZIHPM: KVM_RISCV_ISA_EXT_ID = 22; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_SMSTATEEN: KVM_RISCV_ISA_EXT_ID = 23; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZICOND: KVM_RISCV_ISA_EXT_ID = 24; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBC: KVM_RISCV_ISA_EXT_ID = 25; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBKB: KVM_RISCV_ISA_EXT_ID = 26; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBKC: KVM_RISCV_ISA_EXT_ID = 27; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZBKX: KVM_RISCV_ISA_EXT_ID = 28; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKND: KVM_RISCV_ISA_EXT_ID = 29; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKNE: KVM_RISCV_ISA_EXT_ID = 30; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKNH: KVM_RISCV_ISA_EXT_ID = 31; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKR: KVM_RISCV_ISA_EXT_ID = 32; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKSED: KVM_RISCV_ISA_EXT_ID = 33; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKSH: KVM_RISCV_ISA_EXT_ID = 34; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZKT: KVM_RISCV_ISA_EXT_ID = 35; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVBB: KVM_RISCV_ISA_EXT_ID = 36; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVBC: KVM_RISCV_ISA_EXT_ID = 37; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKB: KVM_RISCV_ISA_EXT_ID = 38; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKG: KVM_RISCV_ISA_EXT_ID = 39; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKNED: KVM_RISCV_ISA_EXT_ID = 40; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKNHA: KVM_RISCV_ISA_EXT_ID = 41; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKNHB: KVM_RISCV_ISA_EXT_ID = 42; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKSED: KVM_RISCV_ISA_EXT_ID = 43; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKSH: KVM_RISCV_ISA_EXT_ID = 44; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVKT: KVM_RISCV_ISA_EXT_ID = 45; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZFH: KVM_RISCV_ISA_EXT_ID = 46; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZFHMIN: KVM_RISCV_ISA_EXT_ID = 47; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZIHINTNTL: KVM_RISCV_ISA_EXT_ID = 48; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVFH: KVM_RISCV_ISA_EXT_ID = 49; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZVFHMIN: KVM_RISCV_ISA_EXT_ID = 50; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZFA: KVM_RISCV_ISA_EXT_ID = 51; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZTSO: KVM_RISCV_ISA_EXT_ID = 52; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_ZACAS: KVM_RISCV_ISA_EXT_ID = 53; +pub const KVM_RISCV_ISA_EXT_ID_KVM_RISCV_ISA_EXT_MAX: KVM_RISCV_ISA_EXT_ID = 54; +pub type KVM_RISCV_ISA_EXT_ID = ::std::os::raw::c_uint; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_V01: KVM_RISCV_SBI_EXT_ID = 0; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_TIME: KVM_RISCV_SBI_EXT_ID = 1; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_IPI: KVM_RISCV_SBI_EXT_ID = 2; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_RFENCE: KVM_RISCV_SBI_EXT_ID = 3; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_SRST: KVM_RISCV_SBI_EXT_ID = 4; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_HSM: KVM_RISCV_SBI_EXT_ID = 5; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_PMU: KVM_RISCV_SBI_EXT_ID = 6; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_EXPERIMENTAL: KVM_RISCV_SBI_EXT_ID = 7; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_VENDOR: KVM_RISCV_SBI_EXT_ID = 8; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_DBCN: KVM_RISCV_SBI_EXT_ID = 9; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_STA: KVM_RISCV_SBI_EXT_ID = 10; +pub const KVM_RISCV_SBI_EXT_ID_KVM_RISCV_SBI_EXT_MAX: KVM_RISCV_SBI_EXT_ID = 11; +pub type KVM_RISCV_SBI_EXT_ID = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_riscv_sbi_sta { + pub shmem_lo: ::std::os::raw::c_ulong, + pub shmem_hi: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_riscv_sbi_sta() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_riscv_sbi_sta)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_riscv_sbi_sta)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).shmem_lo) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_sbi_sta), + "::", + stringify!(shmem_lo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).shmem_hi) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_riscv_sbi_sta), + "::", + stringify!(shmem_hi) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_userspace_memory_region { + pub slot: __u32, + pub flags: __u32, + pub guest_phys_addr: __u64, + pub memory_size: __u64, + pub userspace_addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_userspace_memory_region() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_userspace_memory_region)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_userspace_memory_region)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(slot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).guest_phys_addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(guest_phys_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(memory_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(userspace_addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_userspace_memory_region2 { + pub slot: __u32, + pub flags: __u32, + pub guest_phys_addr: __u64, + pub memory_size: __u64, + pub userspace_addr: __u64, + pub guest_memfd_offset: __u64, + pub guest_memfd: __u32, + pub pad1: __u32, + pub pad2: [__u64; 14usize], +} +#[test] +fn bindgen_test_layout_kvm_userspace_memory_region2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 160usize, + concat!("Size of: ", stringify!(kvm_userspace_memory_region2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_userspace_memory_region2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(slot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).guest_phys_addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(guest_phys_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(memory_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(userspace_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).guest_memfd_offset) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(guest_memfd_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).guest_memfd) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(guest_memfd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(kvm_userspace_memory_region2), + "::", + stringify!(pad2) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_level { + pub __bindgen_anon_1: kvm_irq_level__bindgen_ty_1, + pub level: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_level__bindgen_ty_1 { + pub irq: __u32, + pub status: __s32, +} +#[test] +fn bindgen_test_layout_kvm_irq_level__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_irq_level__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_level__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_level__bindgen_ty_1), + "::", + stringify!(irq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_level__bindgen_ty_1), + "::", + stringify!(status) + ) + ); +} +impl Default for kvm_irq_level__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_level__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_level__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_irq_level() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_level)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_level)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_level), + "::", + stringify!(level) + ) + ); +} +impl Default for kvm_irq_level { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_level { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_level {{ __bindgen_anon_1: {:?}, level: {:?} }}", + self.__bindgen_anon_1, self.level + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irqchip { + pub chip_id: __u32, + pub pad: __u32, + pub chip: kvm_irqchip__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irqchip__bindgen_ty_1 { + pub dummy: [::std::os::raw::c_char; 512usize], +} +#[test] +fn bindgen_test_layout_kvm_irqchip__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 512usize, + concat!("Size of: ", stringify!(kvm_irqchip__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_irqchip__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dummy) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqchip__bindgen_ty_1), + "::", + stringify!(dummy) + ) + ); +} +impl Default for kvm_irqchip__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irqchip__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irqchip__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_irqchip() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 520usize, + concat!("Size of: ", stringify!(kvm_irqchip)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irqchip)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).chip_id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqchip), + "::", + stringify!(chip_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqchip), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).chip) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqchip), + "::", + stringify!(chip) + ) + ); +} +impl Default for kvm_irqchip { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irqchip { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irqchip {{ chip_id: {:?}, pad: {:?}, chip: {:?} }}", + self.chip_id, self.pad, self.chip + ) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_pit_config { + pub flags: __u32, + pub pad: [__u32; 15usize], +} +#[test] +fn bindgen_test_layout_kvm_pit_config() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_pit_config)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_pit_config)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_pit_config), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_pit_config), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_hyperv_exit { + pub type_: __u32, + pub pad1: __u32, + pub u: kvm_hyperv_exit__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_hyperv_exit__bindgen_ty_1 { + pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, + pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, + pub syndbg: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { + pub msr: __u32, + pub pad2: __u32, + pub control: __u64, + pub evt_page: __u64, + pub msg_page: __u64, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(msr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pad2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(control) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).evt_page) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(evt_page) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_page) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(msg_page) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { + pub input: __u64, + pub result: __u64, + pub params: [__u64; 2usize], +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(input) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(result) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(params) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3 { + pub msr: __u32, + pub pad2: __u32, + pub control: __u64, + pub status: __u64, + pub send_page: __u64, + pub recv_page: __u64, + pub pending_page: __u64, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(msr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(pad2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(control) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(status) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).send_page) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(send_page) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).recv_page) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(recv_page) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pending_page) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(pending_page) + ) + ); +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).synic) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1), + "::", + stringify!(synic) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hcall) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1), + "::", + stringify!(hcall) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).syndbg) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1), + "::", + stringify!(syndbg) + ) + ); +} +impl Default for kvm_hyperv_exit__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_hyperv_exit__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_hyperv_exit__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_hyperv_exit)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit), + "::", + stringify!(pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit), + "::", + stringify!(u) + ) + ); +} +impl Default for kvm_hyperv_exit { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_hyperv_exit { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_hyperv_exit {{ type: {:?}, pad1: {:?}, u: {:?} }}", + self.type_, self.pad1, self.u + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_xen_exit { + pub type_: __u32, + pub u: kvm_xen_exit__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_xen_exit__bindgen_ty_1 { + pub hcall: kvm_xen_exit__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_xen_exit__bindgen_ty_1__bindgen_ty_1 { + pub longmode: __u32, + pub cpl: __u32, + pub input: __u64, + pub result: __u64, + pub params: [__u64; 6usize], +} +#[test] +fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!( + "Size of: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).longmode) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(longmode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cpl) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(cpl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(input) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(result) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(params) + ) + ); +} +#[test] +fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_xen_exit__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_xen_exit__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hcall) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit__bindgen_ty_1), + "::", + stringify!(hcall) + ) + ); +} +impl Default for kvm_xen_exit__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_xen_exit__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_xen_exit__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_xen_exit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(kvm_xen_exit)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_xen_exit)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_exit), + "::", + stringify!(u) + ) + ); +} +impl Default for kvm_xen_exit { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_xen_exit { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_exit {{ type: {:?}, u: {:?} }}", + self.type_, self.u + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run { + pub request_interrupt_window: __u8, + pub immediate_exit: __u8, + pub padding1: [__u8; 6usize], + pub exit_reason: __u32, + pub ready_for_interrupt_injection: __u8, + pub if_flag: __u8, + pub flags: __u16, + pub cr8: __u64, + pub apic_base: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1, + pub kvm_valid_regs: __u64, + pub kvm_dirty_regs: __u64, + pub s: kvm_run__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1 { + pub hw: kvm_run__bindgen_ty_1__bindgen_ty_1, + pub fail_entry: kvm_run__bindgen_ty_1__bindgen_ty_2, + pub ex: kvm_run__bindgen_ty_1__bindgen_ty_3, + pub io: kvm_run__bindgen_ty_1__bindgen_ty_4, + pub debug: kvm_run__bindgen_ty_1__bindgen_ty_5, + pub mmio: kvm_run__bindgen_ty_1__bindgen_ty_6, + pub iocsr_io: kvm_run__bindgen_ty_1__bindgen_ty_7, + pub hypercall: kvm_run__bindgen_ty_1__bindgen_ty_8, + pub tpr_access: kvm_run__bindgen_ty_1__bindgen_ty_9, + pub s390_sieic: kvm_run__bindgen_ty_1__bindgen_ty_10, + pub s390_reset_flags: __u64, + pub s390_ucontrol: kvm_run__bindgen_ty_1__bindgen_ty_11, + pub dcr: kvm_run__bindgen_ty_1__bindgen_ty_12, + pub internal: kvm_run__bindgen_ty_1__bindgen_ty_13, + pub emulation_failure: kvm_run__bindgen_ty_1__bindgen_ty_14, + pub osi: kvm_run__bindgen_ty_1__bindgen_ty_15, + pub papr_hcall: kvm_run__bindgen_ty_1__bindgen_ty_16, + pub s390_tsch: kvm_run__bindgen_ty_1__bindgen_ty_17, + pub epr: kvm_run__bindgen_ty_1__bindgen_ty_18, + pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_19, + pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_20, + pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_21, + pub hyperv: kvm_hyperv_exit, + pub arm_nisv: kvm_run__bindgen_ty_1__bindgen_ty_22, + pub msr: kvm_run__bindgen_ty_1__bindgen_ty_23, + pub xen: kvm_xen_exit, + pub riscv_sbi: kvm_run__bindgen_ty_1__bindgen_ty_24, + pub riscv_csr: kvm_run__bindgen_ty_1__bindgen_ty_25, + pub notify: kvm_run__bindgen_ty_1__bindgen_ty_26, + pub memory_fault: kvm_run__bindgen_ty_1__bindgen_ty_27, + pub padding: [::std::os::raw::c_char; 256usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_1 { + pub hardware_exit_reason: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hardware_exit_reason) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(hardware_exit_reason) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_2 { + pub hardware_entry_failure_reason: __u64, + pub cpu: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + ::std::ptr::addr_of!((*ptr).hardware_entry_failure_reason) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(hardware_entry_failure_reason) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cpu) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(cpu) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_3 { + pub exception: __u32, + pub error_code: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).exception) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(exception) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).error_code) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(error_code) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_4 { + pub direction: __u8, + pub size: __u8, + pub port: __u16, + pub count: __u32, + pub data_offset: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + "::", + stringify!(direction) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + "::", + stringify!(count) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data_offset) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + "::", + stringify!(data_offset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_5 { + pub arch: kvm_debug_exit_arch, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_5() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5), + "::", + stringify!(arch) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_6 { + pub phys_addr: __u64, + pub data: [__u8; 8usize], + pub len: __u32, + pub is_write: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + "::", + stringify!(phys_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + "::", + stringify!(is_write) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_7 { + pub phys_addr: __u64, + pub data: [__u8; 8usize], + pub len: __u32, + pub is_write: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_7() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + "::", + stringify!(phys_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + "::", + stringify!(is_write) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_8 { + pub nr: __u64, + pub args: [__u64; 6usize], + pub ret: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + pub longmode: __u32, + pub flags: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).longmode) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1), + "::", + stringify!(longmode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1), + "::", + stringify!(flags) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 {{ union }}" + ) + } +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + "::", + stringify!(args) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + "::", + stringify!(ret) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_8 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_8 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_8 {{ nr: {:?}, args: {:?}, ret: {:?}, __bindgen_anon_1: {:?} }}" , self . nr , self . args , self . ret , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_9 { + pub rip: __u64, + pub is_write: __u32, + pub pad: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_9() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rip) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), + "::", + stringify!(rip) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), + "::", + stringify!(is_write) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_10 { + pub icptcode: __u8, + pub ipa: __u16, + pub ipb: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_10() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).icptcode) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), + "::", + stringify!(icptcode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipa) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), + "::", + stringify!(ipa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipb) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), + "::", + stringify!(ipb) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_11 { + pub trans_exc_code: __u64, + pub pgm_code: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_11() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).trans_exc_code) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), + "::", + stringify!(trans_exc_code) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pgm_code) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), + "::", + stringify!(pgm_code) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_12 { + pub dcrn: __u32, + pub data: __u32, + pub is_write: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_12() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dcrn) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), + "::", + stringify!(dcrn) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), + "::", + stringify!(is_write) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_13 { + pub suberror: __u32, + pub ndata: __u32, + pub data: [__u64; 16usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_13() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 136usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).suberror) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), + "::", + stringify!(suberror) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), + "::", + stringify!(ndata) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), + "::", + stringify!(data) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_14 { + pub suberror: __u32, + pub ndata: __u32, + pub flags: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1 { + pub insn_size: __u8, + pub insn_bytes: [__u8; 15usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit< + kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1, + > = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).insn_size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(insn_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).insn_bytes) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(insn_bytes) + ) + ); +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 {{ union }}" + ) + } +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).suberror) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + "::", + stringify!(suberror) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + "::", + stringify!(ndata) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + "::", + stringify!(flags) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_14 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_14 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_14 {{ suberror: {:?}, ndata: {:?}, flags: {:?}, __bindgen_anon_1: {:?} }}" , self . suberror , self . ndata , self . flags , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_15 { + pub gprs: [__u64; 32usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_15() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gprs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + "::", + stringify!(gprs) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_16 { + pub nr: __u64, + pub ret: __u64, + pub args: [__u64; 9usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_16() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 88usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), + "::", + stringify!(ret) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), + "::", + stringify!(args) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_17 { + pub subchannel_id: __u16, + pub subchannel_nr: __u16, + pub io_int_parm: __u32, + pub io_int_word: __u32, + pub ipb: __u32, + pub dequeued: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_17() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).subchannel_id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + "::", + stringify!(subchannel_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).subchannel_nr) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + "::", + stringify!(subchannel_nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).io_int_parm) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + "::", + stringify!(io_int_parm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).io_int_word) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + "::", + stringify!(io_int_word) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipb) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + "::", + stringify!(ipb) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dequeued) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), + "::", + stringify!(dequeued) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_18 { + pub epr: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_18() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).epr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + "::", + stringify!(epr) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_19 { + pub type_: __u32, + pub ndata: __u32, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + pub flags: __u64, + pub data: [__u64; 16usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 128usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1), + "::", + stringify!(data) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 {{ union }}" + ) + } +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 136usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), + "::", + stringify!(ndata) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_19 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_19 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_19 {{ type: {:?}, ndata: {:?}, __bindgen_anon_1: {:?} }}" , self . type_ , self . ndata , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_20 { + pub addr: __u64, + pub ar: __u8, + pub reserved: __u8, + pub fc: __u8, + pub sel1: __u8, + pub sel2: __u16, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_20() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ar) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + "::", + stringify!(ar) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 9usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fc) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + "::", + stringify!(fc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sel1) as usize - ptr as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + "::", + stringify!(sel1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sel2) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + "::", + stringify!(sel2) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_21 { + pub vector: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_21() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + "::", + stringify!(vector) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_22 { + pub esr_iss: __u64, + pub fault_ipa: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_22() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).esr_iss) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22), + "::", + stringify!(esr_iss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fault_ipa) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22), + "::", + stringify!(fault_ipa) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_23 { + pub error: __u8, + pub pad: [__u8; 7usize], + pub reason: __u32, + pub index: __u32, + pub data: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_23() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).error) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), + "::", + stringify!(error) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reason) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), + "::", + stringify!(reason) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), + "::", + stringify!(index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), + "::", + stringify!(data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_24 { + pub extension_id: ::std::os::raw::c_ulong, + pub function_id: ::std::os::raw::c_ulong, + pub args: [::std::os::raw::c_ulong; 6usize], + pub ret: [::std::os::raw::c_ulong; 2usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_24() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).extension_id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), + "::", + stringify!(extension_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).function_id) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), + "::", + stringify!(function_id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), + "::", + stringify!(args) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), + "::", + stringify!(ret) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_25 { + pub csr_num: ::std::os::raw::c_ulong, + pub new_value: ::std::os::raw::c_ulong, + pub write_mask: ::std::os::raw::c_ulong, + pub ret_value: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_25() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).csr_num) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), + "::", + stringify!(csr_num) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).new_value) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), + "::", + stringify!(new_value) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).write_mask) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), + "::", + stringify!(write_mask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret_value) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), + "::", + stringify!(ret_value) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_26 { + pub flags: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_26() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_27 { + pub flags: __u64, + pub gpa: __u64, + pub size: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_27() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gpa) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), + "::", + stringify!(gpa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), + "::", + stringify!(size) + ) + ); +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hw) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(hw) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fail_entry) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(fail_entry) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ex) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(ex) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).io) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(io) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).debug) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(debug) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mmio) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(mmio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iocsr_io) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(iocsr_io) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hypercall) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(hypercall) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tpr_access) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(tpr_access) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s390_sieic) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_sieic) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s390_reset_flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_reset_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s390_ucontrol) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_ucontrol) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dcr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(dcr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).internal) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(internal) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).emulation_failure) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(emulation_failure) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).osi) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(osi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).papr_hcall) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(papr_hcall) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s390_tsch) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_tsch) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).epr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(epr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).system_event) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(system_event) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s390_stsi) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_stsi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).eoi) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(eoi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hyperv) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(hyperv) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).arm_nisv) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(arm_nisv) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(msr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).xen) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(xen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).riscv_sbi) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(riscv_sbi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).riscv_csr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(riscv_csr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).notify) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(notify) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).memory_fault) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(memory_fault) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(padding) + ) + ); +} +impl Default for kvm_run__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_run__bindgen_ty_1 {{ union }}") + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_2 { + pub regs: kvm_sync_regs, + pub padding: [::std::os::raw::c_char; 2048usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 2048usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_2), + "::", + stringify!(regs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_2), + "::", + stringify!(padding) + ) + ); +} +impl Default for kvm_run__bindgen_ty_2 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_2 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_run__bindgen_ty_2 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_run() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 2352usize, + concat!("Size of: ", stringify!(kvm_run)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_run)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).request_interrupt_window) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(request_interrupt_window) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).immediate_exit) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(immediate_exit) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding1) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(padding1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).exit_reason) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(exit_reason) + ) + ); + assert_eq!( + unsafe { + ::std::ptr::addr_of!((*ptr).ready_for_interrupt_injection) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(ready_for_interrupt_injection) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).if_flag) as usize - ptr as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(if_flag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cr8) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(cr8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).apic_base) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(apic_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kvm_valid_regs) as usize - ptr as usize }, + 288usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(kvm_valid_regs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kvm_dirty_regs) as usize - ptr as usize }, + 296usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(kvm_dirty_regs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s) as usize - ptr as usize }, + 304usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(s) + ) + ); +} +impl Default for kvm_run { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run {{ request_interrupt_window: {:?}, immediate_exit: {:?}, padding1: {:?}, exit_reason: {:?}, ready_for_interrupt_injection: {:?}, if_flag: {:?}, flags: {:?}, cr8: {:?}, apic_base: {:?}, __bindgen_anon_1: {:?}, kvm_valid_regs: {:?}, kvm_dirty_regs: {:?}, s: {:?} }}" , self . request_interrupt_window , self . immediate_exit , self . padding1 , self . exit_reason , self . ready_for_interrupt_injection , self . if_flag , self . flags , self . cr8 , self . apic_base , self . __bindgen_anon_1 , self . kvm_valid_regs , self . kvm_dirty_regs , self . s) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_coalesced_mmio_zone { + pub addr: __u64, + pub size: __u32, + pub __bindgen_anon_1: kvm_coalesced_mmio_zone__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_coalesced_mmio_zone__bindgen_ty_1 { + pub pad: __u32, + pub pio: __u32, +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio_zone__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pio) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), + "::", + stringify!(pio) + ) + ); +} +impl Default for kvm_coalesced_mmio_zone__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_zone__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_coalesced_mmio_zone__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio_zone() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio_zone)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_coalesced_mmio_zone)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_zone), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_zone), + "::", + stringify!(size) + ) + ); +} +impl Default for kvm_coalesced_mmio_zone { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_zone { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_coalesced_mmio_zone {{ addr: {:?}, size: {:?}, __bindgen_anon_1: {:?} }}", + self.addr, self.size, self.__bindgen_anon_1 + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_coalesced_mmio { + pub phys_addr: __u64, + pub len: __u32, + pub __bindgen_anon_1: kvm_coalesced_mmio__bindgen_ty_1, + pub data: [__u8; 8usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_coalesced_mmio__bindgen_ty_1 { + pub pad: __u32, + pub pio: __u32, +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_coalesced_mmio__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio__bindgen_ty_1), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pio) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio__bindgen_ty_1), + "::", + stringify!(pio) + ) + ); +} +impl Default for kvm_coalesced_mmio__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_coalesced_mmio__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_coalesced_mmio)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio), + "::", + stringify!(phys_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio), + "::", + stringify!(data) + ) + ); +} +impl Default for kvm_coalesced_mmio { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_coalesced_mmio {{ phys_addr: {:?}, len: {:?}, __bindgen_anon_1: {:?}, data: {:?} }}" , self . phys_addr , self . len , self . __bindgen_anon_1 , self . data) + } +} +#[repr(C)] +pub struct kvm_coalesced_mmio_ring { + pub first: __u32, + pub last: __u32, + pub coalesced_mmio: __IncompleteArrayField, +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio_ring() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio_ring)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_coalesced_mmio_ring)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_ring), + "::", + stringify!(first) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_ring), + "::", + stringify!(last) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).coalesced_mmio) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_coalesced_mmio_ring), + "::", + stringify!(coalesced_mmio) + ) + ); +} +impl Default for kvm_coalesced_mmio_ring { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_ring { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_coalesced_mmio_ring {{ first: {:?}, last: {:?}, coalesced_mmio: {:?} }}", + self.first, self.last, self.coalesced_mmio + ) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_translation { + pub linear_address: __u64, + pub physical_address: __u64, + pub valid: __u8, + pub writeable: __u8, + pub usermode: __u8, + pub pad: [__u8; 5usize], +} +#[test] +fn bindgen_test_layout_kvm_translation() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_translation)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_translation)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).linear_address) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(linear_address) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).physical_address) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(physical_address) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).valid) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(valid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).writeable) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(writeable) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).usermode) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(usermode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 19usize, + concat!( + "Offset of field: ", + stringify!(kvm_translation), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_interrupt { + pub irq: __u32, +} +#[test] +fn bindgen_test_layout_kvm_interrupt() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_interrupt)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_interrupt)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_interrupt), + "::", + stringify!(irq) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_dirty_log { + pub slot: __u32, + pub padding1: __u32, + pub __bindgen_anon_1: kvm_dirty_log__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_dirty_log__bindgen_ty_1 { + pub dirty_bitmap: *mut ::std::os::raw::c_void, + pub padding2: __u64, +} +#[test] +fn bindgen_test_layout_kvm_dirty_log__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_dirty_log__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_log__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dirty_bitmap) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_log__bindgen_ty_1), + "::", + stringify!(dirty_bitmap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding2) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_log__bindgen_ty_1), + "::", + stringify!(padding2) + ) + ); +} +impl Default for kvm_dirty_log__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_dirty_log__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_dirty_log__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_dirty_log() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_log)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_log)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_log), + "::", + stringify!(slot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding1) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_log), + "::", + stringify!(padding1) + ) + ); +} +impl Default for kvm_dirty_log { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_dirty_log { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_dirty_log {{ slot: {:?}, padding1: {:?}, __bindgen_anon_1: {:?} }}", + self.slot, self.padding1, self.__bindgen_anon_1 + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_clear_dirty_log { + pub slot: __u32, + pub num_pages: __u32, + pub first_page: __u64, + pub __bindgen_anon_1: kvm_clear_dirty_log__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_clear_dirty_log__bindgen_ty_1 { + pub dirty_bitmap: *mut ::std::os::raw::c_void, + pub padding2: __u64, +} +#[test] +fn bindgen_test_layout_kvm_clear_dirty_log__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_clear_dirty_log__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_clear_dirty_log__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dirty_bitmap) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_clear_dirty_log__bindgen_ty_1), + "::", + stringify!(dirty_bitmap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding2) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_clear_dirty_log__bindgen_ty_1), + "::", + stringify!(padding2) + ) + ); +} +impl Default for kvm_clear_dirty_log__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_clear_dirty_log__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_clear_dirty_log__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_clear_dirty_log() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_clear_dirty_log)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_clear_dirty_log)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_clear_dirty_log), + "::", + stringify!(slot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_pages) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_clear_dirty_log), + "::", + stringify!(num_pages) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).first_page) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_clear_dirty_log), + "::", + stringify!(first_page) + ) + ); +} +impl Default for kvm_clear_dirty_log { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_clear_dirty_log { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_clear_dirty_log {{ slot: {:?}, num_pages: {:?}, first_page: {:?}, __bindgen_anon_1: {:?} }}" , self . slot , self . num_pages , self . first_page , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct kvm_signal_mask { + pub len: __u32, + pub sigset: __IncompleteArrayField<__u8>, +} +#[test] +fn bindgen_test_layout_kvm_signal_mask() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_signal_mask)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_signal_mask)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_signal_mask), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sigset) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_signal_mask), + "::", + stringify!(sigset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_tpr_access_ctl { + pub enabled: __u32, + pub flags: __u32, + pub reserved: [__u32; 8usize], +} +#[test] +fn bindgen_test_layout_kvm_tpr_access_ctl() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(kvm_tpr_access_ctl)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_tpr_access_ctl)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).enabled) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_tpr_access_ctl), + "::", + stringify!(enabled) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_tpr_access_ctl), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_tpr_access_ctl), + "::", + stringify!(reserved) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_vapic_addr { + pub vapic_addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_vapic_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_vapic_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_vapic_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vapic_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_vapic_addr), + "::", + stringify!(vapic_addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_mp_state { + pub mp_state: __u32, +} +#[test] +fn bindgen_test_layout_kvm_mp_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_mp_state)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_mp_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mp_state) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_mp_state), + "::", + stringify!(mp_state) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_guest_debug { + pub control: __u32, + pub pad: __u32, + pub arch: kvm_guest_debug_arch, +} +#[test] +fn bindgen_test_layout_kvm_guest_debug() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_guest_debug)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_guest_debug)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_guest_debug), + "::", + stringify!(control) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_guest_debug), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_guest_debug), + "::", + stringify!(arch) + ) + ); +} +pub const kvm_ioeventfd_flag_nr_datamatch: _bindgen_ty_1 = 0; +pub const kvm_ioeventfd_flag_nr_pio: _bindgen_ty_1 = 1; +pub const kvm_ioeventfd_flag_nr_deassign: _bindgen_ty_1 = 2; +pub const kvm_ioeventfd_flag_nr_virtio_ccw_notify: _bindgen_ty_1 = 3; +pub const kvm_ioeventfd_flag_nr_fast_mmio: _bindgen_ty_1 = 4; +pub const kvm_ioeventfd_flag_nr_max: _bindgen_ty_1 = 5; +pub type _bindgen_ty_1 = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_ioeventfd { + pub datamatch: __u64, + pub addr: __u64, + pub len: __u32, + pub fd: __s32, + pub flags: __u32, + pub pad: [__u8; 36usize], +} +#[test] +fn bindgen_test_layout_kvm_ioeventfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_ioeventfd)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_ioeventfd)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).datamatch) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_ioeventfd), + "::", + stringify!(datamatch) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_ioeventfd), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_ioeventfd), + "::", + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_ioeventfd), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_ioeventfd), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(kvm_ioeventfd), + "::", + stringify!(pad) + ) + ); +} +impl Default for kvm_ioeventfd { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_enable_cap { + pub cap: __u32, + pub flags: __u32, + pub args: [__u64; 4usize], + pub pad: [__u8; 64usize], +} +#[test] +fn bindgen_test_layout_kvm_enable_cap() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 104usize, + concat!("Size of: ", stringify!(kvm_enable_cap)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_enable_cap)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cap) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(cap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(args) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(pad) + ) + ); +} +impl Default for kvm_enable_cap { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_irqchip { + pub irqchip: __u32, + pub pin: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_irqchip() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing_irqchip)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_irqchip)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).irqchip) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_irqchip), + "::", + stringify!(irqchip) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pin) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_irqchip), + "::", + stringify!(pin) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_routing_msi { + pub address_lo: __u32, + pub address_hi: __u32, + pub data: __u32, + pub __bindgen_anon_1: kvm_irq_routing_msi__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_routing_msi__bindgen_ty_1 { + pub pad: __u32, + pub devid: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_msi__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_irq_routing_msi__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_irq_routing_msi__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_msi__bindgen_ty_1), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_msi__bindgen_ty_1), + "::", + stringify!(devid) + ) + ); +} +impl Default for kvm_irq_routing_msi__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_msi__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_routing_msi__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_msi() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_irq_routing_msi)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_msi)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).address_lo) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_msi), + "::", + stringify!(address_lo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).address_hi) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_msi), + "::", + stringify!(address_hi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_msi), + "::", + stringify!(data) + ) + ); +} +impl Default for kvm_irq_routing_msi { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_msi { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_irq_routing_msi {{ address_lo: {:?}, address_hi: {:?}, data: {:?}, __bindgen_anon_1: {:?} }}" , self . address_lo , self . address_hi , self . data , self . __bindgen_anon_1) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_s390_adapter { + pub ind_addr: __u64, + pub summary_addr: __u64, + pub ind_offset: __u64, + pub summary_offset: __u32, + pub adapter_id: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_s390_adapter() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irq_routing_s390_adapter)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_s390_adapter)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ind_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_s390_adapter), + "::", + stringify!(ind_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).summary_addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_s390_adapter), + "::", + stringify!(summary_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ind_offset) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_s390_adapter), + "::", + stringify!(ind_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).summary_offset) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_s390_adapter), + "::", + stringify!(summary_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).adapter_id) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_s390_adapter), + "::", + stringify!(adapter_id) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_hv_sint { + pub vcpu: __u32, + pub sint: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_hv_sint() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing_hv_sint)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_hv_sint)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_hv_sint), + "::", + stringify!(vcpu) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sint) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_hv_sint), + "::", + stringify!(sint) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_xen_evtchn { + pub port: __u32, + pub vcpu: __u32, + pub priority: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_xen_evtchn() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_irq_routing_xen_evtchn)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_xen_evtchn)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_xen_evtchn), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_xen_evtchn), + "::", + stringify!(vcpu) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_xen_evtchn), + "::", + stringify!(priority) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_routing_entry { + pub gsi: __u32, + pub type_: __u32, + pub flags: __u32, + pub pad: __u32, + pub u: kvm_irq_routing_entry__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_routing_entry__bindgen_ty_1 { + pub irqchip: kvm_irq_routing_irqchip, + pub msi: kvm_irq_routing_msi, + pub adapter: kvm_irq_routing_s390_adapter, + pub hv_sint: kvm_irq_routing_hv_sint, + pub xen_evtchn: kvm_irq_routing_xen_evtchn, + pub pad: [__u32; 8usize], +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_entry__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irq_routing_entry__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).irqchip) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1), + "::", + stringify!(irqchip) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msi) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1), + "::", + stringify!(msi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).adapter) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1), + "::", + stringify!(adapter) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hv_sint) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1), + "::", + stringify!(hv_sint) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).xen_evtchn) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1), + "::", + stringify!(xen_evtchn) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1), + "::", + stringify!(pad) + ) + ); +} +impl Default for kvm_irq_routing_entry__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_entry__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_routing_entry__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_entry() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_irq_routing_entry)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_entry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gsi) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry), + "::", + stringify!(gsi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing_entry), + "::", + stringify!(u) + ) + ); +} +impl Default for kvm_irq_routing_entry { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_entry { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_routing_entry {{ gsi: {:?}, type: {:?}, flags: {:?}, pad: {:?}, u: {:?} }}", + self.gsi, self.type_, self.flags, self.pad, self.u + ) + } +} +#[repr(C)] +pub struct kvm_irq_routing { + pub nr: __u32, + pub flags: __u32, + pub entries: __IncompleteArrayField, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_irq_routing)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irq_routing), + "::", + stringify!(entries) + ) + ); +} +impl Default for kvm_irq_routing { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_routing {{ nr: {:?}, flags: {:?}, entries: {:?} }}", + self.nr, self.flags, self.entries + ) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irqfd { + pub fd: __u32, + pub gsi: __u32, + pub flags: __u32, + pub resamplefd: __u32, + pub pad: [__u8; 16usize], +} +#[test] +fn bindgen_test_layout_kvm_irqfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irqfd)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irqfd)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqfd), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gsi) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqfd), + "::", + stringify!(gsi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqfd), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).resamplefd) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqfd), + "::", + stringify!(resamplefd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqfd), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_clock_data { + pub clock: __u64, + pub flags: __u32, + pub pad0: __u32, + pub realtime: __u64, + pub host_tsc: __u64, + pub pad: [__u32; 4usize], +} +#[test] +fn bindgen_test_layout_kvm_clock_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_clock_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_clock_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).clock) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(clock) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(pad0) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).realtime) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(realtime) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).host_tsc) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(host_tsc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_clock_data), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_config_tlb { + pub params: __u64, + pub array: __u64, + pub mmu_type: __u32, + pub array_len: __u32, +} +#[test] +fn bindgen_test_layout_kvm_config_tlb() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_config_tlb)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_config_tlb)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_config_tlb), + "::", + stringify!(params) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).array) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_config_tlb), + "::", + stringify!(array) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mmu_type) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_config_tlb), + "::", + stringify!(mmu_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).array_len) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_config_tlb), + "::", + stringify!(array_len) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_dirty_tlb { + pub bitmap: __u64, + pub num_dirty: __u32, +} +#[test] +fn bindgen_test_layout_kvm_dirty_tlb() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_tlb)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_tlb)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bitmap) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_tlb), + "::", + stringify!(bitmap) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_dirty) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_tlb), + "::", + stringify!(num_dirty) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct kvm_reg_list { + pub n: __u64, + pub reg: __IncompleteArrayField<__u64>, +} +#[test] +fn bindgen_test_layout_kvm_reg_list() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_reg_list)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_reg_list)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).n) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_reg_list), + "::", + stringify!(n) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reg) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_reg_list), + "::", + stringify!(reg) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_one_reg { + pub id: __u64, + pub addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_one_reg() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_one_reg)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_one_reg)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_one_reg), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_one_reg), + "::", + stringify!(addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_msi { + pub address_lo: __u32, + pub address_hi: __u32, + pub data: __u32, + pub flags: __u32, + pub devid: __u32, + pub pad: [__u8; 12usize], +} +#[test] +fn bindgen_test_layout_kvm_msi() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_msi)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_msi)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).address_lo) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_msi), + "::", + stringify!(address_lo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).address_hi) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_msi), + "::", + stringify!(address_hi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_msi), + "::", + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_msi), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_msi), + "::", + stringify!(devid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_msi), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_arm_device_addr { + pub id: __u64, + pub addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_arm_device_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_arm_device_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_arm_device_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_arm_device_addr), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_arm_device_addr), + "::", + stringify!(addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_create_device { + pub type_: __u32, + pub fd: __u32, + pub flags: __u32, +} +#[test] +fn bindgen_test_layout_kvm_create_device() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_create_device)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_create_device)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_create_device), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_create_device), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_create_device), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_device_attr { + pub flags: __u32, + pub group: __u32, + pub attr: __u64, + pub addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_device_attr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_device_attr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_device_attr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_device_attr), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).group) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_device_attr), + "::", + stringify!(group) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).attr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_device_attr), + "::", + stringify!(attr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_device_attr), + "::", + stringify!(addr) + ) + ); +} +pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20: kvm_device_type = 1; +pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_42: kvm_device_type = 2; +pub const kvm_device_type_KVM_DEV_TYPE_XICS: kvm_device_type = 3; +pub const kvm_device_type_KVM_DEV_TYPE_VFIO: kvm_device_type = 4; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2: kvm_device_type = 5; +pub const kvm_device_type_KVM_DEV_TYPE_FLIC: kvm_device_type = 6; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3: kvm_device_type = 7; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS: kvm_device_type = 8; +pub const kvm_device_type_KVM_DEV_TYPE_XIVE: kvm_device_type = 9; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_PV_TIME: kvm_device_type = 10; +pub const kvm_device_type_KVM_DEV_TYPE_RISCV_AIA: kvm_device_type = 11; +pub const kvm_device_type_KVM_DEV_TYPE_MAX: kvm_device_type = 12; +pub type kvm_device_type = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_vfio_spapr_tce { + pub groupfd: __s32, + pub tablefd: __s32, +} +#[test] +fn bindgen_test_layout_kvm_vfio_spapr_tce() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_vfio_spapr_tce)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_vfio_spapr_tce)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).groupfd) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_vfio_spapr_tce), + "::", + stringify!(groupfd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tablefd) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_vfio_spapr_tce), + "::", + stringify!(tablefd) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_enc_region { + pub addr: __u64, + pub size: __u64, +} +#[test] +fn bindgen_test_layout_kvm_enc_region() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_enc_region)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_enc_region)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_enc_region), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_enc_region), + "::", + stringify!(size) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_dirty_gfn { + pub flags: __u32, + pub slot: __u32, + pub offset: __u64, +} +#[test] +fn bindgen_test_layout_kvm_dirty_gfn() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_gfn)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_gfn)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_gfn), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_gfn), + "::", + stringify!(slot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_dirty_gfn), + "::", + stringify!(offset) + ) + ); +} +#[doc = " struct kvm_stats_header - Header of per vm/vcpu binary statistics data.\n @flags: Some extra information for header, always 0 for now.\n @name_size: The size in bytes of the memory which contains statistics\n name string including trailing '\\0'. The memory is allocated\n at the send of statistics descriptor.\n @num_desc: The number of statistics the vm or vcpu has.\n @id_offset: The offset of the vm/vcpu stats' id string in the file pointed\n by vm/vcpu stats fd.\n @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file\n pointd by vm/vcpu stats fd.\n @data_offset: The offset of the vm/vcpu stats' data block in the file\n pointed by vm/vcpu stats fd.\n\n This is the header userspace needs to read from stats fd before any other\n readings. It is used by userspace to discover all the information about the\n vm/vcpu's binary statistics.\n Userspace reads this header from the start of the vm/vcpu's stats fd."] +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_stats_header { + pub flags: __u32, + pub name_size: __u32, + pub num_desc: __u32, + pub id_offset: __u32, + pub desc_offset: __u32, + pub data_offset: __u32, +} +#[test] +fn bindgen_test_layout_kvm_stats_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_stats_header)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_stats_header)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).name_size) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(name_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).num_desc) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(num_desc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id_offset) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(id_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).desc_offset) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(desc_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data_offset) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(data_offset) + ) + ); +} +#[doc = " struct kvm_stats_desc - Descriptor of a KVM statistics.\n @flags: Annotations of the stats, like type, unit, etc.\n @exponent: Used together with @flags to determine the unit.\n @size: The number of data items for this stats.\n Every data item is of type __u64.\n @offset: The offset of the stats to the start of stat structure in\n structure kvm or kvm_vcpu.\n @bucket_size: A parameter value used for histogram stats. It is only used\n\t\tfor linear histogram stats, specifying the size of the bucket;\n @name: The name string for the stats. Its size is indicated by the\n &kvm_stats_header->name_size."] +#[repr(C)] +#[derive(Debug, Default)] +pub struct kvm_stats_desc { + pub flags: __u32, + pub exponent: __s16, + pub size: __u16, + pub offset: __u32, + pub bucket_size: __u32, + pub name: __IncompleteArrayField<::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_kvm_stats_desc() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_stats_desc)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_stats_desc)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_desc), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).exponent) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_desc), + "::", + stringify!(exponent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_desc), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_desc), + "::", + stringify!(offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bucket_size) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_desc), + "::", + stringify!(bucket_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_stats_desc), + "::", + stringify!(name) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_memory_attributes { + pub address: __u64, + pub size: __u64, + pub attributes: __u64, + pub flags: __u64, +} +#[test] +fn bindgen_test_layout_kvm_memory_attributes() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_memory_attributes)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_memory_attributes)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_memory_attributes), + "::", + stringify!(address) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_memory_attributes), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).attributes) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_memory_attributes), + "::", + stringify!(attributes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_memory_attributes), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_create_guest_memfd { + pub size: __u64, + pub flags: __u64, + pub reserved: [__u64; 6usize], +} +#[test] +fn bindgen_test_layout_kvm_create_guest_memfd() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_create_guest_memfd)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_create_guest_memfd)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_create_guest_memfd), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_create_guest_memfd), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_create_guest_memfd), + "::", + stringify!(reserved) + ) + ); +} diff --git a/vendor/kvm-bindings/src/riscv64/fam_wrappers.rs b/vendor/kvm-bindings/src/riscv64/fam_wrappers.rs new file mode 100644 index 0000000..f433172 --- /dev/null +++ b/vendor/kvm-bindings/src/riscv64/fam_wrappers.rs @@ -0,0 +1,49 @@ +// Copyright 2024 © Institute of Software, CAS. All rights reserved. +// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +use vmm_sys_util::fam::{FamStruct, FamStructWrapper}; + +use riscv64::bindings::*; + +// There is no constant in the kernel as far as the maximum number +// of registers on RISC-V, but KVM_GET_REG_LIST usually returns around 160. +const RISCV64_REGS_MAX: usize = 200; + +// Implement the FamStruct trait for kvm_reg_list. +generate_fam_struct_impl!(kvm_reg_list, u64, reg, u64, n, RISCV64_REGS_MAX); + +// Implement the PartialEq trait for kvm_reg_list. +impl PartialEq for kvm_reg_list { + fn eq(&self, other: &kvm_reg_list) -> bool { + // No need to call entries's eq, FamStructWrapper's PartialEq will do it for you + self.n == other.n + } +} + +/// Wrapper over the `kvm_reg_list` structure. +/// +/// The `kvm_reg_list` structure contains a flexible array member. For details check the +/// [KVM API KVM_GET_REG_LIST](https://docs.kernel.org/virt/kvm/api.html#kvm-get-reg-list) +/// documentation. To provide safe access to the array elements, this type is +/// implemented using [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html). +pub type RegList = FamStructWrapper; + +#[cfg(test)] +mod tests { + use super::RegList; + + #[test] + fn test_reg_list_eq() { + let mut wrapper = RegList::new(1).unwrap(); + assert_eq!(wrapper.as_slice().len(), 1); + + let mut wrapper2 = wrapper.clone(); + assert!(wrapper == wrapper2); + + wrapper.as_mut_slice()[0] = 1; + assert!(wrapper != wrapper2); + wrapper2.as_mut_slice()[0] = 1; + assert!(wrapper == wrapper2); + } +} diff --git a/vendor/kvm-bindings/src/x86/mod.rs b/vendor/kvm-bindings/src/riscv64/mod.rs similarity index 73% rename from vendor/kvm-bindings/src/x86/mod.rs rename to vendor/kvm-bindings/src/riscv64/mod.rs index 0a71400..bef3baf 100644 --- a/vendor/kvm-bindings/src/x86/mod.rs +++ b/vendor/kvm-bindings/src/riscv64/mod.rs @@ -1,13 +1,16 @@ +// Copyright 2024 © Institute of Software, CAS. All rights reserved. // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -#[allow(clippy::undocumented_unsafe_blocks)] + #[allow(clippy::all)] -// Keep this until https://github.com/rust-lang/rust-bindgen/issues/1651 is fixed. -#[cfg_attr(test, allow(deref_nullptr))] +#[allow(clippy::undocumented_unsafe_blocks)] pub mod bindings; #[cfg(feature = "fam-wrappers")] pub mod fam_wrappers; +#[cfg(feature = "serde")] +mod serialize; + pub use self::bindings::*; #[cfg(feature = "fam-wrappers")] pub use self::fam_wrappers::*; diff --git a/vendor/kvm-bindings/src/riscv64/serialize.rs b/vendor/kvm-bindings/src/riscv64/serialize.rs new file mode 100644 index 0000000..791d24b --- /dev/null +++ b/vendor/kvm-bindings/src/riscv64/serialize.rs @@ -0,0 +1,96 @@ +// Copyright 2024 © Institute of Software, CAS. All rights reserved. +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +use bindings::{ + kvm_mp_state, kvm_one_reg, kvm_riscv_aia_csr, kvm_riscv_config, kvm_riscv_core, kvm_riscv_csr, + kvm_riscv_sbi_sta, kvm_riscv_smstateen_csr, kvm_riscv_timer, user_regs_struct, +}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use zerocopy::{transmute, AsBytes}; + +serde_impls! { + kvm_mp_state, + kvm_one_reg, + kvm_riscv_config, + kvm_riscv_core, + user_regs_struct, + kvm_riscv_csr, + kvm_riscv_aia_csr, + kvm_riscv_smstateen_csr, + kvm_riscv_timer, + kvm_riscv_sbi_sta +} + +#[cfg(test)] +mod tests { + use bindings::*; + use serde::{Deserialize, Serialize}; + + fn is_serde Deserialize<'de> + Default>() { + let serialized = bincode::serialize(&T::default()).unwrap(); + let deserialized = bincode::deserialize::(serialized.as_ref()).unwrap(); + let serialized_again = bincode::serialize(&deserialized).unwrap(); + // Compare the serialized state after a roundtrip, to work around issues with + // bindings not implementing `PartialEq`. + assert_eq!(serialized, serialized_again); + } + + #[test] + fn static_assert_serde_implementations() { + // This test statically (= at compile-time) asserts that various bindgen generated + // structures implement serde's `Serialize` and `Deserialize` traits. + // This is to make sure that we do not accidentally remove those implementations + // when regenerating bindings. If this test fails to compile, please add + // + // #[cfg_attr( + // feature = "serde", + // derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) + // )] + // + // to all structures causing compilation errors (we need the zerocopy traits, as the + // `Serialize` and `Deserialize` implementations are provided by the `serde_impls!` macro + // above, which implements serialization based on zerocopy's `FromBytes` and `AsBytes` + // traits that it expects to be derived). + // + // NOTE: This only include "top-level" items, and does not list out bindgen-anonymous types + // (e.g. types like `kvm_vcpu_events__bindgen_ty_5`). These types can change name across + // bindgen versions. If after re-adding the derives to all the below items you can compile + // errors about anonymous types not implementing `Serialize`/`Deserialize`, please also add + // the derives to all anonymous types references in the definitions of the below items. + + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + } + + fn is_serde_json Deserialize<'de> + Default>() { + let serialized = serde_json::to_string(&T::default()).unwrap(); + let deserialized = serde_json::from_str::(serialized.as_ref()).unwrap(); + let serialized_again = serde_json::to_string(&deserialized).unwrap(); + // Compare the serialized state after a roundtrip, to work around issues with + // bindings not implementing `PartialEq`. + assert_eq!(serialized, serialized_again); + } + + #[test] + fn test_json_serde() { + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + } +} diff --git a/vendor/kvm-bindings/src/serialize.rs b/vendor/kvm-bindings/src/serialize.rs new file mode 100644 index 0000000..75c6851 --- /dev/null +++ b/vendor/kvm-bindings/src/serialize.rs @@ -0,0 +1,66 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Module containing serialization utilities + +/// Macro that generates serde::Serialize and serde::Deserialize implementations for the given types. +/// This macro assumes that the types implement zerocopy::FromBytes and zerocopy::AsBytes, and uses +/// these implementations to serialize as opaque byte arrays. During deserialization, it will +/// try to deserialize as a `Vec`. If this deserialized `Vec` has a length that equals `size_of::`, +/// it will transmute to `T` (using zerocopy), otherwise the `Vec` will either be zero-padded, or truncated. +/// This will hopefully allow live update of bindings across kernel versions even if the kernel adds +/// new fields to the end of some struct (we heavily rely on the kernel not making ABI breaking changes here). +macro_rules! serde_impls { + ($($typ: ty),*) => { + $( + impl Serialize for $typ { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer + { + let bytes = self.as_bytes(); + serializer.serialize_bytes(bytes) + } + } + + impl<'de> Deserialize<'de> for $typ { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de> + { + struct BytesVisitor; + + impl<'a> serde::de::Visitor<'a> for BytesVisitor { + type Value = [u8; std::mem::size_of::<$typ>()]; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("a byte array") + } + + fn visit_bytes(self, bytes: &[u8]) -> Result { + let mut backing = [0u8; std::mem::size_of::<$typ>()]; + let limit = bytes.len().min(backing.len()); + backing[..limit].copy_from_slice(&bytes[..limit]); + Ok(backing) + } + + fn visit_seq>(self, mut seq: A) -> Result { + let mut backing = [0u8; std::mem::size_of::<$typ>()]; + + for backing_byte in &mut backing { + let Some(byte) = seq.next_element()? else { break }; + + *backing_byte = byte; + } + + Ok(backing) + } + } + + let backing = deserializer.deserialize_bytes(BytesVisitor)?; + + Ok(transmute!(backing)) + } + } + )* + } +} diff --git a/vendor/kvm-bindings/src/x86/bindings.rs b/vendor/kvm-bindings/src/x86_64/bindings.rs similarity index 66% rename from vendor/kvm-bindings/src/x86/bindings.rs rename to vendor/kvm-bindings/src/x86_64/bindings.rs index 2c0d210..c36cd40 100644 --- a/vendor/kvm-bindings/src/x86/bindings.rs +++ b/vendor/kvm-bindings/src/x86_64/bindings.rs @@ -1,7 +1,11 @@ -/* automatically generated by rust-bindgen 0.59.1 */ +/* automatically generated by rust-bindgen 0.64.0 */ -#[repr(C)] +#[repr(transparent)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct __BindgenBitfieldUnit { storage: Storage, } @@ -80,8 +84,12 @@ where } } } -#[repr(C)] +#[repr(transparent)] #[derive(Default)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] @@ -154,6 +162,7 @@ impl ::std::cmp::PartialEq for __BindgenUnionField { } impl ::std::cmp::Eq for __BindgenUnionField {} pub const __BITS_PER_LONG: u32 = 64; +pub const __BITS_PER_LONG_LONG: u32 = 64; pub const __FD_SETSIZE: u32 = 1024; pub const _IOC_NRBITS: u32 = 8; pub const _IOC_TYPEBITS: u32 = 8; @@ -205,12 +214,15 @@ pub const KVM_NR_IRQCHIPS: u32 = 3; pub const KVM_RUN_X86_SMM: u32 = 1; pub const KVM_RUN_X86_BUS_LOCK: u32 = 2; pub const KVM_APIC_REG_SIZE: u32 = 1024; +pub const KVM_SREGS2_FLAGS_PDPTRS_VALID: u32 = 1; pub const KVM_MSR_FILTER_MAX_BITMAP_SIZE: u32 = 1536; pub const KVM_MSR_FILTER_READ: u32 = 1; pub const KVM_MSR_FILTER_WRITE: u32 = 2; +pub const KVM_MSR_FILTER_RANGE_VALID_MASK: u32 = 3; pub const KVM_MSR_FILTER_MAX_RANGES: u32 = 16; pub const KVM_MSR_FILTER_DEFAULT_ALLOW: u32 = 0; pub const KVM_MSR_FILTER_DEFAULT_DENY: u32 = 1; +pub const KVM_MSR_FILTER_VALID_MASK: u32 = 1; pub const KVM_CPUID_FLAG_SIGNIFCANT_INDEX: u32 = 1; pub const KVM_CPUID_FLAG_STATEFUL_FUNC: u32 = 2; pub const KVM_CPUID_FLAG_STATE_READ_NEXT: u32 = 4; @@ -218,12 +230,15 @@ pub const KVM_GUESTDBG_USE_SW_BP: u32 = 65536; pub const KVM_GUESTDBG_USE_HW_BP: u32 = 131072; pub const KVM_GUESTDBG_INJECT_DB: u32 = 262144; pub const KVM_GUESTDBG_INJECT_BP: u32 = 524288; +pub const KVM_GUESTDBG_BLOCKIRQ: u32 = 1048576; pub const KVM_PIT_FLAGS_HPET_LEGACY: u32 = 1; +pub const KVM_PIT_FLAGS_SPEAKER_DATA_ON: u32 = 2; pub const KVM_VCPUEVENT_VALID_NMI_PENDING: u32 = 1; pub const KVM_VCPUEVENT_VALID_SIPI_VECTOR: u32 = 2; pub const KVM_VCPUEVENT_VALID_SHADOW: u32 = 4; pub const KVM_VCPUEVENT_VALID_SMM: u32 = 8; pub const KVM_VCPUEVENT_VALID_PAYLOAD: u32 = 16; +pub const KVM_VCPUEVENT_VALID_TRIPLE_FAULT: u32 = 32; pub const KVM_X86_SHADOW_INT_MOV_SS: u32 = 1; pub const KVM_X86_SHADOW_INT_STI: u32 = 2; pub const KVM_MAX_XCRS: u32 = 16; @@ -236,6 +251,8 @@ pub const KVM_X86_QUIRK_CD_NW_CLEARED: u32 = 2; pub const KVM_X86_QUIRK_LAPIC_MMIO_HOLE: u32 = 4; pub const KVM_X86_QUIRK_OUT_7E_INC_RIP: u32 = 8; pub const KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT: u32 = 16; +pub const KVM_X86_QUIRK_FIX_HYPERCALL_INSN: u32 = 32; +pub const KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS: u32 = 64; pub const KVM_STATE_NESTED_FORMAT_VMX: u32 = 0; pub const KVM_STATE_NESTED_FORMAT_SVM: u32 = 1; pub const KVM_STATE_NESTED_GUEST_MODE: u32 = 1; @@ -248,46 +265,52 @@ pub const KVM_STATE_NESTED_SMM_VMXON: u32 = 2; pub const KVM_STATE_NESTED_VMX_VMCS_SIZE: u32 = 4096; pub const KVM_STATE_NESTED_SVM_VMCB_SIZE: u32 = 4096; pub const KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE: u32 = 1; +pub const KVM_X86_XCOMP_GUEST_SUPP: u32 = 0; pub const KVM_PMU_EVENT_ALLOW: u32 = 0; pub const KVM_PMU_EVENT_DENY: u32 = 1; +pub const KVM_XEN_HVM_CONFIG_HYPERCALL_MSR: u32 = 1; +pub const KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL: u32 = 2; +pub const KVM_XEN_HVM_CONFIG_SHARED_INFO: u32 = 4; +pub const KVM_XEN_HVM_CONFIG_RUNSTATE: u32 = 8; +pub const KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL: u32 = 16; +pub const KVM_XEN_HVM_CONFIG_EVTCHN_SEND: u32 = 32; +pub const KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG: u32 = 64; +pub const KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE: u32 = 128; +pub const KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA: u32 = 256; +pub const KVM_XEN_EVTCHN_DEASSIGN: u32 = 1; +pub const KVM_XEN_EVTCHN_UPDATE: u32 = 2; +pub const KVM_XEN_EVTCHN_RESET: u32 = 4; +pub const KVM_XEN_ATTR_TYPE_LONG_MODE: u32 = 0; +pub const KVM_XEN_ATTR_TYPE_SHARED_INFO: u32 = 1; +pub const KVM_XEN_ATTR_TYPE_UPCALL_VECTOR: u32 = 2; +pub const KVM_XEN_ATTR_TYPE_EVTCHN: u32 = 3; +pub const KVM_XEN_ATTR_TYPE_XEN_VERSION: u32 = 4; +pub const KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG: u32 = 5; +pub const KVM_XEN_ATTR_TYPE_SHARED_INFO_HVA: u32 = 6; +pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO: u32 = 0; +pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO: u32 = 1; +pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR: u32 = 2; +pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT: u32 = 3; +pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA: u32 = 4; +pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST: u32 = 5; +pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID: u32 = 6; +pub const KVM_XEN_VCPU_ATTR_TYPE_TIMER: u32 = 7; +pub const KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR: u32 = 8; +pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA: u32 = 9; +pub const KVM_X2APIC_API_USE_32BIT_IDS: u32 = 1; +pub const KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK: u32 = 2; +pub const KVM_HYPERV_CONN_ID_MASK: u32 = 16777215; +pub const KVM_HYPERV_EVENTFD_DEASSIGN: u32 = 1; +pub const KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT: u32 = 56; +pub const KVM_VCPU_TSC_CTRL: u32 = 0; +pub const KVM_VCPU_TSC_OFFSET: u32 = 0; +pub const KVM_X86_DEFAULT_VM: u32 = 0; +pub const KVM_X86_SW_PROTECTED_VM: u32 = 1; pub const KVM_API_VERSION: u32 = 12; -pub const KVM_TRC_SHIFT: u32 = 16; -pub const KVM_TRC_ENTRYEXIT: u32 = 65536; -pub const KVM_TRC_HANDLER: u32 = 131072; -pub const KVM_TRC_VMENTRY: u32 = 65537; -pub const KVM_TRC_VMEXIT: u32 = 65538; -pub const KVM_TRC_PAGE_FAULT: u32 = 131073; -pub const KVM_TRC_HEAD_SIZE: u32 = 12; -pub const KVM_TRC_CYCLE_SIZE: u32 = 8; -pub const KVM_TRC_EXTRA_MAX: u32 = 7; -pub const KVM_TRC_INJ_VIRQ: u32 = 131074; -pub const KVM_TRC_REDELIVER_EVT: u32 = 131075; -pub const KVM_TRC_PEND_INTR: u32 = 131076; -pub const KVM_TRC_IO_READ: u32 = 131077; -pub const KVM_TRC_IO_WRITE: u32 = 131078; -pub const KVM_TRC_CR_READ: u32 = 131079; -pub const KVM_TRC_CR_WRITE: u32 = 131080; -pub const KVM_TRC_DR_READ: u32 = 131081; -pub const KVM_TRC_DR_WRITE: u32 = 131082; -pub const KVM_TRC_MSR_READ: u32 = 131083; -pub const KVM_TRC_MSR_WRITE: u32 = 131084; -pub const KVM_TRC_CPUID: u32 = 131085; -pub const KVM_TRC_INTR: u32 = 131086; -pub const KVM_TRC_NMI: u32 = 131087; -pub const KVM_TRC_VMMCALL: u32 = 131088; -pub const KVM_TRC_HLT: u32 = 131089; -pub const KVM_TRC_CLTS: u32 = 131090; -pub const KVM_TRC_LMSW: u32 = 131091; -pub const KVM_TRC_APIC_ACCESS: u32 = 131092; -pub const KVM_TRC_TDP_FAULT: u32 = 131093; -pub const KVM_TRC_GTLB_WRITE: u32 = 131094; -pub const KVM_TRC_STLB_WRITE: u32 = 131095; -pub const KVM_TRC_STLB_INVAL: u32 = 131096; -pub const KVM_TRC_PPC_INSTR: u32 = 131097; pub const KVM_MEM_LOG_DIRTY_PAGES: u32 = 1; pub const KVM_MEM_READONLY: u32 = 2; +pub const KVM_MEM_GUEST_MEMFD: u32 = 4; pub const KVM_PIT_SPEAKER_DUMMY: u32 = 1; -pub const KVM_S390_CMMA_PEEK: u32 = 1; pub const KVM_EXIT_HYPERV_SYNIC: u32 = 1; pub const KVM_EXIT_HYPERV_HCALL: u32 = 2; pub const KVM_EXIT_HYPERV_SYNDBG: u32 = 3; @@ -329,30 +352,31 @@ pub const KVM_EXIT_DIRTY_RING_FULL: u32 = 31; pub const KVM_EXIT_AP_RESET_HOLD: u32 = 32; pub const KVM_EXIT_X86_BUS_LOCK: u32 = 33; pub const KVM_EXIT_XEN: u32 = 34; +pub const KVM_EXIT_RISCV_SBI: u32 = 35; +pub const KVM_EXIT_RISCV_CSR: u32 = 36; +pub const KVM_EXIT_NOTIFY: u32 = 37; +pub const KVM_EXIT_LOONGARCH_IOCSR: u32 = 38; +pub const KVM_EXIT_MEMORY_FAULT: u32 = 39; pub const KVM_INTERNAL_ERROR_EMULATION: u32 = 1; pub const KVM_INTERNAL_ERROR_SIMUL_EX: u32 = 2; pub const KVM_INTERNAL_ERROR_DELIVERY_EV: u32 = 3; pub const KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON: u32 = 4; +pub const KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES: u32 = 1; pub const KVM_EXIT_IO_IN: u32 = 0; pub const KVM_EXIT_IO_OUT: u32 = 1; -pub const KVM_S390_RESET_POR: u32 = 1; -pub const KVM_S390_RESET_CLEAR: u32 = 2; -pub const KVM_S390_RESET_SUBSYSTEM: u32 = 4; -pub const KVM_S390_RESET_CPU_INIT: u32 = 8; -pub const KVM_S390_RESET_IPL: u32 = 16; pub const KVM_SYSTEM_EVENT_SHUTDOWN: u32 = 1; pub const KVM_SYSTEM_EVENT_RESET: u32 = 2; pub const KVM_SYSTEM_EVENT_CRASH: u32 = 3; +pub const KVM_SYSTEM_EVENT_WAKEUP: u32 = 4; +pub const KVM_SYSTEM_EVENT_SUSPEND: u32 = 5; +pub const KVM_SYSTEM_EVENT_SEV_TERM: u32 = 6; pub const KVM_MSR_EXIT_REASON_INVAL: u32 = 1; pub const KVM_MSR_EXIT_REASON_UNKNOWN: u32 = 2; pub const KVM_MSR_EXIT_REASON_FILTER: u32 = 4; +pub const KVM_MSR_EXIT_REASON_VALID_MASK: u32 = 7; +pub const KVM_NOTIFY_CONTEXT_INVALID: u32 = 1; +pub const KVM_MEMORY_EXIT_FLAG_PRIVATE: u32 = 8; pub const SYNC_REGS_SIZE_BYTES: u32 = 2048; -pub const KVM_S390_MEMOP_LOGICAL_READ: u32 = 0; -pub const KVM_S390_MEMOP_LOGICAL_WRITE: u32 = 1; -pub const KVM_S390_MEMOP_SIDA_READ: u32 = 2; -pub const KVM_S390_MEMOP_SIDA_WRITE: u32 = 3; -pub const KVM_S390_MEMOP_F_CHECK_ONLY: u32 = 1; -pub const KVM_S390_MEMOP_F_INJECT_EXCEPTION: u32 = 2; pub const KVM_MP_STATE_RUNNABLE: u32 = 0; pub const KVM_MP_STATE_UNINITIALIZED: u32 = 1; pub const KVM_MP_STATE_INIT_RECEIVED: u32 = 2; @@ -363,28 +387,7 @@ pub const KVM_MP_STATE_CHECK_STOP: u32 = 6; pub const KVM_MP_STATE_OPERATING: u32 = 7; pub const KVM_MP_STATE_LOAD: u32 = 8; pub const KVM_MP_STATE_AP_RESET_HOLD: u32 = 9; -pub const KVM_S390_SIGP_STOP: u32 = 4294836224; -pub const KVM_S390_PROGRAM_INT: u32 = 4294836225; -pub const KVM_S390_SIGP_SET_PREFIX: u32 = 4294836226; -pub const KVM_S390_RESTART: u32 = 4294836227; -pub const KVM_S390_INT_PFAULT_INIT: u32 = 4294836228; -pub const KVM_S390_INT_PFAULT_DONE: u32 = 4294836229; -pub const KVM_S390_MCHK: u32 = 4294840320; -pub const KVM_S390_INT_CLOCK_COMP: u32 = 4294905860; -pub const KVM_S390_INT_CPU_TIMER: u32 = 4294905861; -pub const KVM_S390_INT_VIRTIO: u32 = 4294911491; -pub const KVM_S390_INT_SERVICE: u32 = 4294910977; -pub const KVM_S390_INT_EMERGENCY: u32 = 4294906369; -pub const KVM_S390_INT_EXTERNAL_CALL: u32 = 4294906370; -pub const KVM_S390_INT_IO_MIN: u32 = 0; -pub const KVM_S390_INT_IO_MAX: u32 = 4294836223; -pub const KVM_S390_INT_IO_AI_MASK: u32 = 67108864; -pub const KVM_S390_PGM_FLAGS_ILC_VALID: u32 = 1; -pub const KVM_S390_PGM_FLAGS_ILC_0: u32 = 2; -pub const KVM_S390_PGM_FLAGS_ILC_1: u32 = 4; -pub const KVM_S390_PGM_FLAGS_ILC_MASK: u32 = 6; -pub const KVM_S390_PGM_FLAGS_NO_REWIND: u32 = 8; -pub const KVM_S390_STOP_FLAG_STORE_STATUS: u32 = 1; +pub const KVM_MP_STATE_SUSPENDED: u32 = 10; pub const KVM_GUESTDBG_ENABLE: u32 = 1; pub const KVM_GUESTDBG_SINGLESTEP: u32 = 2; pub const KVM_X86_DISABLE_EXITS_MWAIT: u32 = 1; @@ -392,11 +395,6 @@ pub const KVM_X86_DISABLE_EXITS_HLT: u32 = 2; pub const KVM_X86_DISABLE_EXITS_PAUSE: u32 = 4; pub const KVM_X86_DISABLE_EXITS_CSTATE: u32 = 8; pub const KVM_X86_DISABLE_VALID_EXITS: u32 = 15; -pub const KVM_PPC_PVINFO_FLAGS_EV_IDLE: u32 = 1; -pub const KVM_PPC_PAGE_SIZES_MAX_SZ: u32 = 8; -pub const KVM_PPC_PAGE_SIZES_REAL: u32 = 1; -pub const KVM_PPC_1T_SEGMENTS: u32 = 2; -pub const KVM_PPC_NO_HASH: u32 = 4; pub const KVMIO: u32 = 174; pub const KVM_VM_S390_UCONTROL: u32 = 1; pub const KVM_VM_PPC_HV: u32 = 1; @@ -599,17 +597,53 @@ pub const KVM_CAP_SET_GUEST_DEBUG2: u32 = 195; pub const KVM_CAP_SGX_ATTRIBUTE: u32 = 196; pub const KVM_CAP_VM_COPY_ENC_CONTEXT_FROM: u32 = 197; pub const KVM_CAP_PTP_KVM: u32 = 198; +pub const KVM_CAP_HYPERV_ENFORCE_CPUID: u32 = 199; +pub const KVM_CAP_SREGS2: u32 = 200; +pub const KVM_CAP_EXIT_HYPERCALL: u32 = 201; +pub const KVM_CAP_PPC_RPT_INVALIDATE: u32 = 202; +pub const KVM_CAP_BINARY_STATS_FD: u32 = 203; +pub const KVM_CAP_EXIT_ON_EMULATION_FAILURE: u32 = 204; +pub const KVM_CAP_ARM_MTE: u32 = 205; +pub const KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM: u32 = 206; +pub const KVM_CAP_VM_GPA_BITS: u32 = 207; +pub const KVM_CAP_XSAVE2: u32 = 208; +pub const KVM_CAP_SYS_ATTRIBUTES: u32 = 209; +pub const KVM_CAP_PPC_AIL_MODE_3: u32 = 210; +pub const KVM_CAP_S390_MEM_OP_EXTENSION: u32 = 211; +pub const KVM_CAP_PMU_CAPABILITY: u32 = 212; +pub const KVM_CAP_DISABLE_QUIRKS2: u32 = 213; +pub const KVM_CAP_VM_TSC_CONTROL: u32 = 214; +pub const KVM_CAP_SYSTEM_EVENT_DATA: u32 = 215; +pub const KVM_CAP_ARM_SYSTEM_SUSPEND: u32 = 216; +pub const KVM_CAP_S390_PROTECTED_DUMP: u32 = 217; +pub const KVM_CAP_X86_TRIPLE_FAULT_EVENT: u32 = 218; +pub const KVM_CAP_X86_NOTIFY_VMEXIT: u32 = 219; +pub const KVM_CAP_VM_DISABLE_NX_HUGE_PAGES: u32 = 220; +pub const KVM_CAP_S390_ZPCI_OP: u32 = 221; +pub const KVM_CAP_S390_CPU_TOPOLOGY: u32 = 222; +pub const KVM_CAP_DIRTY_LOG_RING_ACQ_REL: u32 = 223; +pub const KVM_CAP_S390_PROTECTED_ASYNC_DISABLE: u32 = 224; +pub const KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP: u32 = 225; +pub const KVM_CAP_PMU_EVENT_MASKED_EVENTS: u32 = 226; +pub const KVM_CAP_COUNTER_OFFSET: u32 = 227; +pub const KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE: u32 = 228; +pub const KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES: u32 = 229; +pub const KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES: u32 = 230; +pub const KVM_CAP_USER_MEMORY2: u32 = 231; +pub const KVM_CAP_MEMORY_FAULT_INFO: u32 = 232; +pub const KVM_CAP_MEMORY_ATTRIBUTES: u32 = 233; +pub const KVM_CAP_GUEST_MEMFD: u32 = 234; +pub const KVM_CAP_VM_TYPES: u32 = 235; pub const KVM_IRQ_ROUTING_IRQCHIP: u32 = 1; pub const KVM_IRQ_ROUTING_MSI: u32 = 2; pub const KVM_IRQ_ROUTING_S390_ADAPTER: u32 = 3; pub const KVM_IRQ_ROUTING_HV_SINT: u32 = 4; -pub const KVM_XEN_HVM_CONFIG_HYPERCALL_MSR: u32 = 1; -pub const KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL: u32 = 2; -pub const KVM_XEN_HVM_CONFIG_SHARED_INFO: u32 = 4; -pub const KVM_XEN_HVM_CONFIG_RUNSTATE: u32 = 8; +pub const KVM_IRQ_ROUTING_XEN_EVTCHN: u32 = 5; pub const KVM_IRQFD_FLAG_DEASSIGN: u32 = 1; pub const KVM_IRQFD_FLAG_RESAMPLE: u32 = 2; pub const KVM_CLOCK_TSC_STABLE: u32 = 2; +pub const KVM_CLOCK_REALTIME: u32 = 4; +pub const KVM_CLOCK_HOST_TSC: u32 = 8; pub const KVM_MMU_FSL_BOOKE_NOHV: u32 = 0; pub const KVM_MMU_FSL_BOOKE_HV: u32 = 1; pub const KVM_REG_ARCH_MASK: i64 = -72057594037927936; @@ -622,6 +656,7 @@ pub const KVM_REG_S390: u64 = 5764607523034234880; pub const KVM_REG_ARM64: u64 = 6917529027641081856; pub const KVM_REG_MIPS: u64 = 8070450532247928832; pub const KVM_REG_RISCV: i64 = -9223372036854775808; +pub const KVM_REG_LOONGARCH: i64 = -8070450532247928832; pub const KVM_REG_SIZE_SHIFT: u32 = 52; pub const KVM_REG_SIZE_MASK: u64 = 67553994410557440; pub const KVM_REG_SIZE_U8: u32 = 0; @@ -635,45 +670,45 @@ pub const KVM_REG_SIZE_U1024: u64 = 31525197391593472; pub const KVM_REG_SIZE_U2048: u64 = 36028797018963968; pub const KVM_MSI_VALID_DEVID: u32 = 1; pub const KVM_CREATE_DEVICE_TEST: u32 = 1; +pub const KVM_DEV_VFIO_FILE: u32 = 1; +pub const KVM_DEV_VFIO_FILE_ADD: u32 = 1; +pub const KVM_DEV_VFIO_FILE_DEL: u32 = 2; pub const KVM_DEV_VFIO_GROUP: u32 = 1; pub const KVM_DEV_VFIO_GROUP_ADD: u32 = 1; pub const KVM_DEV_VFIO_GROUP_DEL: u32 = 2; pub const KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE: u32 = 3; pub const KVM_S390_STORE_STATUS_NOADDR: i32 = -1; pub const KVM_S390_STORE_STATUS_PREFIXED: i32 = -2; -pub const KVM_XEN_ATTR_TYPE_LONG_MODE: u32 = 0; -pub const KVM_XEN_ATTR_TYPE_SHARED_INFO: u32 = 1; -pub const KVM_XEN_ATTR_TYPE_UPCALL_VECTOR: u32 = 2; -pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO: u32 = 0; -pub const KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO: u32 = 1; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR: u32 = 2; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT: u32 = 3; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA: u32 = 4; -pub const KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST: u32 = 5; -pub const KVM_DEV_ASSIGN_ENABLE_IOMMU: u32 = 1; -pub const KVM_DEV_ASSIGN_PCI_2_3: u32 = 2; -pub const KVM_DEV_ASSIGN_MASK_INTX: u32 = 4; -pub const KVM_DEV_IRQ_HOST_INTX: u32 = 1; -pub const KVM_DEV_IRQ_HOST_MSI: u32 = 2; -pub const KVM_DEV_IRQ_HOST_MSIX: u32 = 4; -pub const KVM_DEV_IRQ_GUEST_INTX: u32 = 256; -pub const KVM_DEV_IRQ_GUEST_MSI: u32 = 512; -pub const KVM_DEV_IRQ_GUEST_MSIX: u32 = 1024; -pub const KVM_DEV_IRQ_HOST_MASK: u32 = 255; -pub const KVM_DEV_IRQ_GUEST_MASK: u32 = 65280; -pub const KVM_MAX_MSIX_PER_DEV: u32 = 256; -pub const KVM_X2APIC_API_USE_32BIT_IDS: u32 = 1; -pub const KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK: u32 = 2; -pub const KVM_ARM_DEV_EL1_VTIMER: u32 = 1; -pub const KVM_ARM_DEV_EL1_PTIMER: u32 = 2; -pub const KVM_ARM_DEV_PMU: u32 = 4; -pub const KVM_HYPERV_CONN_ID_MASK: u32 = 16777215; -pub const KVM_HYPERV_EVENTFD_DEASSIGN: u32 = 1; pub const KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE: u32 = 1; pub const KVM_DIRTY_LOG_INITIALLY_SET: u32 = 2; pub const KVM_DIRTY_GFN_F_MASK: u32 = 3; pub const KVM_BUS_LOCK_DETECTION_OFF: u32 = 1; pub const KVM_BUS_LOCK_DETECTION_EXIT: u32 = 2; +pub const KVM_PMU_CAP_DISABLE: u32 = 1; +pub const KVM_STATS_TYPE_SHIFT: u32 = 0; +pub const KVM_STATS_TYPE_MASK: u32 = 15; +pub const KVM_STATS_TYPE_CUMULATIVE: u32 = 0; +pub const KVM_STATS_TYPE_INSTANT: u32 = 1; +pub const KVM_STATS_TYPE_PEAK: u32 = 2; +pub const KVM_STATS_TYPE_LINEAR_HIST: u32 = 3; +pub const KVM_STATS_TYPE_LOG_HIST: u32 = 4; +pub const KVM_STATS_TYPE_MAX: u32 = 4; +pub const KVM_STATS_UNIT_SHIFT: u32 = 4; +pub const KVM_STATS_UNIT_MASK: u32 = 240; +pub const KVM_STATS_UNIT_NONE: u32 = 0; +pub const KVM_STATS_UNIT_BYTES: u32 = 16; +pub const KVM_STATS_UNIT_SECONDS: u32 = 32; +pub const KVM_STATS_UNIT_CYCLES: u32 = 48; +pub const KVM_STATS_UNIT_BOOLEAN: u32 = 64; +pub const KVM_STATS_UNIT_MAX: u32 = 64; +pub const KVM_STATS_BASE_SHIFT: u32 = 8; +pub const KVM_STATS_BASE_MASK: u32 = 3840; +pub const KVM_STATS_BASE_POW10: u32 = 0; +pub const KVM_STATS_BASE_POW2: u32 = 256; +pub const KVM_STATS_BASE_MAX: u32 = 256; +pub const KVM_X86_NOTIFY_VMEXIT_ENABLED: u32 = 1; +pub const KVM_X86_NOTIFY_VMEXIT_USER: u32 = 2; +pub const KVM_MEMORY_ATTRIBUTE_PRIVATE: u32 = 8; pub type __s8 = ::std::os::raw::c_schar; pub type __u8 = ::std::os::raw::c_uchar; pub type __s16 = ::std::os::raw::c_short; @@ -689,6 +724,8 @@ pub struct __kernel_fd_set { } #[test] fn bindgen_test_layout___kernel_fd_set() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fd_set> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<__kernel_fd_set>(), 128usize, @@ -700,7 +737,7 @@ fn bindgen_test_layout___kernel_fd_set() { concat!("Alignment of ", stringify!(__kernel_fd_set)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<__kernel_fd_set>())).fds_bits as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -739,6 +776,8 @@ pub struct __kernel_fsid_t { } #[test] fn bindgen_test_layout___kernel_fsid_t() { + const UNINIT: ::std::mem::MaybeUninit<__kernel_fsid_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<__kernel_fsid_t>(), 8usize, @@ -750,7 +789,7 @@ fn bindgen_test_layout___kernel_fsid_t() { concat!("Alignment of ", stringify!(__kernel_fsid_t)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<__kernel_fsid_t>())).val as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -771,6 +810,8 @@ pub type __kernel_clockid_t = ::std::os::raw::c_int; pub type __kernel_caddr_t = *mut ::std::os::raw::c_char; pub type __kernel_uid16_t = ::std::os::raw::c_ushort; pub type __kernel_gid16_t = ::std::os::raw::c_ushort; +pub type __s128 = i128; +pub type __u128 = u128; pub type __le16 = __u16; pub type __be16 = __u16; pub type __le32 = __u32; @@ -782,82 +823,10 @@ pub type __wsum = __u32; pub type __poll_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_memory_alias { - pub slot: __u32, - pub flags: __u32, - pub guest_phys_addr: __u64, - pub memory_size: __u64, - pub target_phys_addr: __u64, -} -#[test] -fn bindgen_test_layout_kvm_memory_alias() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_memory_alias)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_memory_alias)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_memory_alias), - "::", - stringify!(slot) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_memory_alias), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_phys_addr as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_memory_alias), - "::", - stringify!(guest_phys_addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).memory_size as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_memory_alias), - "::", - stringify!(memory_size) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).target_phys_addr as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(kvm_memory_alias), - "::", - stringify!(target_phys_addr) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_pic_state { pub last_irr: __u8, pub irr: __u8, @@ -878,6 +847,8 @@ pub struct kvm_pic_state { } #[test] fn bindgen_test_layout_kvm_pic_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -889,7 +860,7 @@ fn bindgen_test_layout_kvm_pic_state() { concat!("Alignment of ", stringify!(kvm_pic_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).last_irr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).last_irr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -899,7 +870,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irr) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -909,7 +880,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).imr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).imr) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -919,7 +890,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).isr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).isr) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -929,7 +900,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).priority_add as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).priority_add) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -939,7 +910,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irq_base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irq_base) as usize - ptr as usize }, 5usize, concat!( "Offset of field: ", @@ -949,7 +920,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).read_reg_select as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).read_reg_select) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", @@ -959,7 +930,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).poll as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).poll) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -969,7 +940,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).special_mask as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).special_mask) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -979,7 +950,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).init_state as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).init_state) as usize - ptr as usize }, 9usize, concat!( "Offset of field: ", @@ -989,7 +960,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).auto_eoi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).auto_eoi) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -999,9 +970,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rotate_on_auto_eoi as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rotate_on_auto_eoi) as usize - ptr as usize }, 11usize, concat!( "Offset of field: ", @@ -1011,9 +980,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).special_fully_nested_mode as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).special_fully_nested_mode) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -1023,7 +990,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).init4 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).init4) as usize - ptr as usize }, 13usize, concat!( "Offset of field: ", @@ -1033,7 +1000,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).elcr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).elcr) as usize - ptr as usize }, 14usize, concat!( "Offset of field: ", @@ -1043,7 +1010,7 @@ fn bindgen_test_layout_kvm_pic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).elcr_mask as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).elcr_mask) as usize - ptr as usize }, 15usize, concat!( "Offset of field: ", @@ -1055,6 +1022,10 @@ fn bindgen_test_layout_kvm_pic_state() { } #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_ioapic_state { pub base_address: __u64, pub ioregsel: __u32, @@ -1065,12 +1036,20 @@ pub struct kvm_ioapic_state { } #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub union kvm_ioapic_state__bindgen_ty_1 { pub bits: __u64, pub fields: kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1 { pub vector: __u8, pub _bitfield_align_1: [u8; 0], @@ -1080,6 +1059,9 @@ pub struct kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1097,10 +1079,7 @@ fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vector - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1110,10 +1089,7 @@ fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -1123,10 +1099,7 @@ fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dest_id - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dest_id) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -1274,6 +1247,9 @@ impl kvm_ioapic_state__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1285,9 +1261,7 @@ fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_ioapic_state__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).bits as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).bits) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1297,9 +1271,7 @@ fn bindgen_test_layout_kvm_ioapic_state__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fields as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).fields) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1318,8 +1290,15 @@ impl Default for kvm_ioapic_state__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_ioapic_state__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_ioapic_state__bindgen_ty_1 {{ union }}") + } +} #[test] fn bindgen_test_layout_kvm_ioapic_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 216usize, @@ -1331,7 +1310,7 @@ fn bindgen_test_layout_kvm_ioapic_state() { concat!("Alignment of ", stringify!(kvm_ioapic_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).base_address as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).base_address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1341,7 +1320,7 @@ fn bindgen_test_layout_kvm_ioapic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ioregsel as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ioregsel) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1351,7 +1330,7 @@ fn bindgen_test_layout_kvm_ioapic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -1361,7 +1340,7 @@ fn bindgen_test_layout_kvm_ioapic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irr) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -1371,7 +1350,7 @@ fn bindgen_test_layout_kvm_ioapic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -1381,7 +1360,7 @@ fn bindgen_test_layout_kvm_ioapic_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).redirtbl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).redirtbl) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -1400,8 +1379,17 @@ impl Default for kvm_ioapic_state { } } } +impl ::std::fmt::Debug for kvm_ioapic_state { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_ioapic_state {{ base_address: {:?}, ioregsel: {:?}, id: {:?}, irr: {:?}, pad: {:?}, redirtbl: {:?} }}" , self . base_address , self . ioregsel , self . id , self . irr , self . pad , self . redirtbl) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_regs { pub rax: __u64, pub rbx: __u64, @@ -1424,6 +1412,8 @@ pub struct kvm_regs { } #[test] fn bindgen_test_layout_kvm_regs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 144usize, @@ -1435,7 +1425,7 @@ fn bindgen_test_layout_kvm_regs() { concat!("Alignment of ", stringify!(kvm_regs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rax as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rax) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1445,7 +1435,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rbx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rbx) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1455,7 +1445,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rcx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rcx) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -1465,7 +1455,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rdx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rdx) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -1475,7 +1465,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rsi) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -1485,7 +1475,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rdi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rdi) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -1495,7 +1485,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rsp as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rsp) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -1505,7 +1495,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rbp as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rbp) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -1515,7 +1505,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r8 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r8) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -1525,7 +1515,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r9 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r9) as usize - ptr as usize }, 72usize, concat!( "Offset of field: ", @@ -1535,7 +1525,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r10 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r10) as usize - ptr as usize }, 80usize, concat!( "Offset of field: ", @@ -1545,7 +1535,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r11 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r11) as usize - ptr as usize }, 88usize, concat!( "Offset of field: ", @@ -1555,7 +1545,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r12 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r12) as usize - ptr as usize }, 96usize, concat!( "Offset of field: ", @@ -1565,7 +1555,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r13 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r13) as usize - ptr as usize }, 104usize, concat!( "Offset of field: ", @@ -1575,7 +1565,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r14 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r14) as usize - ptr as usize }, 112usize, concat!( "Offset of field: ", @@ -1585,7 +1575,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r15 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r15) as usize - ptr as usize }, 120usize, concat!( "Offset of field: ", @@ -1595,7 +1585,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rip as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rip) as usize - ptr as usize }, 128usize, concat!( "Offset of field: ", @@ -1605,7 +1595,7 @@ fn bindgen_test_layout_kvm_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rflags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rflags) as usize - ptr as usize }, 136usize, concat!( "Offset of field: ", @@ -1617,11 +1607,17 @@ fn bindgen_test_layout_kvm_regs() { } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_lapic_state { pub regs: [::std::os::raw::c_char; 1024usize], } #[test] fn bindgen_test_layout_kvm_lapic_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 1024usize, @@ -1633,7 +1629,7 @@ fn bindgen_test_layout_kvm_lapic_state() { concat!("Alignment of ", stringify!(kvm_lapic_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1654,6 +1650,10 @@ impl Default for kvm_lapic_state { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_segment { pub base: __u64, pub limit: __u32, @@ -1671,6 +1671,8 @@ pub struct kvm_segment { } #[test] fn bindgen_test_layout_kvm_segment() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -1682,7 +1684,7 @@ fn bindgen_test_layout_kvm_segment() { concat!("Alignment of ", stringify!(kvm_segment)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).base) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1692,7 +1694,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).limit as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1702,7 +1704,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).selector as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).selector) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -1712,7 +1714,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 14usize, concat!( "Offset of field: ", @@ -1722,7 +1724,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).present as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).present) as usize - ptr as usize }, 15usize, concat!( "Offset of field: ", @@ -1732,7 +1734,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dpl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dpl) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -1742,7 +1744,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).db as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).db) as usize - ptr as usize }, 17usize, concat!( "Offset of field: ", @@ -1752,7 +1754,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).s as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).s) as usize - ptr as usize }, 18usize, concat!( "Offset of field: ", @@ -1762,7 +1764,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).l as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).l) as usize - ptr as usize }, 19usize, concat!( "Offset of field: ", @@ -1772,7 +1774,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).g as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).g) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -1782,7 +1784,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).avl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).avl) as usize - ptr as usize }, 21usize, concat!( "Offset of field: ", @@ -1792,7 +1794,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).unusable as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).unusable) as usize - ptr as usize }, 22usize, concat!( "Offset of field: ", @@ -1802,7 +1804,7 @@ fn bindgen_test_layout_kvm_segment() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 23usize, concat!( "Offset of field: ", @@ -1814,6 +1816,10 @@ fn bindgen_test_layout_kvm_segment() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_dtable { pub base: __u64, pub limit: __u16, @@ -1821,6 +1827,8 @@ pub struct kvm_dtable { } #[test] fn bindgen_test_layout_kvm_dtable() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1832,7 +1840,7 @@ fn bindgen_test_layout_kvm_dtable() { concat!("Alignment of ", stringify!(kvm_dtable)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).base) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1842,7 +1850,7 @@ fn bindgen_test_layout_kvm_dtable() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).limit as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1852,7 +1860,7 @@ fn bindgen_test_layout_kvm_dtable() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -1864,6 +1872,10 @@ fn bindgen_test_layout_kvm_dtable() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_sregs { pub cs: kvm_segment, pub ds: kvm_segment, @@ -1886,6 +1898,8 @@ pub struct kvm_sregs { } #[test] fn bindgen_test_layout_kvm_sregs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 312usize, @@ -1897,7 +1911,7 @@ fn bindgen_test_layout_kvm_sregs() { concat!("Alignment of ", stringify!(kvm_sregs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1907,7 +1921,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ds as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ds) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -1917,7 +1931,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).es as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).es) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -1927,7 +1941,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fs) as usize - ptr as usize }, 72usize, concat!( "Offset of field: ", @@ -1937,7 +1951,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gs) as usize - ptr as usize }, 96usize, concat!( "Offset of field: ", @@ -1947,7 +1961,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ss as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ss) as usize - ptr as usize }, 120usize, concat!( "Offset of field: ", @@ -1957,7 +1971,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tr) as usize - ptr as usize }, 144usize, concat!( "Offset of field: ", @@ -1967,7 +1981,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ldt as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ldt) as usize - ptr as usize }, 168usize, concat!( "Offset of field: ", @@ -1977,7 +1991,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gdt as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gdt) as usize - ptr as usize }, 192usize, concat!( "Offset of field: ", @@ -1987,7 +2001,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).idt as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).idt) as usize - ptr as usize }, 208usize, concat!( "Offset of field: ", @@ -1997,7 +2011,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr0 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cr0) as usize - ptr as usize }, 224usize, concat!( "Offset of field: ", @@ -2007,7 +2021,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr2 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cr2) as usize - ptr as usize }, 232usize, concat!( "Offset of field: ", @@ -2017,7 +2031,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr3 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cr3) as usize - ptr as usize }, 240usize, concat!( "Offset of field: ", @@ -2027,7 +2041,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr4 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cr4) as usize - ptr as usize }, 248usize, concat!( "Offset of field: ", @@ -2037,7 +2051,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr8 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cr8) as usize - ptr as usize }, 256usize, concat!( "Offset of field: ", @@ -2047,7 +2061,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).efer as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).efer) as usize - ptr as usize }, 264usize, concat!( "Offset of field: ", @@ -2057,7 +2071,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apic_base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).apic_base) as usize - ptr as usize }, 272usize, concat!( "Offset of field: ", @@ -2067,7 +2081,7 @@ fn bindgen_test_layout_kvm_sregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).interrupt_bitmap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).interrupt_bitmap) as usize - ptr as usize }, 280usize, concat!( "Offset of field: ", @@ -2079,204 +2093,446 @@ fn bindgen_test_layout_kvm_sregs() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_fpu { - pub fpr: [[__u8; 16usize]; 8usize], - pub fcw: __u16, - pub fsw: __u16, - pub ftwx: __u8, - pub pad1: __u8, - pub last_opcode: __u16, - pub last_ip: __u64, - pub last_dp: __u64, - pub xmm: [[__u8; 16usize]; 16usize], - pub mxcsr: __u32, - pub pad2: __u32, +pub struct kvm_sregs2 { + pub cs: kvm_segment, + pub ds: kvm_segment, + pub es: kvm_segment, + pub fs: kvm_segment, + pub gs: kvm_segment, + pub ss: kvm_segment, + pub tr: kvm_segment, + pub ldt: kvm_segment, + pub gdt: kvm_dtable, + pub idt: kvm_dtable, + pub cr0: __u64, + pub cr2: __u64, + pub cr3: __u64, + pub cr4: __u64, + pub cr8: __u64, + pub efer: __u64, + pub apic_base: __u64, + pub flags: __u64, + pub pdptrs: [__u64; 4usize], } #[test] -fn bindgen_test_layout_kvm_fpu() { +fn bindgen_test_layout_kvm_sregs2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 416usize, - concat!("Size of: ", stringify!(kvm_fpu)) + ::std::mem::size_of::(), + 320usize, + concat!("Size of: ", stringify!(kvm_sregs2)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_fpu)) + concat!("Alignment of ", stringify!(kvm_sregs2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fpr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(fpr) + stringify!(cs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fcw as *const _ as usize }, - 128usize, + unsafe { ::std::ptr::addr_of!((*ptr).ds) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(fcw) + stringify!(ds) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fsw as *const _ as usize }, - 130usize, + unsafe { ::std::ptr::addr_of!((*ptr).es) as usize - ptr as usize }, + 48usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(fsw) + stringify!(es) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ftwx as *const _ as usize }, - 132usize, + unsafe { ::std::ptr::addr_of!((*ptr).fs) as usize - ptr as usize }, + 72usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(ftwx) + stringify!(fs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad1 as *const _ as usize }, - 133usize, + unsafe { ::std::ptr::addr_of!((*ptr).gs) as usize - ptr as usize }, + 96usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(pad1) + stringify!(gs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).last_opcode as *const _ as usize }, - 134usize, + unsafe { ::std::ptr::addr_of!((*ptr).ss) as usize - ptr as usize }, + 120usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(last_opcode) + stringify!(ss) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).last_ip as *const _ as usize }, - 136usize, + unsafe { ::std::ptr::addr_of!((*ptr).tr) as usize - ptr as usize }, + 144usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(last_ip) + stringify!(tr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).last_dp as *const _ as usize }, - 144usize, + unsafe { ::std::ptr::addr_of!((*ptr).ldt) as usize - ptr as usize }, + 168usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(last_dp) + stringify!(ldt) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xmm as *const _ as usize }, - 152usize, + unsafe { ::std::ptr::addr_of!((*ptr).gdt) as usize - ptr as usize }, + 192usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(xmm) + stringify!(gdt) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mxcsr as *const _ as usize }, - 408usize, + unsafe { ::std::ptr::addr_of!((*ptr).idt) as usize - ptr as usize }, + 208usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(mxcsr) + stringify!(idt) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad2 as *const _ as usize }, - 412usize, + unsafe { ::std::ptr::addr_of!((*ptr).cr0) as usize - ptr as usize }, + 224usize, concat!( "Offset of field: ", - stringify!(kvm_fpu), + stringify!(kvm_sregs2), "::", - stringify!(pad2) + stringify!(cr0) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_msr_entry { - pub index: __u32, - pub reserved: __u32, - pub data: __u64, -} -#[test] -fn bindgen_test_layout_kvm_msr_entry() { assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_msr_entry)) + unsafe { ::std::ptr::addr_of!((*ptr).cr2) as usize - ptr as usize }, + 232usize, + concat!( + "Offset of field: ", + stringify!(kvm_sregs2), + "::", + stringify!(cr2) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_msr_entry)) + unsafe { ::std::ptr::addr_of!((*ptr).cr3) as usize - ptr as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(kvm_sregs2), + "::", + stringify!(cr3) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).cr4) as usize - ptr as usize }, + 248usize, concat!( "Offset of field: ", - stringify!(kvm_msr_entry), + stringify!(kvm_sregs2), "::", - stringify!(index) + stringify!(cr4) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).cr8) as usize - ptr as usize }, + 256usize, concat!( "Offset of field: ", - stringify!(kvm_msr_entry), + stringify!(kvm_sregs2), "::", - stringify!(reserved) + stringify!(cr8) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).efer) as usize - ptr as usize }, + 264usize, concat!( "Offset of field: ", - stringify!(kvm_msr_entry), + stringify!(kvm_sregs2), "::", - stringify!(data) + stringify!(efer) ) ); -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct kvm_msrs { - pub nmsrs: __u32, - pub pad: __u32, - pub entries: __IncompleteArrayField, -} -#[test] -fn bindgen_test_layout_kvm_msrs() { assert_eq!( - ::std::mem::size_of::(), - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).apic_base) as usize - ptr as usize }, + 272usize, + concat!( + "Offset of field: ", + stringify!(kvm_sregs2), + "::", + stringify!(apic_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(kvm_sregs2), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pdptrs) as usize - ptr as usize }, + 288usize, + concat!( + "Offset of field: ", + stringify!(kvm_sregs2), + "::", + stringify!(pdptrs) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_fpu { + pub fpr: [[__u8; 16usize]; 8usize], + pub fcw: __u16, + pub fsw: __u16, + pub ftwx: __u8, + pub pad1: __u8, + pub last_opcode: __u16, + pub last_ip: __u64, + pub last_dp: __u64, + pub xmm: [[__u8; 16usize]; 16usize], + pub mxcsr: __u32, + pub pad2: __u32, +} +#[test] +fn bindgen_test_layout_kvm_fpu() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 416usize, + concat!("Size of: ", stringify!(kvm_fpu)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_fpu)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fpr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(fpr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fcw) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(fcw) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fsw) as usize - ptr as usize }, + 130usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(fsw) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ftwx) as usize - ptr as usize }, + 132usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(ftwx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 133usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last_opcode) as usize - ptr as usize }, + 134usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(last_opcode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last_ip) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(last_ip) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last_dp) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(last_dp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).xmm) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(xmm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mxcsr) as usize - ptr as usize }, + 408usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(mxcsr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 412usize, + concat!( + "Offset of field: ", + stringify!(kvm_fpu), + "::", + stringify!(pad2) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_msr_entry { + pub index: __u32, + pub reserved: __u32, + pub data: __u64, +} +#[test] +fn bindgen_test_layout_kvm_msr_entry() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_msr_entry)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_msr_entry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_msr_entry), + "::", + stringify!(index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_msr_entry), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_msr_entry), + "::", + stringify!(data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_msrs { + pub nmsrs: __u32, + pub pad: __u32, + pub entries: __IncompleteArrayField, +} +#[test] +fn bindgen_test_layout_kvm_msrs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, concat!("Size of: ", stringify!(kvm_msrs)) ); assert_eq!( @@ -2285,7 +2541,7 @@ fn bindgen_test_layout_kvm_msrs() { concat!("Alignment of ", stringify!(kvm_msrs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nmsrs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nmsrs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2295,7 +2551,7 @@ fn bindgen_test_layout_kvm_msrs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2305,7 +2561,7 @@ fn bindgen_test_layout_kvm_msrs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2323,6 +2579,8 @@ pub struct kvm_msr_list { } #[test] fn bindgen_test_layout_kvm_msr_list() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4usize, @@ -2334,7 +2592,7 @@ fn bindgen_test_layout_kvm_msr_list() { concat!("Alignment of ", stringify!(kvm_msr_list)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nmsrs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nmsrs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2344,7 +2602,7 @@ fn bindgen_test_layout_kvm_msr_list() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).indices as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).indices) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2364,6 +2622,8 @@ pub struct kvm_msr_filter_range { } #[test] fn bindgen_test_layout_kvm_msr_filter_range() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -2375,7 +2635,7 @@ fn bindgen_test_layout_kvm_msr_filter_range() { concat!("Alignment of ", stringify!(kvm_msr_filter_range)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2385,7 +2645,7 @@ fn bindgen_test_layout_kvm_msr_filter_range() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nmsrs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nmsrs) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2395,7 +2655,7 @@ fn bindgen_test_layout_kvm_msr_filter_range() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).base) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2405,7 +2665,7 @@ fn bindgen_test_layout_kvm_msr_filter_range() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bitmap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).bitmap) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2432,6 +2692,8 @@ pub struct kvm_msr_filter { } #[test] fn bindgen_test_layout_kvm_msr_filter() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 392usize, @@ -2443,7 +2705,7 @@ fn bindgen_test_layout_kvm_msr_filter() { concat!("Alignment of ", stringify!(kvm_msr_filter)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2453,7 +2715,7 @@ fn bindgen_test_layout_kvm_msr_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ranges as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ranges) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2484,6 +2746,8 @@ pub struct kvm_cpuid_entry { } #[test] fn bindgen_test_layout_kvm_cpuid_entry() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -2495,7 +2759,7 @@ fn bindgen_test_layout_kvm_cpuid_entry() { concat!("Alignment of ", stringify!(kvm_cpuid_entry)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).function as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).function) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2505,7 +2769,7 @@ fn bindgen_test_layout_kvm_cpuid_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).eax as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).eax) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2515,7 +2779,7 @@ fn bindgen_test_layout_kvm_cpuid_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ebx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ebx) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2525,7 +2789,7 @@ fn bindgen_test_layout_kvm_cpuid_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ecx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ecx) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2535,7 +2799,7 @@ fn bindgen_test_layout_kvm_cpuid_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).edx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).edx) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2545,7 +2809,7 @@ fn bindgen_test_layout_kvm_cpuid_entry() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -2564,6 +2828,8 @@ pub struct kvm_cpuid { } #[test] fn bindgen_test_layout_kvm_cpuid() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -2575,7 +2841,7 @@ fn bindgen_test_layout_kvm_cpuid() { concat!("Alignment of ", stringify!(kvm_cpuid)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nent as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nent) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2585,7 +2851,7 @@ fn bindgen_test_layout_kvm_cpuid() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2595,7 +2861,7 @@ fn bindgen_test_layout_kvm_cpuid() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2607,6 +2873,10 @@ fn bindgen_test_layout_kvm_cpuid() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_cpuid_entry2 { pub function: __u32, pub index: __u32, @@ -2619,6 +2889,8 @@ pub struct kvm_cpuid_entry2 { } #[test] fn bindgen_test_layout_kvm_cpuid_entry2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 40usize, @@ -2630,7 +2902,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { concat!("Alignment of ", stringify!(kvm_cpuid_entry2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).function as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).function) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2640,7 +2912,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2650,7 +2922,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2660,7 +2932,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).eax as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).eax) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2670,7 +2942,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ebx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ebx) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2680,7 +2952,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ecx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ecx) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -2690,7 +2962,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).edx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).edx) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2700,7 +2972,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 28usize, concat!( "Offset of field: ", @@ -2712,6 +2984,10 @@ fn bindgen_test_layout_kvm_cpuid_entry2() { } #[repr(C)] #[derive(Debug, Default)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_cpuid2 { pub nent: __u32, pub padding: __u32, @@ -2719,6 +2995,8 @@ pub struct kvm_cpuid2 { } #[test] fn bindgen_test_layout_kvm_cpuid2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -2730,7 +3008,7 @@ fn bindgen_test_layout_kvm_cpuid2() { concat!("Alignment of ", stringify!(kvm_cpuid2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nent as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nent) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2740,7 +3018,7 @@ fn bindgen_test_layout_kvm_cpuid2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2750,7 +3028,7 @@ fn bindgen_test_layout_kvm_cpuid2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2762,6 +3040,10 @@ fn bindgen_test_layout_kvm_cpuid2() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_pit_channel_state { pub count: __u32, pub latched_count: __u16, @@ -2779,6 +3061,9 @@ pub struct kvm_pit_channel_state { } #[test] fn bindgen_test_layout_kvm_pit_channel_state() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -2790,7 +3075,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { concat!("Alignment of ", stringify!(kvm_pit_channel_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2800,9 +3085,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).latched_count as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).latched_count) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2812,9 +3095,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).count_latched as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).count_latched) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", @@ -2824,9 +3105,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).status_latched as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).status_latched) as usize - ptr as usize }, 7usize, concat!( "Offset of field: ", @@ -2836,7 +3115,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).status as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2846,9 +3125,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).read_state as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).read_state) as usize - ptr as usize }, 9usize, concat!( "Offset of field: ", @@ -2858,9 +3135,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).write_state as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).write_state) as usize - ptr as usize }, 10usize, concat!( "Offset of field: ", @@ -2870,9 +3145,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).write_latch as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).write_latch) as usize - ptr as usize }, 11usize, concat!( "Offset of field: ", @@ -2882,7 +3155,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rw_mode as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rw_mode) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2892,7 +3165,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mode as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize }, 13usize, concat!( "Offset of field: ", @@ -2902,7 +3175,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bcd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).bcd) as usize - ptr as usize }, 14usize, concat!( "Offset of field: ", @@ -2912,7 +3185,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gate as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gate) as usize - ptr as usize }, 15usize, concat!( "Offset of field: ", @@ -2922,9 +3195,7 @@ fn bindgen_test_layout_kvm_pit_channel_state() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).count_load_time as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).count_load_time) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2945,6 +3216,8 @@ pub struct kvm_debug_exit_arch { } #[test] fn bindgen_test_layout_kvm_debug_exit_arch() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -2956,7 +3229,7 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { concat!("Alignment of ", stringify!(kvm_debug_exit_arch)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).exception as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exception) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2966,7 +3239,7 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2976,7 +3249,7 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pc as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pc) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2986,7 +3259,7 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dr6 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dr6) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2996,7 +3269,7 @@ fn bindgen_test_layout_kvm_debug_exit_arch() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dr7 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dr7) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -3013,6 +3286,8 @@ pub struct kvm_guest_debug_arch { } #[test] fn bindgen_test_layout_kvm_guest_debug_arch() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -3024,7 +3299,7 @@ fn bindgen_test_layout_kvm_guest_debug_arch() { concat!("Alignment of ", stringify!(kvm_guest_debug_arch)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).debugreg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).debugreg) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3041,6 +3316,8 @@ pub struct kvm_pit_state { } #[test] fn bindgen_test_layout_kvm_pit_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 72usize, @@ -3052,7 +3329,7 @@ fn bindgen_test_layout_kvm_pit_state() { concat!("Alignment of ", stringify!(kvm_pit_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).channels as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).channels) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3064,6 +3341,10 @@ fn bindgen_test_layout_kvm_pit_state() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_pit_state2 { pub channels: [kvm_pit_channel_state; 3usize], pub flags: __u32, @@ -3071,6 +3352,8 @@ pub struct kvm_pit_state2 { } #[test] fn bindgen_test_layout_kvm_pit_state2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 112usize, @@ -3082,7 +3365,7 @@ fn bindgen_test_layout_kvm_pit_state2() { concat!("Alignment of ", stringify!(kvm_pit_state2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).channels as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).channels) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3092,7 +3375,7 @@ fn bindgen_test_layout_kvm_pit_state2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 72usize, concat!( "Offset of field: ", @@ -3102,7 +3385,7 @@ fn bindgen_test_layout_kvm_pit_state2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 76usize, concat!( "Offset of field: ", @@ -3120,6 +3403,8 @@ pub struct kvm_reinject_control { } #[test] fn bindgen_test_layout_kvm_reinject_control() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -3131,9 +3416,7 @@ fn bindgen_test_layout_kvm_reinject_control() { concat!("Alignment of ", stringify!(kvm_reinject_control)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pit_reinject as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pit_reinject) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3143,7 +3426,7 @@ fn bindgen_test_layout_kvm_reinject_control() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3155,6 +3438,10 @@ fn bindgen_test_layout_kvm_reinject_control() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_vcpu_events { pub exception: kvm_vcpu_events__bindgen_ty_1, pub interrupt: kvm_vcpu_events__bindgen_ty_2, @@ -3162,12 +3449,17 @@ pub struct kvm_vcpu_events { pub sipi_vector: __u32, pub flags: __u32, pub smi: kvm_vcpu_events__bindgen_ty_4, - pub reserved: [__u8; 27usize], + pub triple_fault: kvm_vcpu_events__bindgen_ty_5, + pub reserved: [__u8; 26usize], pub exception_has_payload: __u8, pub exception_payload: __u64, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_vcpu_events__bindgen_ty_1 { pub injected: __u8, pub nr: __u8, @@ -3177,6 +3469,9 @@ pub struct kvm_vcpu_events__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -3188,9 +3483,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_vcpu_events__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).injected as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).injected) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3200,9 +3493,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3212,10 +3503,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).has_error_code as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).has_error_code) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3225,9 +3513,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pending as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pending) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -3237,10 +3523,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).error_code as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).error_code) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3252,6 +3535,10 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_vcpu_events__bindgen_ty_2 { pub injected: __u8, pub nr: __u8, @@ -3260,6 +3547,9 @@ pub struct kvm_vcpu_events__bindgen_ty_2 { } #[test] fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4usize, @@ -3271,9 +3561,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() { concat!("Alignment of ", stringify!(kvm_vcpu_events__bindgen_ty_2)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).injected as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).injected) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3283,9 +3571,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3295,9 +3581,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).soft as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).soft) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3307,9 +3591,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).shadow as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).shadow) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -3321,6 +3603,10 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_vcpu_events__bindgen_ty_3 { pub injected: __u8, pub pending: __u8, @@ -3329,6 +3615,9 @@ pub struct kvm_vcpu_events__bindgen_ty_3 { } #[test] fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4usize, @@ -3340,9 +3629,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() { concat!("Alignment of ", stringify!(kvm_vcpu_events__bindgen_ty_3)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).injected as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).injected) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3352,9 +3639,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pending as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pending) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3364,9 +3649,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).masked as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).masked) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3376,9 +3659,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -3390,6 +3671,10 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_vcpu_events__bindgen_ty_4 { pub smm: __u8, pub pending: __u8, @@ -3398,6 +3683,9 @@ pub struct kvm_vcpu_events__bindgen_ty_4 { } #[test] fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4usize, @@ -3409,9 +3697,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() { concat!("Alignment of ", stringify!(kvm_vcpu_events__bindgen_ty_4)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).smm as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).smm) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3421,9 +3707,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pending as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pending) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3433,10 +3717,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).smm_inside_nmi as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).smm_inside_nmi) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3446,10 +3727,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).latched_init as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).latched_init) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -3459,8 +3737,45 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() { ) ); } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_vcpu_events__bindgen_ty_5 { + pub pending: __u8, +} +#[test] +fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_5() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(kvm_vcpu_events__bindgen_ty_5)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_vcpu_events__bindgen_ty_5)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pending) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_vcpu_events__bindgen_ty_5), + "::", + stringify!(pending) + ) + ); +} #[test] fn bindgen_test_layout_kvm_vcpu_events() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -3472,7 +3787,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { concat!("Alignment of ", stringify!(kvm_vcpu_events)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).exception as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exception) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3482,7 +3797,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).interrupt as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).interrupt) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3492,7 +3807,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nmi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nmi) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -3502,7 +3817,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sipi_vector as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sipi_vector) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3512,7 +3827,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -3522,7 +3837,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).smi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).smi) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -3532,8 +3847,18 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).triple_fault) as usize - ptr as usize }, 28usize, + concat!( + "Offset of field: ", + stringify!(kvm_vcpu_events), + "::", + stringify!(triple_fault) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 29usize, concat!( "Offset of field: ", stringify!(kvm_vcpu_events), @@ -3542,9 +3867,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).exception_has_payload as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).exception_has_payload) as usize - ptr as usize }, 55usize, concat!( "Offset of field: ", @@ -3554,9 +3877,7 @@ fn bindgen_test_layout_kvm_vcpu_events() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).exception_payload as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).exception_payload) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -3568,6 +3889,10 @@ fn bindgen_test_layout_kvm_vcpu_events() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_debugregs { pub db: [__u64; 4usize], pub dr6: __u64, @@ -3577,6 +3902,8 @@ pub struct kvm_debugregs { } #[test] fn bindgen_test_layout_kvm_debugregs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 128usize, @@ -3588,7 +3915,7 @@ fn bindgen_test_layout_kvm_debugregs() { concat!("Alignment of ", stringify!(kvm_debugregs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).db as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).db) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3598,7 +3925,7 @@ fn bindgen_test_layout_kvm_debugregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dr6 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dr6) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -3608,7 +3935,7 @@ fn bindgen_test_layout_kvm_debugregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dr7 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dr7) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -3618,7 +3945,7 @@ fn bindgen_test_layout_kvm_debugregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -3628,7 +3955,7 @@ fn bindgen_test_layout_kvm_debugregs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -3639,12 +3966,19 @@ fn bindgen_test_layout_kvm_debugregs() { ); } #[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_xsave { pub region: [__u32; 1024usize], + pub extra: __IncompleteArrayField<__u32>, } #[test] fn bindgen_test_layout_kvm_xsave() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4096usize, @@ -3656,7 +3990,7 @@ fn bindgen_test_layout_kvm_xsave() { concat!("Alignment of ", stringify!(kvm_xsave)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).region as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).region) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3665,6 +3999,16 @@ fn bindgen_test_layout_kvm_xsave() { stringify!(region) ) ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).extra) as usize - ptr as usize }, + 4096usize, + concat!( + "Offset of field: ", + stringify!(kvm_xsave), + "::", + stringify!(extra) + ) + ); } impl Default for kvm_xsave { fn default() -> Self { @@ -3677,6 +4021,10 @@ impl Default for kvm_xsave { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_xcr { pub xcr: __u32, pub reserved: __u32, @@ -3684,6 +4032,8 @@ pub struct kvm_xcr { } #[test] fn bindgen_test_layout_kvm_xcr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -3695,7 +4045,7 @@ fn bindgen_test_layout_kvm_xcr() { concat!("Alignment of ", stringify!(kvm_xcr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xcr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).xcr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3705,7 +4055,7 @@ fn bindgen_test_layout_kvm_xcr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3715,7 +4065,7 @@ fn bindgen_test_layout_kvm_xcr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).value as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3727,6 +4077,10 @@ fn bindgen_test_layout_kvm_xcr() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] pub struct kvm_xcrs { pub nr_xcrs: __u32, pub flags: __u32, @@ -3735,6 +4089,8 @@ pub struct kvm_xcrs { } #[test] fn bindgen_test_layout_kvm_xcrs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 392usize, @@ -3746,7 +4102,7 @@ fn bindgen_test_layout_kvm_xcrs() { concat!("Alignment of ", stringify!(kvm_xcrs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr_xcrs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr_xcrs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3756,7 +4112,7 @@ fn bindgen_test_layout_kvm_xcrs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3766,7 +4122,7 @@ fn bindgen_test_layout_kvm_xcrs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xcrs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).xcrs) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3776,7 +4132,7 @@ fn bindgen_test_layout_kvm_xcrs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 264usize, concat!( "Offset of field: ", @@ -3795,6 +4151,8 @@ pub struct kvm_sync_regs { } #[test] fn bindgen_test_layout_kvm_sync_regs() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 520usize, @@ -3806,7 +4164,7 @@ fn bindgen_test_layout_kvm_sync_regs() { concat!("Alignment of ", stringify!(kvm_sync_regs)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3816,7 +4174,7 @@ fn bindgen_test_layout_kvm_sync_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sregs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sregs) as usize - ptr as usize }, 144usize, concat!( "Offset of field: ", @@ -3826,7 +4184,7 @@ fn bindgen_test_layout_kvm_sync_regs() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).events as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).events) as usize - ptr as usize }, 456usize, concat!( "Offset of field: ", @@ -3844,6 +4202,9 @@ pub struct kvm_vmx_nested_state_data { } #[test] fn bindgen_test_layout_kvm_vmx_nested_state_data() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8192usize, @@ -3855,9 +4216,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_data() { concat!("Alignment of ", stringify!(kvm_vmx_nested_state_data)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmcs12 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vmcs12) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3867,9 +4226,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_data() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).shadow_vmcs12 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).shadow_vmcs12) as usize - ptr as usize }, 4096usize, concat!( "Offset of field: ", @@ -3905,6 +4262,9 @@ pub struct kvm_vmx_nested_state_hdr__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_vmx_nested_state_hdr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 2usize, @@ -3922,10 +4282,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flags as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3937,6 +4294,9 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr__bindgen_ty_1() { } #[test] fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -3948,9 +4308,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { concat!("Alignment of ", stringify!(kvm_vmx_nested_state_hdr)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmxon_pa as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vmxon_pa) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3960,9 +4318,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmcs12_pa as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vmcs12_pa) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3972,7 +4328,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).smm as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).smm) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3982,7 +4338,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 18usize, concat!( "Offset of field: ", @@ -3992,7 +4348,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -4002,10 +4358,7 @@ fn bindgen_test_layout_kvm_vmx_nested_state_hdr() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).preemption_timer_deadline - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).preemption_timer_deadline) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -4022,6 +4375,9 @@ pub struct kvm_svm_nested_state_data { } #[test] fn bindgen_test_layout_kvm_svm_nested_state_data() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4096usize, @@ -4033,9 +4389,7 @@ fn bindgen_test_layout_kvm_svm_nested_state_data() { concat!("Alignment of ", stringify!(kvm_svm_nested_state_data)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmcb12 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vmcb12) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4061,6 +4415,9 @@ pub struct kvm_svm_nested_state_hdr { } #[test] fn bindgen_test_layout_kvm_svm_nested_state_hdr() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -4072,9 +4429,7 @@ fn bindgen_test_layout_kvm_svm_nested_state_hdr() { concat!("Alignment of ", stringify!(kvm_svm_nested_state_hdr)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmcb_pa as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vmcb_pa) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4101,6 +4456,9 @@ pub union kvm_nested_state__bindgen_ty_1 { } #[test] fn bindgen_test_layout_kvm_nested_state__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 120usize, @@ -4112,9 +4470,7 @@ fn bindgen_test_layout_kvm_nested_state__bindgen_ty_1() { concat!("Alignment of ", stringify!(kvm_nested_state__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmx as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).vmx) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4124,9 +4480,7 @@ fn bindgen_test_layout_kvm_nested_state__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).svm as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).svm) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4136,9 +4490,7 @@ fn bindgen_test_layout_kvm_nested_state__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4157,49 +4509,188 @@ impl Default for kvm_nested_state__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_nested_state__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_nested_state__bindgen_ty_1 {{ union }}") + } +} #[repr(C)] pub struct kvm_nested_state__bindgen_ty_2 { - pub vmx: __BindgenUnionField<[kvm_vmx_nested_state_data; 0usize]>, - pub svm: __BindgenUnionField<[kvm_svm_nested_state_data; 0usize]>, + pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_2: __BindgenUnionField, pub bindgen_union_field: [u8; 0usize], } +#[repr(C)] +#[derive(Debug)] +pub struct kvm_nested_state__bindgen_ty_2__bindgen_ty_1 { + pub __empty_vmx: kvm_nested_state__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, + pub vmx: __IncompleteArrayField, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_nested_state__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1 {} #[test] -fn bindgen_test_layout_kvm_nested_state__bindgen_ty_2() { +fn bindgen_test_layout_kvm_nested_state__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1() { assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 0usize, - concat!("Size of: ", stringify!(kvm_nested_state__bindgen_ty_2)) + concat!( + "Size of: ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(kvm_nested_state__bindgen_ty_2)) + concat!( + "Alignment of ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1) + ) ); +} +#[test] +fn bindgen_test_layout_kvm_nested_state__bindgen_ty_2__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vmx as *const _ as usize - }, + ::std::mem::size_of::(), + 0usize, + concat!( + "Size of: ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__empty_vmx) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_nested_state__bindgen_ty_2), + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_1), "::", - stringify!(vmx) + stringify!(__empty_vmx) ) ); assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).vmx) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(vmx) + ) + ); +} +impl Default for kvm_nested_state__bindgen_ty_2__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).svm as *const _ as usize - }, + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug)] +pub struct kvm_nested_state__bindgen_ty_2__bindgen_ty_2 { + pub __empty_svm: kvm_nested_state__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1, + pub svm: __IncompleteArrayField, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_nested_state__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1 {} +#[test] +fn bindgen_test_layout_kvm_nested_state__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!( + "Size of: ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_2__bindgen_ty_1) + ) + ); +} +#[test] +fn bindgen_test_layout_kvm_nested_state__bindgen_ty_2__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!( + "Size of: ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__empty_svm) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_2), + "::", + stringify!(__empty_svm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).svm) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_nested_state__bindgen_ty_2), + stringify!(kvm_nested_state__bindgen_ty_2__bindgen_ty_2), "::", stringify!(svm) ) ); } +impl Default for kvm_nested_state__bindgen_ty_2__bindgen_ty_2 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[test] +fn bindgen_test_layout_kvm_nested_state__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(kvm_nested_state__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(kvm_nested_state__bindgen_ty_2)) + ); +} impl Default for kvm_nested_state__bindgen_ty_2 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); @@ -4209,8 +4700,15 @@ impl Default for kvm_nested_state__bindgen_ty_2 { } } } +impl ::std::fmt::Debug for kvm_nested_state__bindgen_ty_2 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_nested_state__bindgen_ty_2 {{ union }}") + } +} #[test] fn bindgen_test_layout_kvm_nested_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 128usize, @@ -4222,7 +4720,7 @@ fn bindgen_test_layout_kvm_nested_state() { concat!("Alignment of ", stringify!(kvm_nested_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4232,7 +4730,7 @@ fn bindgen_test_layout_kvm_nested_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).format as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -4242,7 +4740,7 @@ fn bindgen_test_layout_kvm_nested_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -4252,7 +4750,7 @@ fn bindgen_test_layout_kvm_nested_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -4262,7 +4760,7 @@ fn bindgen_test_layout_kvm_nested_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 128usize, concat!( "Offset of field: ", @@ -4281,6 +4779,15 @@ impl Default for kvm_nested_state { } } } +impl ::std::fmt::Debug for kvm_nested_state { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_nested_state {{ flags: {:?}, format: {:?}, size: {:?}, hdr: {:?}, data: {:?} }}", + self.flags, self.format, self.size, self.hdr, self.data + ) + } +} #[repr(C)] #[derive(Debug, Default)] pub struct kvm_pmu_event_filter { @@ -4293,6 +4800,8 @@ pub struct kvm_pmu_event_filter { } #[test] fn bindgen_test_layout_kvm_pmu_event_filter() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -4304,7 +4813,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { concat!("Alignment of ", stringify!(kvm_pmu_event_filter)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).action as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4314,7 +4823,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nevents as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nevents) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -4324,10 +4833,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fixed_counter_bitmap as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).fixed_counter_bitmap) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -4337,7 +4843,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -4347,7 +4853,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -4357,7 +4863,7 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).events as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).events) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -4369,349 +4875,263 @@ fn bindgen_test_layout_kvm_pmu_event_filter() { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_user_trace_setup { - pub buf_size: __u32, - pub buf_nr: __u32, +pub struct kvm_x86_mce { + pub status: __u64, + pub addr: __u64, + pub misc: __u64, + pub mcg_status: __u64, + pub bank: __u8, + pub pad1: [__u8; 7usize], + pub pad2: [__u64; 3usize], } #[test] -fn bindgen_test_layout_kvm_user_trace_setup() { +fn bindgen_test_layout_kvm_x86_mce() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_user_trace_setup)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_x86_mce)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_user_trace_setup)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_x86_mce)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_user_trace_setup), + stringify!(kvm_x86_mce), "::", - stringify!(buf_size) + stringify!(status) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf_nr as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_user_trace_setup), + stringify!(kvm_x86_mce), "::", - stringify!(buf_nr) + stringify!(addr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_breakpoint { - pub enabled: __u32, - pub padding: __u32, - pub address: __u64, -} -#[test] -fn bindgen_test_layout_kvm_breakpoint() { assert_eq!( - ::std::mem::size_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).misc) as usize - ptr as usize }, 16usize, - concat!("Size of: ", stringify!(kvm_breakpoint)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_breakpoint)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, - 0usize, concat!( "Offset of field: ", - stringify!(kvm_breakpoint), + stringify!(kvm_x86_mce), "::", - stringify!(enabled) + stringify!(misc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).mcg_status) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_breakpoint), + stringify!(kvm_x86_mce), "::", - stringify!(padding) + stringify!(mcg_status) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).bank) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_breakpoint), + stringify!(kvm_x86_mce), "::", - stringify!(address) + stringify!(bank) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_debug_guest { - pub enabled: __u32, - pub pad: __u32, - pub breakpoints: [kvm_breakpoint; 4usize], - pub singlestep: __u32, -} -#[test] -fn bindgen_test_layout_kvm_debug_guest() { - assert_eq!( - ::std::mem::size_of::(), - 80usize, - concat!("Size of: ", stringify!(kvm_debug_guest)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_debug_guest)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 33usize, concat!( "Offset of field: ", - stringify!(kvm_debug_guest), + stringify!(kvm_x86_mce), "::", - stringify!(enabled) + stringify!(pad1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_debug_guest), + stringify!(kvm_x86_mce), "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).breakpoints as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_debug_guest), - "::", - stringify!(breakpoints) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).singlestep as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(kvm_debug_guest), - "::", - stringify!(singlestep) + stringify!(pad2) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_memory_region { - pub slot: __u32, +pub struct kvm_xen_hvm_config { pub flags: __u32, - pub guest_phys_addr: __u64, - pub memory_size: __u64, + pub msr: __u32, + pub blob_addr_32: __u64, + pub blob_addr_64: __u64, + pub blob_size_32: __u8, + pub blob_size_64: __u8, + pub pad2: [__u8; 30usize], } #[test] -fn bindgen_test_layout_kvm_memory_region() { +fn bindgen_test_layout_kvm_xen_hvm_config() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_memory_region)) + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(kvm_xen_hvm_config)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_memory_region)) + concat!("Alignment of ", stringify!(kvm_xen_hvm_config)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(slot) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(flags) + stringify!(msr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_phys_addr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).blob_addr_32) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(guest_phys_addr) + stringify!(blob_addr_32) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).memory_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).blob_addr_64) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_memory_region), - "::", - stringify!(memory_size) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_userspace_memory_region { - pub slot: __u32, - pub flags: __u32, - pub guest_phys_addr: __u64, - pub memory_size: __u64, - pub userspace_addr: __u64, -} -#[test] -fn bindgen_test_layout_kvm_userspace_memory_region() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_userspace_memory_region)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_userspace_memory_region)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).slot as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_userspace_memory_region), - "::", - stringify!(slot) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flags as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_userspace_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(flags) + stringify!(blob_addr_64) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_phys_addr as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).blob_size_32) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_userspace_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(guest_phys_addr) + stringify!(blob_size_32) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).memory_size as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).blob_size_64) as usize - ptr as usize }, + 25usize, concat!( "Offset of field: ", - stringify!(kvm_userspace_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(memory_size) + stringify!(blob_size_64) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).userspace_addr as *const _ - as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 26usize, concat!( "Offset of field: ", - stringify!(kvm_userspace_memory_region), + stringify!(kvm_xen_hvm_config), "::", - stringify!(userspace_addr) + stringify!(pad2) ) ); } #[repr(C)] #[derive(Copy, Clone)] -pub struct kvm_irq_level { - pub __bindgen_anon_1: kvm_irq_level__bindgen_ty_1, - pub level: __u32, +pub struct kvm_xen_hvm_attr { + pub type_: __u16, + pub pad: [__u16; 3usize], + pub u: kvm_xen_hvm_attr__bindgen_ty_1, } #[repr(C)] #[derive(Copy, Clone)] -pub union kvm_irq_level__bindgen_ty_1 { - pub irq: __u32, - pub status: __s32, +pub union kvm_xen_hvm_attr__bindgen_ty_1 { + pub long_mode: __u8, + pub vector: __u8, + pub runstate_update_flag: __u8, + pub shared_info: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1, + pub evtchn: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2, + pub xen_version: __u32, + pub pad: [__u64; 8usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1 { + pub gfn: __u64, + pub hva: __u64, } #[test] -fn bindgen_test_layout_kvm_irq_level__bindgen_ty_1() { +fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_irq_level__bindgen_ty_1)) + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_level__bindgen_ty_1)) + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irq as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gfn) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_level__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(irq) + stringify!(gfn) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).status as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hva) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_level__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(status) + stringify!(hva) ) ); } -impl Default for kvm_irq_level__bindgen_ty_1 { +impl Default for kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -4720,150 +5140,200 @@ impl Default for kvm_irq_level__bindgen_ty_1 { } } } -#[test] -fn bindgen_test_layout_kvm_irq_level() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_level)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_level)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).level as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_irq_level), - "::", - stringify!(level) +impl ::std::fmt::Debug for kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1 {{ union }}" ) - ); -} -impl Default for kvm_irq_level { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } } } #[repr(C)] #[derive(Copy, Clone)] -pub struct kvm_irqchip { - pub chip_id: __u32, - pub pad: __u32, - pub chip: kvm_irqchip__bindgen_ty_1, +pub struct kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2 { + pub send_port: __u32, + pub type_: __u32, + pub flags: __u32, + pub deliver: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] #[derive(Copy, Clone)] -pub union kvm_irqchip__bindgen_ty_1 { - pub dummy: [::std::os::raw::c_char; 512usize], - pub pic: kvm_pic_state, - pub ioapic: kvm_ioapic_state, +pub union kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 { + pub port: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, + pub eventfd: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2, + pub padding: [__u32; 4usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1 { + pub port: __u32, + pub vcpu: __u32, + pub priority: __u32, } #[test] -fn bindgen_test_layout_kvm_irqchip__bindgen_ty_1() { +fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, + > = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 512usize, - concat!("Size of: ", stringify!(kvm_irqchip__bindgen_ty_1)) + ::std::mem::size_of::< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, + >(), + 12usize, + concat!( + "Size of: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_irqchip__bindgen_ty_1)) + ::std::mem::align_of::< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1, + >(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dummy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqchip__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(dummy) + stringify!(port) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pic as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_irqchip__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(pic) + stringify!(vcpu) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ioapic as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_irqchip__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(ioapic) + stringify!(priority) ) ); } -impl Default for kvm_irqchip__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2 { + pub port: __u32, + pub fd: __s32, } #[test] -fn bindgen_test_layout_kvm_irqchip() { - assert_eq!( - ::std::mem::size_of::(), - 520usize, - concat!("Size of: ", stringify!(kvm_irqchip)) - ); +fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2, + > = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::size_of::< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2, + >(), 8usize, - concat!("Alignment of ", stringify!(kvm_irqchip)) + concat!( + "Size of: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).chip_id as *const _ as usize }, - 0usize, + ::std::mem::align_of::< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2, + >(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqchip), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(chip_id) + stringify!(port) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_irqchip), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(pad) + stringify!(fd) ) ); +} +#[test] +fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit< + kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1, + > = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).chip as *const _ as usize }, - 8usize, + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqchip), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1), "::", - stringify!(chip) + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).eventfd) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(eventfd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(padding) ) ); } -impl Default for kvm_irqchip { +impl Default for kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -4872,185 +5342,177 @@ impl Default for kvm_irqchip { } } } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_pit_config { - pub flags: __u32, - pub pad: [__u32; 15usize], +impl ::std::fmt::Debug for kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 {{ union }}" + ) + } } #[test] -fn bindgen_test_layout_kvm_pit_config() { +fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_pit_config)) + ::std::mem::size_of::(), + 28usize, + concat!( + "Size of: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_pit_config)) + concat!( + "Alignment of ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).send_port) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_pit_config), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(flags) + stringify!(send_port) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_pit_config), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(pad) + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).deliver) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(deliver) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_skeys { - pub start_gfn: __u64, - pub count: __u64, - pub skeydata_addr: __u64, - pub flags: __u32, - pub reserved: [__u32; 9usize], +impl Default for kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_2 {{ send_port: {:?}, type: {:?}, flags: {:?}, deliver: {:?} }}" , self . send_port , self . type_ , self . flags , self . deliver) + } } #[test] -fn bindgen_test_layout_kvm_s390_skeys() { +fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 64usize, - concat!("Size of: ", stringify!(kvm_s390_skeys)) + concat!("Size of: ", stringify!(kvm_xen_hvm_attr__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_skeys)) + concat!("Alignment of ", stringify!(kvm_xen_hvm_attr__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).start_gfn as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).long_mode) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(start_gfn) + stringify!(long_mode) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(count) + stringify!(vector) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).skeydata_addr as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).runstate_update_flag) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(skeydata_addr) + stringify!(runstate_update_flag) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).shared_info) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(flags) + stringify!(shared_info) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 28usize, + unsafe { ::std::ptr::addr_of!((*ptr).evtchn) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_skeys), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(reserved) + stringify!(evtchn) ) ); -} -#[doc = " kvm_s390_cmma_log - Used for CMMA migration."] -#[doc = ""] -#[doc = " Used both for input and output."] -#[doc = ""] -#[doc = " @start_gfn: Guest page number to start from."] -#[doc = " @count: Size of the result buffer."] -#[doc = " @flags: Control operation mode via KVM_S390_CMMA_* flags"] -#[doc = " @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty"] -#[doc = " pages are still remaining."] -#[doc = " @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set"] -#[doc = " in the PGSTE."] -#[doc = " @values: Pointer to the values buffer."] -#[doc = ""] -#[doc = " Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls."] -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_s390_cmma_log { - pub start_gfn: __u64, - pub count: __u32, - pub flags: __u32, - pub __bindgen_anon_1: kvm_s390_cmma_log__bindgen_ty_1, - pub values: __u64, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_s390_cmma_log__bindgen_ty_1 { - pub remaining: __u64, - pub mask: __u64, -} -#[test] -fn bindgen_test_layout_kvm_s390_cmma_log__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_s390_cmma_log__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_cmma_log__bindgen_ty_1)) - ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).remaining as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).xen_version) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(remaining) + stringify!(xen_version) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mask as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log__bindgen_ty_1), + stringify!(kvm_xen_hvm_attr__bindgen_ty_1), "::", - stringify!(mask) + stringify!(pad) ) ); } -impl Default for kvm_s390_cmma_log__bindgen_ty_1 { +impl Default for kvm_xen_hvm_attr__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -5059,60 +5521,57 @@ impl Default for kvm_s390_cmma_log__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_xen_hvm_attr__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_xen_hvm_attr__bindgen_ty_1 {{ union }}") + } +} #[test] -fn bindgen_test_layout_kvm_s390_cmma_log() { +fn bindgen_test_layout_kvm_xen_hvm_attr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_s390_cmma_log)) + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_xen_hvm_attr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_cmma_log)) + concat!("Alignment of ", stringify!(kvm_xen_hvm_attr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).start_gfn as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log), - "::", - stringify!(start_gfn) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).count as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_cmma_log), + stringify!(kvm_xen_hvm_attr), "::", - stringify!(count) + stringify!(type_) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log), + stringify!(kvm_xen_hvm_attr), "::", - stringify!(flags) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).values as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_cmma_log), + stringify!(kvm_xen_hvm_attr), "::", - stringify!(values) + stringify!(u) ) ); } -impl Default for kvm_s390_cmma_log { +impl Default for kvm_xen_hvm_attr { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -5121,349 +5580,330 @@ impl Default for kvm_s390_cmma_log { } } } +impl ::std::fmt::Debug for kvm_xen_hvm_attr { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_hvm_attr {{ type: {:?}, pad: {:?}, u: {:?} }}", + self.type_, self.pad, self.u + ) + } +} #[repr(C)] #[derive(Copy, Clone)] -pub struct kvm_hyperv_exit { - pub type_: __u32, - pub pad1: __u32, - pub u: kvm_hyperv_exit__bindgen_ty_1, +pub struct kvm_xen_vcpu_attr { + pub type_: __u16, + pub pad: [__u16; 3usize], + pub u: kvm_xen_vcpu_attr__bindgen_ty_1, } #[repr(C)] #[derive(Copy, Clone)] -pub union kvm_hyperv_exit__bindgen_ty_1 { - pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, - pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, - pub syndbg: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3, +pub union kvm_xen_vcpu_attr__bindgen_ty_1 { + pub gpa: __u64, + pub hva: __u64, + pub pad: [__u64; 8usize], + pub runstate: kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1, + pub vcpu_id: __u32, + pub timer: kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2, + pub vector: __u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { - pub msr: __u32, - pub pad2: __u32, - pub control: __u64, - pub evt_page: __u64, - pub msg_page: __u64, +pub struct kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1 { + pub state: __u64, + pub state_entry_time: __u64, + pub time_running: __u64, + pub time_runnable: __u64, + pub time_blocked: __u64, + pub time_offline: __u64, } #[test] -fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, + ::std::mem::size_of::(), + 48usize, concat!( "Size of: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, concat!( "Alignment of ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(msr) + stringify!(state) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad2 as *const _ - as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).state_entry_time) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(pad2) + stringify!(state_entry_time) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).control - as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).time_running) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(control) + stringify!(time_running) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).evt_page - as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).time_runnable) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(evt_page) + stringify!(time_runnable) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msg_page - as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).time_blocked) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(msg_page) + stringify!(time_blocked) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).time_offline) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(time_offline) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { - pub input: __u64, - pub result: __u64, - pub params: [__u64; 2usize], +pub struct kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2 { + pub port: __u32, + pub priority: __u32, + pub expires_ns: __u64, } #[test] -fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { +fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, + ::std::mem::size_of::(), + 16usize, concat!( "Size of: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2) ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, concat!( "Alignment of ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(input) + stringify!(port) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).result - as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(result) + stringify!(priority) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).params - as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).expires_ns) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(params) + stringify!(expires_ns) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3 { - pub msr: __u32, - pub pad2: __u32, - pub control: __u64, - pub status: __u64, - pub send_page: __u64, - pub recv_page: __u64, - pub pending_page: __u64, -} #[test] -fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { +fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!( - "Size of: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3) - ) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_xen_vcpu_attr__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3) - ) + concat!("Alignment of ", stringify!(kvm_xen_vcpu_attr__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).gpa) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(msr) + stringify!(gpa) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad2 as *const _ - as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).hva) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(pad2) + stringify!(hva) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).control - as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(control) + stringify!(pad) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).status - as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).runstate) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(status) + stringify!(runstate) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).send_page - as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).vcpu_id) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(send_page) + stringify!(vcpu_id) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).recv_page - as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).timer) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(recv_page) + stringify!(timer) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pending_page - as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), "::", - stringify!(pending_page) + stringify!(vector) ) ); } +impl Default for kvm_xen_vcpu_attr__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_xen_vcpu_attr__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_xen_vcpu_attr__bindgen_ty_1 {{ union }}") + } +} #[test] -fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { +fn bindgen_test_layout_kvm_xen_vcpu_attr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_xen_vcpu_attr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + concat!("Alignment of ", stringify!(kvm_xen_vcpu_attr)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).synic as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr), "::", - stringify!(synic) + stringify!(type_) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hcall as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr), "::", - stringify!(hcall) + stringify!(pad) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).syndbg as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit__bindgen_ty_1), + stringify!(kvm_xen_vcpu_attr), "::", - stringify!(syndbg) + stringify!(u) ) ); } -impl Default for kvm_hyperv_exit__bindgen_ty_1 { +impl Default for kvm_xen_vcpu_attr { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -5472,1860 +5912,1570 @@ impl Default for kvm_hyperv_exit__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_xen_vcpu_attr { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_vcpu_attr {{ type: {:?}, pad: {:?}, u: {:?} }}", + self.type_, self.pad, self.u + ) + } +} +pub const sev_cmd_id_KVM_SEV_INIT: sev_cmd_id = 0; +pub const sev_cmd_id_KVM_SEV_ES_INIT: sev_cmd_id = 1; +pub const sev_cmd_id_KVM_SEV_LAUNCH_START: sev_cmd_id = 2; +pub const sev_cmd_id_KVM_SEV_LAUNCH_UPDATE_DATA: sev_cmd_id = 3; +pub const sev_cmd_id_KVM_SEV_LAUNCH_UPDATE_VMSA: sev_cmd_id = 4; +pub const sev_cmd_id_KVM_SEV_LAUNCH_SECRET: sev_cmd_id = 5; +pub const sev_cmd_id_KVM_SEV_LAUNCH_MEASURE: sev_cmd_id = 6; +pub const sev_cmd_id_KVM_SEV_LAUNCH_FINISH: sev_cmd_id = 7; +pub const sev_cmd_id_KVM_SEV_SEND_START: sev_cmd_id = 8; +pub const sev_cmd_id_KVM_SEV_SEND_UPDATE_DATA: sev_cmd_id = 9; +pub const sev_cmd_id_KVM_SEV_SEND_UPDATE_VMSA: sev_cmd_id = 10; +pub const sev_cmd_id_KVM_SEV_SEND_FINISH: sev_cmd_id = 11; +pub const sev_cmd_id_KVM_SEV_RECEIVE_START: sev_cmd_id = 12; +pub const sev_cmd_id_KVM_SEV_RECEIVE_UPDATE_DATA: sev_cmd_id = 13; +pub const sev_cmd_id_KVM_SEV_RECEIVE_UPDATE_VMSA: sev_cmd_id = 14; +pub const sev_cmd_id_KVM_SEV_RECEIVE_FINISH: sev_cmd_id = 15; +pub const sev_cmd_id_KVM_SEV_GUEST_STATUS: sev_cmd_id = 16; +pub const sev_cmd_id_KVM_SEV_DBG_DECRYPT: sev_cmd_id = 17; +pub const sev_cmd_id_KVM_SEV_DBG_ENCRYPT: sev_cmd_id = 18; +pub const sev_cmd_id_KVM_SEV_CERT_EXPORT: sev_cmd_id = 19; +pub const sev_cmd_id_KVM_SEV_GET_ATTESTATION_REPORT: sev_cmd_id = 20; +pub const sev_cmd_id_KVM_SEV_SEND_CANCEL: sev_cmd_id = 21; +pub const sev_cmd_id_KVM_SEV_NR_MAX: sev_cmd_id = 22; +pub type sev_cmd_id = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_sev_cmd { + pub id: __u32, + pub pad0: __u32, + pub data: __u64, + pub error: __u32, + pub sev_fd: __u32, +} #[test] -fn bindgen_test_layout_kvm_hyperv_exit() { +fn bindgen_test_layout_kvm_sev_cmd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 56usize, - concat!("Size of: ", stringify!(kvm_hyperv_exit)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_sev_cmd)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_hyperv_exit)) + concat!("Alignment of ", stringify!(kvm_sev_cmd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit), + stringify!(kvm_sev_cmd), "::", - stringify!(type_) + stringify!(id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad1 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit), + stringify!(kvm_sev_cmd), "::", - stringify!(pad1) + stringify!(pad0) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_exit), + stringify!(kvm_sev_cmd), "::", - stringify!(u) + stringify!(data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).error) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_cmd), + "::", + stringify!(error) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sev_fd) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_cmd), + "::", + stringify!(sev_fd) ) ); -} -impl Default for kvm_hyperv_exit { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_xen_exit { - pub type_: __u32, - pub u: kvm_xen_exit__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_xen_exit__bindgen_ty_1 { - pub hcall: kvm_xen_exit__bindgen_ty_1__bindgen_ty_1, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_xen_exit__bindgen_ty_1__bindgen_ty_1 { - pub longmode: __u32, - pub cpl: __u32, - pub input: __u64, - pub result: __u64, - pub params: [__u64; 6usize], +pub struct kvm_sev_launch_start { + pub handle: __u32, + pub policy: __u32, + pub dh_uaddr: __u64, + pub dh_len: __u32, + pub pad0: __u32, + pub session_uaddr: __u64, + pub session_len: __u32, + pub pad1: __u32, } #[test] -fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_sev_launch_start() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!( - "Size of: ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1) - ) + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(kvm_sev_launch_start)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1) - ) + concat!("Alignment of ", stringify!(kvm_sev_launch_start)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).longmode - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).handle) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_sev_launch_start), "::", - stringify!(longmode) + stringify!(handle) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).cpl as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).policy) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_sev_launch_start), "::", - stringify!(cpl) + stringify!(policy) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).input as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dh_uaddr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_sev_launch_start), "::", - stringify!(input) + stringify!(dh_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).result as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dh_len) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_sev_launch_start), "::", - stringify!(result) + stringify!(dh_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).params as *const _ - as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_sev_launch_start), "::", - stringify!(params) + stringify!(pad0) ) ); -} -#[test] -fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1() { assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_xen_exit__bindgen_ty_1)) + unsafe { ::std::ptr::addr_of!((*ptr).session_uaddr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_launch_start), + "::", + stringify!(session_uaddr) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_exit__bindgen_ty_1)) + unsafe { ::std::ptr::addr_of!((*ptr).session_len) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_launch_start), + "::", + stringify!(session_len) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hcall as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 36usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit__bindgen_ty_1), + stringify!(kvm_sev_launch_start), "::", - stringify!(hcall) + stringify!(pad1) ) ); } -impl Default for kvm_xen_exit__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_sev_launch_update_data { + pub uaddr: __u64, + pub len: __u32, + pub pad0: __u32, } #[test] -fn bindgen_test_layout_kvm_xen_exit() { +fn bindgen_test_layout_kvm_sev_launch_update_data() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 80usize, - concat!("Size of: ", stringify!(kvm_xen_exit)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_sev_launch_update_data)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_xen_exit)) + concat!("Alignment of ", stringify!(kvm_sev_launch_update_data)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).uaddr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit), + stringify!(kvm_sev_launch_update_data), "::", - stringify!(type_) + stringify!(uaddr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_exit), + stringify!(kvm_sev_launch_update_data), "::", - stringify!(u) + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_launch_update_data), + "::", + stringify!(pad0) ) ); -} -impl Default for kvm_xen_exit { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_run { - pub request_interrupt_window: __u8, - pub immediate_exit: __u8, - pub padding1: [__u8; 6usize], - pub exit_reason: __u32, - pub ready_for_interrupt_injection: __u8, - pub if_flag: __u8, - pub flags: __u16, - pub cr8: __u64, - pub apic_base: __u64, - pub __bindgen_anon_1: kvm_run__bindgen_ty_1, - pub kvm_valid_regs: __u64, - pub kvm_dirty_regs: __u64, - pub s: kvm_run__bindgen_ty_2, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_run__bindgen_ty_1 { - pub hw: kvm_run__bindgen_ty_1__bindgen_ty_1, - pub fail_entry: kvm_run__bindgen_ty_1__bindgen_ty_2, - pub ex: kvm_run__bindgen_ty_1__bindgen_ty_3, - pub io: kvm_run__bindgen_ty_1__bindgen_ty_4, - pub debug: kvm_run__bindgen_ty_1__bindgen_ty_5, - pub mmio: kvm_run__bindgen_ty_1__bindgen_ty_6, - pub hypercall: kvm_run__bindgen_ty_1__bindgen_ty_7, - pub tpr_access: kvm_run__bindgen_ty_1__bindgen_ty_8, - pub s390_sieic: kvm_run__bindgen_ty_1__bindgen_ty_9, - pub s390_reset_flags: __u64, - pub s390_ucontrol: kvm_run__bindgen_ty_1__bindgen_ty_10, - pub dcr: kvm_run__bindgen_ty_1__bindgen_ty_11, - pub internal: kvm_run__bindgen_ty_1__bindgen_ty_12, - pub osi: kvm_run__bindgen_ty_1__bindgen_ty_13, - pub papr_hcall: kvm_run__bindgen_ty_1__bindgen_ty_14, - pub s390_tsch: kvm_run__bindgen_ty_1__bindgen_ty_15, - pub epr: kvm_run__bindgen_ty_1__bindgen_ty_16, - pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_17, - pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_18, - pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_19, - pub hyperv: kvm_hyperv_exit, - pub arm_nisv: kvm_run__bindgen_ty_1__bindgen_ty_20, - pub msr: kvm_run__bindgen_ty_1__bindgen_ty_21, - pub xen: kvm_xen_exit, - pub padding: [::std::os::raw::c_char; 256usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_1 { - pub hardware_exit_reason: __u64, +pub struct kvm_sev_launch_secret { + pub hdr_uaddr: __u64, + pub hdr_len: __u32, + pub pad0: __u32, + pub guest_uaddr: __u64, + pub guest_len: __u32, + pub pad1: __u32, + pub trans_uaddr: __u64, + pub trans_len: __u32, + pub pad2: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_sev_launch_secret() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_sev_launch_secret)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1) - ) + concat!("Alignment of ", stringify!(kvm_sev_launch_secret)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hardware_exit_reason - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hdr_uaddr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_sev_launch_secret), "::", - stringify!(hardware_exit_reason) + stringify!(hdr_uaddr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_2 { - pub hardware_entry_failure_reason: __u64, - pub cpu: __u32, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_2() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2)) - ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).hdr_len) as usize - ptr as usize }, 8usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2) + "Offset of field: ", + stringify!(kvm_sev_launch_secret), + "::", + stringify!(hdr_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())) - .hardware_entry_failure_reason as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2), + stringify!(kvm_sev_launch_secret), "::", - stringify!(hardware_entry_failure_reason) + stringify!(pad0) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).cpu as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).guest_uaddr) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2), + stringify!(kvm_sev_launch_secret), "::", - stringify!(cpu) + stringify!(guest_uaddr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_3 { - pub exception: __u32, - pub error_code: __u32, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_3() { assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3)) + unsafe { ::std::ptr::addr_of!((*ptr).guest_len) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_launch_secret), + "::", + stringify!(guest_len) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 28usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3) + "Offset of field: ", + stringify!(kvm_sev_launch_secret), + "::", + stringify!(pad1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).exception as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_uaddr) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_sev_launch_secret), "::", - stringify!(exception) + stringify!(trans_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).error_code as *const _ - as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_len) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3), + stringify!(kvm_sev_launch_secret), "::", - stringify!(error_code) + stringify!(trans_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_launch_secret), + "::", + stringify!(pad2) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_4 { - pub direction: __u8, - pub size: __u8, - pub port: __u16, - pub count: __u32, - pub data_offset: __u64, +pub struct kvm_sev_launch_measure { + pub uaddr: __u64, + pub len: __u32, + pub pad0: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { +fn bindgen_test_layout_kvm_sev_launch_measure() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4)) + concat!("Size of: ", stringify!(kvm_sev_launch_measure)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4) - ) + concat!("Alignment of ", stringify!(kvm_sev_launch_measure)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).direction as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).uaddr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + stringify!(kvm_sev_launch_measure), "::", - stringify!(direction) + stringify!(uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).size as *const _ - as usize - }, - 1usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + stringify!(kvm_sev_launch_measure), "::", - stringify!(size) + stringify!(len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).port as *const _ - as usize - }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + stringify!(kvm_sev_launch_measure), "::", - stringify!(port) + stringify!(pad0) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_sev_guest_status { + pub handle: __u32, + pub policy: __u32, + pub state: __u32, +} +#[test] +fn bindgen_test_layout_kvm_sev_guest_status() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_sev_guest_status)) + ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).count as *const _ - as usize - }, + ::std::mem::align_of::(), 4usize, + concat!("Alignment of ", stringify!(kvm_sev_guest_status)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).handle) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + stringify!(kvm_sev_guest_status), "::", - stringify!(count) + stringify!(handle) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data_offset as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).policy) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + stringify!(kvm_sev_guest_status), "::", - stringify!(data_offset) + stringify!(policy) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_5 { - pub arch: kvm_debug_exit_arch, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_5() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5)) - ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).arch as *const _ - as usize - }, - 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5), + stringify!(kvm_sev_guest_status), "::", - stringify!(arch) + stringify!(state) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_6 { - pub phys_addr: __u64, - pub data: [__u8; 8usize], +pub struct kvm_sev_dbg { + pub src_uaddr: __u64, + pub dst_uaddr: __u64, pub len: __u32, - pub is_write: __u8, + pub pad0: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { +fn bindgen_test_layout_kvm_sev_dbg() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 24usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6)) + concat!("Size of: ", stringify!(kvm_sev_dbg)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6) - ) + concat!("Alignment of ", stringify!(kvm_sev_dbg)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).phys_addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).src_uaddr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + stringify!(kvm_sev_dbg), "::", - stringify!(phys_addr) + stringify!(src_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dst_uaddr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + stringify!(kvm_sev_dbg), "::", - stringify!(data) + stringify!(dst_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).len as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + stringify!(kvm_sev_dbg), "::", stringify!(len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).is_write as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), + stringify!(kvm_sev_dbg), "::", - stringify!(is_write) + stringify!(pad0) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_7 { - pub nr: __u64, - pub args: [__u64; 6usize], - pub ret: __u64, - pub longmode: __u32, - pub pad: __u32, +pub struct kvm_sev_attestation_report { + pub mnonce: [__u8; 16usize], + pub uaddr: __u64, + pub len: __u32, + pub pad0: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_7() { +fn bindgen_test_layout_kvm_sev_attestation_report() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_sev_attestation_report)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7) - ) + concat!("Alignment of ", stringify!(kvm_sev_attestation_report)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).mnonce) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + stringify!(kvm_sev_attestation_report), "::", - stringify!(nr) + stringify!(mnonce) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).args as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).uaddr) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + stringify!(kvm_sev_attestation_report), "::", - stringify!(args) + stringify!(uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ret as *const _ as usize - }, - 56usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + stringify!(kvm_sev_attestation_report), "::", - stringify!(ret) + stringify!(len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).longmode as *const _ - as usize - }, - 64usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 28usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + stringify!(kvm_sev_attestation_report), "::", - stringify!(longmode) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), - "::", - stringify!(pad) + stringify!(pad0) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_8 { - pub rip: __u64, - pub is_write: __u32, - pub pad: __u32, +pub struct kvm_sev_send_start { + pub policy: __u32, + pub pad0: __u32, + pub pdh_cert_uaddr: __u64, + pub pdh_cert_len: __u32, + pub pad1: __u32, + pub plat_certs_uaddr: __u64, + pub plat_certs_len: __u32, + pub pad2: __u32, + pub amd_certs_uaddr: __u64, + pub amd_certs_len: __u32, + pub pad3: __u32, + pub session_uaddr: __u64, + pub session_len: __u32, + pub pad4: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8() { +fn bindgen_test_layout_kvm_sev_send_start() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8)) + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_sev_send_start)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8) - ) + concat!("Alignment of ", stringify!(kvm_sev_send_start)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rip as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).policy) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + stringify!(kvm_sev_send_start), "::", - stringify!(rip) + stringify!(policy) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).is_write as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + stringify!(kvm_sev_send_start), "::", - stringify!(is_write) + stringify!(pad0) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).pdh_cert_uaddr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + stringify!(kvm_sev_send_start), "::", - stringify!(pad) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_9 { - pub icptcode: __u8, - pub ipa: __u16, - pub ipb: __u32, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_9() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9) + stringify!(pdh_cert_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).icptcode as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pdh_cert_len) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), + stringify!(kvm_sev_send_start), "::", - stringify!(icptcode) + stringify!(pdh_cert_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipa as *const _ as usize - }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), + stringify!(kvm_sev_send_start), "::", - stringify!(ipa) + stringify!(pad1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipb as *const _ as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).plat_certs_uaddr) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), + stringify!(kvm_sev_send_start), "::", - stringify!(ipb) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_10 { - pub trans_exc_code: __u64, - pub pgm_code: __u32, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_10() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) + stringify!(plat_certs_uaddr) ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).plat_certs_len) as usize - ptr as usize }, + 32usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) + "Offset of field: ", + stringify!(kvm_sev_send_start), + "::", + stringify!(plat_certs_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_exc_code - as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 36usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), + stringify!(kvm_sev_send_start), "::", - stringify!(trans_exc_code) + stringify!(pad2) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pgm_code as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).amd_certs_uaddr) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), + stringify!(kvm_sev_send_start), "::", - stringify!(pgm_code) + stringify!(amd_certs_uaddr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_11 { - pub dcrn: __u32, - pub data: __u32, - pub is_write: __u8, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_11() { assert_eq!( - ::std::mem::size_of::(), - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).amd_certs_len) as usize - ptr as usize }, + 48usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) + "Offset of field: ", + stringify!(kvm_sev_send_start), + "::", + stringify!(amd_certs_len) ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad3) as usize - ptr as usize }, + 52usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) + "Offset of field: ", + stringify!(kvm_sev_send_start), + "::", + stringify!(pad3) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dcrn as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).session_uaddr) as usize - ptr as usize }, + 56usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), + stringify!(kvm_sev_send_start), "::", - stringify!(dcrn) + stringify!(session_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).session_len) as usize - ptr as usize }, + 64usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), + stringify!(kvm_sev_send_start), "::", - stringify!(data) + stringify!(session_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).is_write as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad4) as usize - ptr as usize }, + 68usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), + stringify!(kvm_sev_send_start), "::", - stringify!(is_write) + stringify!(pad4) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_12 { - pub suberror: __u32, - pub ndata: __u32, - pub data: [__u64; 16usize], +pub struct kvm_sev_send_update_data { + pub hdr_uaddr: __u64, + pub hdr_len: __u32, + pub pad0: __u32, + pub guest_uaddr: __u64, + pub guest_len: __u32, + pub pad1: __u32, + pub trans_uaddr: __u64, + pub trans_len: __u32, + pub pad2: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_12() { +fn bindgen_test_layout_kvm_sev_send_update_data() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 136usize, + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_sev_send_update_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_sev_send_update_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr_uaddr) as usize - ptr as usize }, + 0usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) + "Offset of field: ", + stringify!(kvm_sev_send_update_data), + "::", + stringify!(hdr_uaddr) ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).hdr_len) as usize - ptr as usize }, 8usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) + "Offset of field: ", + stringify!(kvm_sev_send_update_data), + "::", + stringify!(hdr_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).suberror as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), + stringify!(kvm_sev_send_update_data), "::", - stringify!(suberror) + stringify!(pad0) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ndata as *const _ - as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).guest_uaddr) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), + stringify!(kvm_sev_send_update_data), "::", - stringify!(ndata) + stringify!(guest_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).guest_len) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), + stringify!(kvm_sev_send_update_data), "::", - stringify!(data) + stringify!(guest_len) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_13 { - pub gprs: [__u64; 32usize], -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_13() { assert_eq!( - ::std::mem::size_of::(), - 256usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 28usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) + "Offset of field: ", + stringify!(kvm_sev_send_update_data), + "::", + stringify!(pad1) ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_uaddr) as usize - ptr as usize }, + 32usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) + "Offset of field: ", + stringify!(kvm_sev_send_update_data), + "::", + stringify!(trans_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gprs as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_len) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), + stringify!(kvm_sev_send_update_data), "::", - stringify!(gprs) + stringify!(trans_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(kvm_sev_send_update_data), + "::", + stringify!(pad2) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_14 { - pub nr: __u64, - pub ret: __u64, - pub args: [__u64; 9usize], +pub struct kvm_sev_receive_start { + pub handle: __u32, + pub policy: __u32, + pub pdh_uaddr: __u64, + pub pdh_len: __u32, + pub pad0: __u32, + pub session_uaddr: __u64, + pub session_len: __u32, + pub pad1: __u32, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14() { +fn bindgen_test_layout_kvm_sev_receive_start() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 88usize, - concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) - ) + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(kvm_sev_receive_start)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, + concat!("Alignment of ", stringify!(kvm_sev_receive_start)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).handle) as usize - ptr as usize }, + 0usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + "Offset of field: ", + stringify!(kvm_sev_receive_start), + "::", + stringify!(handle) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).nr as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).policy) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + stringify!(kvm_sev_receive_start), "::", - stringify!(nr) + stringify!(policy) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ret as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pdh_uaddr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + stringify!(kvm_sev_receive_start), "::", - stringify!(ret) + stringify!(pdh_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).args as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pdh_len) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), + stringify!(kvm_sev_receive_start), "::", - stringify!(args) + stringify!(pdh_len) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_15 { - pub subchannel_id: __u16, - pub subchannel_nr: __u16, - pub io_int_parm: __u32, - pub io_int_word: __u32, - pub ipb: __u32, - pub dequeued: __u8, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_15() { assert_eq!( - ::std::mem::size_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, 20usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + "Offset of field: ", + stringify!(kvm_sev_receive_start), + "::", + stringify!(pad0) ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).session_uaddr) as usize - ptr as usize }, + 24usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + "Offset of field: ", + stringify!(kvm_sev_receive_start), + "::", + stringify!(session_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).subchannel_id - as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).session_len) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_sev_receive_start), "::", - stringify!(subchannel_id) + stringify!(session_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).subchannel_nr - as *const _ as usize - }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 36usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_sev_receive_start), "::", - stringify!(subchannel_nr) + stringify!(pad1) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_sev_receive_update_data { + pub hdr_uaddr: __u64, + pub hdr_len: __u32, + pub pad0: __u32, + pub guest_uaddr: __u64, + pub guest_len: __u32, + pub pad1: __u32, + pub trans_uaddr: __u64, + pub trans_len: __u32, + pub pad2: __u32, +} +#[test] +fn bindgen_test_layout_kvm_sev_receive_update_data() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).io_int_parm as *const _ - as usize - }, - 4usize, + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_sev_receive_update_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_sev_receive_update_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hdr_uaddr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_sev_receive_update_data), "::", - stringify!(io_int_parm) + stringify!(hdr_uaddr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).io_int_word as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hdr_len) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_sev_receive_update_data), "::", - stringify!(io_int_word) + stringify!(hdr_len) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ipb as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_sev_receive_update_data), "::", - stringify!(ipb) + stringify!(pad0) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dequeued as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).guest_uaddr) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), + stringify!(kvm_sev_receive_update_data), "::", - stringify!(dequeued) + stringify!(guest_uaddr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_16 { - pub epr: __u32, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_16() { assert_eq!( - ::std::mem::size_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).guest_len) as usize - ptr as usize }, + 24usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) + "Offset of field: ", + stringify!(kvm_sev_receive_update_data), + "::", + stringify!(guest_len) ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 28usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) + "Offset of field: ", + stringify!(kvm_sev_receive_update_data), + "::", + stringify!(pad1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).epr as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_uaddr) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), + stringify!(kvm_sev_receive_update_data), "::", - stringify!(epr) + stringify!(trans_uaddr) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_17 { - pub type_: __u32, - pub flags: __u64, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_17() { assert_eq!( - ::std::mem::size_of::(), - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_len) as usize - ptr as usize }, + 40usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) + "Offset of field: ", + stringify!(kvm_sev_receive_update_data), + "::", + stringify!(trans_len) ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 44usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_ as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).flags as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), - "::", - stringify!(flags) + "Offset of field: ", + stringify!(kvm_sev_receive_update_data), + "::", + stringify!(pad2) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_18 { - pub addr: __u64, - pub ar: __u8, - pub reserved: __u8, - pub fc: __u8, - pub sel1: __u8, - pub sel2: __u16, +pub struct kvm_hyperv_eventfd { + pub conn_id: __u32, + pub fd: __s32, + pub flags: __u32, + pub padding: [__u32; 3usize], } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_18() { +fn bindgen_test_layout_kvm_hyperv_eventfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) - ) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_hyperv_eventfd)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_hyperv_eventfd)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).conn_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ar as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), - "::", - stringify!(ar) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ - as usize - }, - 9usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_hyperv_eventfd), "::", - stringify!(reserved) + stringify!(conn_id) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fc as *const _ as usize - }, - 10usize, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_hyperv_eventfd), "::", - stringify!(fc) + stringify!(fd) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sel1 as *const _ - as usize - }, - 11usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_hyperv_eventfd), "::", - stringify!(sel1) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).sel2 as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), + stringify!(kvm_hyperv_eventfd), "::", - stringify!(sel2) + stringify!(padding) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_19 { - pub vector: __u8, +pub struct kvm_userspace_memory_region { + pub slot: __u32, + pub flags: __u32, + pub guest_phys_addr: __u64, + pub memory_size: __u64, + pub userspace_addr: __u64, } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { +fn bindgen_test_layout_kvm_userspace_memory_region() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) - ) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_userspace_memory_region)) ); assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) - ) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_userspace_memory_region)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vector as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), + stringify!(kvm_userspace_memory_region), "::", - stringify!(vector) + stringify!(slot) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_20 { - pub esr_iss: __u64, - pub fault_ipa: __u64, -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_20() { assert_eq!( - ::std::mem::size_of::(), - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(flags) ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).guest_phys_addr) as usize - ptr as usize }, 8usize, concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + "Offset of field: ", + stringify!(kvm_userspace_memory_region), + "::", + stringify!(guest_phys_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).esr_iss as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + stringify!(kvm_userspace_memory_region), "::", - stringify!(esr_iss) + stringify!(memory_size) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fault_ipa as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), + stringify!(kvm_userspace_memory_region), "::", - stringify!(fault_ipa) + stringify!(userspace_addr) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_run__bindgen_ty_1__bindgen_ty_21 { - pub error: __u8, - pub pad: [__u8; 7usize], - pub reason: __u32, - pub index: __u32, - pub data: __u64, +pub struct kvm_userspace_memory_region2 { + pub slot: __u32, + pub flags: __u32, + pub guest_phys_addr: __u64, + pub memory_size: __u64, + pub userspace_addr: __u64, + pub guest_memfd_offset: __u64, + pub guest_memfd: __u32, + pub pad1: __u32, + pub pad2: [__u64; 14usize], } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_21() { +fn bindgen_test_layout_kvm_userspace_memory_region2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!( - "Size of: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) - ) + ::std::mem::size_of::(), + 160usize, + concat!("Size of: ", stringify!(kvm_userspace_memory_region2)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) - ) + concat!("Alignment of ", stringify!(kvm_userspace_memory_region2)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).error as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(error) + stringify!(slot) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ - as usize - }, - 1usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(pad) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reason as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).guest_phys_addr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(reason) + stringify!(guest_phys_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).index as *const _ - as usize - }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(index) + stringify!(memory_size) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).data as *const _ - as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(data) + stringify!(userspace_addr) ) ); -} -#[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 256usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_1)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hw as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).guest_memfd_offset) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(hw) + stringify!(guest_memfd_offset) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).fail_entry as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).guest_memfd) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(fail_entry) + stringify!(guest_memfd) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ex as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, + 44usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(ex) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).io as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(io) + stringify!(pad1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).debug as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 48usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_userspace_memory_region2), "::", - stringify!(debug) + stringify!(pad2) ) ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_level { + pub __bindgen_anon_1: kvm_irq_level__bindgen_ty_1, + pub level: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_level__bindgen_ty_1 { + pub irq: __u32, + pub status: __s32, +} +#[test] +fn bindgen_test_layout_kvm_irq_level__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mmio as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(mmio) - ) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_irq_level__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hypercall as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(hypercall) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_level__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tpr_access as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(tpr_access) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).s390_sieic as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_irq_level__bindgen_ty_1), "::", - stringify!(s390_sieic) + stringify!(irq) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).s390_reset_flags as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_irq_level__bindgen_ty_1), "::", - stringify!(s390_reset_flags) + stringify!(status) ) ); - assert_eq!( +} +impl Default for kvm_irq_level__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).s390_ucontrol as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(s390_ucontrol) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dcr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(dcr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).internal as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(internal) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).osi as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(osi) - ) - ); + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_level__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_level__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_irq_level() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).papr_hcall as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(papr_hcall) - ) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_level)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).s390_tsch as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(s390_tsch) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_level)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).epr as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).level) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_irq_level), "::", - stringify!(epr) + stringify!(level) ) ); - assert_eq!( +} +impl Default for kvm_irq_level { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).system_event as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(system_event) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).s390_stsi as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(s390_stsi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).eoi as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(eoi) + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_level { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_level {{ __bindgen_anon_1: {:?}, level: {:?} }}", + self.__bindgen_anon_1, self.level ) - ); + } +} +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_irqchip { + pub chip_id: __u32, + pub pad: __u32, + pub chip: kvm_irqchip__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irqchip__bindgen_ty_1 { + pub dummy: [::std::os::raw::c_char; 512usize], + pub pic: kvm_pic_state, + pub ioapic: kvm_ioapic_state, +} +#[test] +fn bindgen_test_layout_kvm_irqchip__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hyperv as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(hyperv) - ) + ::std::mem::size_of::(), + 512usize, + concat!("Size of: ", stringify!(kvm_irqchip__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).arm_nisv as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), - "::", - stringify!(arm_nisv) - ) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_irqchip__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).msr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dummy) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_irqchip__bindgen_ty_1), "::", - stringify!(msr) + stringify!(dummy) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xen as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pic) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_irqchip__bindgen_ty_1), "::", - stringify!(xen) + stringify!(pic) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ioapic) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_1), + stringify!(kvm_irqchip__bindgen_ty_1), "::", - stringify!(padding) + stringify!(ioapic) ) ); } -impl Default for kvm_run__bindgen_ty_1 { +impl Default for kvm_irqchip__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7334,46 +7484,57 @@ impl Default for kvm_run__bindgen_ty_1 { } } } -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_run__bindgen_ty_2 { - pub regs: kvm_sync_regs, - pub padding: [::std::os::raw::c_char; 2048usize], +impl ::std::fmt::Debug for kvm_irqchip__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irqchip__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_run__bindgen_ty_2() { +fn bindgen_test_layout_kvm_irqchip() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 2048usize, - concat!("Size of: ", stringify!(kvm_run__bindgen_ty_2)) + ::std::mem::size_of::(), + 520usize, + concat!("Size of: ", stringify!(kvm_irqchip)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_2)) + concat!("Alignment of ", stringify!(kvm_irqchip)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).regs as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).chip_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_2), + stringify!(kvm_irqchip), "::", - stringify!(regs) + stringify!(chip_id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run__bindgen_ty_2), + stringify!(kvm_irqchip), "::", - stringify!(padding) + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).chip) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_irqchip), + "::", + stringify!(chip) ) ); } -impl Default for kvm_run__bindgen_ty_2 { +impl Default for kvm_irqchip { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7382,368 +7543,360 @@ impl Default for kvm_run__bindgen_ty_2 { } } } +impl ::std::fmt::Debug for kvm_irqchip { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irqchip {{ chip_id: {:?}, pad: {:?}, chip: {:?} }}", + self.chip_id, self.pad, self.chip + ) + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_pit_config { + pub flags: __u32, + pub pad: [__u32; 15usize], +} #[test] -fn bindgen_test_layout_kvm_run() { +fn bindgen_test_layout_kvm_pit_config() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 2352usize, - concat!("Size of: ", stringify!(kvm_run)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_pit_config)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_run)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_pit_config)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).request_interrupt_window as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_pit_config), "::", - stringify!(request_interrupt_window) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).immediate_exit as *const _ as usize }, - 1usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_pit_config), "::", - stringify!(immediate_exit) + stringify!(pad) ) ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_hyperv_exit { + pub type_: __u32, + pub pad1: __u32, + pub u: kvm_hyperv_exit__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_hyperv_exit__bindgen_ty_1 { + pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, + pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, + pub syndbg: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { + pub msr: __u32, + pub pad2: __u32, + pub control: __u64, + pub evt_page: __u64, + pub msg_page: __u64, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding1 as *const _ as usize }, - 2usize, + ::std::mem::size_of::(), + 32usize, concat!( - "Offset of field: ", - stringify!(kvm_run), - "::", - stringify!(padding1) + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).exit_reason as *const _ as usize }, + ::std::mem::align_of::(), 8usize, concat!( - "Offset of field: ", - stringify!(kvm_run), - "::", - stringify!(exit_reason) + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ready_for_interrupt_injection as *const _ as usize - }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(ready_for_interrupt_injection) + stringify!(msr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).if_flag as *const _ as usize }, - 13usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(if_flag) + stringify!(pad2) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 14usize, + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(flags) + stringify!(control) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr8 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).evt_page) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(cr8) + stringify!(evt_page) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).apic_base as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).msg_page) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", - stringify!(kvm_run), - "::", - stringify!(apic_base) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).kvm_valid_regs as *const _ as usize }, - 288usize, - concat!( - "Offset of field: ", - stringify!(kvm_run), - "::", - stringify!(kvm_valid_regs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).kvm_dirty_regs as *const _ as usize }, - 296usize, - concat!( - "Offset of field: ", - stringify!(kvm_run), - "::", - stringify!(kvm_dirty_regs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).s as *const _ as usize }, - 304usize, - concat!( - "Offset of field: ", - stringify!(kvm_run), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(s) + stringify!(msg_page) ) ); } -impl Default for kvm_run { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_coalesced_mmio_zone { - pub addr: __u64, - pub size: __u32, - pub __bindgen_anon_1: kvm_coalesced_mmio_zone__bindgen_ty_1, -} #[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_coalesced_mmio_zone__bindgen_ty_1 { - pub pad: __u32, - pub pio: __u32, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { + pub input: __u64, + pub result: __u64, + pub params: [__u64; 2usize], } #[test] -fn bindgen_test_layout_kvm_coalesced_mmio_zone__bindgen_ty_1() { +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 4usize, + ::std::mem::size_of::(), + 32usize, concat!( "Size of: ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + ::std::mem::align_of::(), + 8usize, concat!( "Alignment of ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(pad) + stringify!(input) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pio as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(pio) + stringify!(result) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(params) ) ); } -impl Default for kvm_coalesced_mmio_zone__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3 { + pub msr: __u32, + pub pad2: __u32, + pub control: __u64, + pub status: __u64, + pub send_page: __u64, + pub recv_page: __u64, + pub pending_page: __u64, } #[test] -fn bindgen_test_layout_kvm_coalesced_mmio_zone() { +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio_zone)) + ::std::mem::size_of::(), + 48usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_coalesced_mmio_zone)) + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), "::", - stringify!(addr) + stringify!(msr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(pad2) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_zone), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), "::", - stringify!(size) + stringify!(control) ) ); -} -impl Default for kvm_coalesced_mmio_zone { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_coalesced_mmio { - pub phys_addr: __u64, - pub len: __u32, - pub __bindgen_anon_1: kvm_coalesced_mmio__bindgen_ty_1, - pub data: [__u8; 8usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_coalesced_mmio__bindgen_ty_1 { - pub pad: __u32, - pub pio: __u32, -} -#[test] -fn bindgen_test_layout_kvm_coalesced_mmio__bindgen_ty_1() { assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio__bindgen_ty_1)) + unsafe { ::std::ptr::addr_of!((*ptr).status) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(status) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).send_page) as usize - ptr as usize }, + 24usize, concat!( - "Alignment of ", - stringify!(kvm_coalesced_mmio__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(send_page) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).recv_page) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio__bindgen_ty_1), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), "::", - stringify!(pad) + stringify!(recv_page) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pio as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pending_page) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio__bindgen_ty_1), + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_3), "::", - stringify!(pio) + stringify!(pending_page) ) ); } -impl Default for kvm_coalesced_mmio__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} #[test] -fn bindgen_test_layout_kvm_coalesced_mmio() { +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_coalesced_mmio)) + concat!("Alignment of ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).phys_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).synic) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio), + stringify!(kvm_hyperv_exit__bindgen_ty_1), "::", - stringify!(phys_addr) + stringify!(synic) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).hcall) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio), + stringify!(kvm_hyperv_exit__bindgen_ty_1), "::", - stringify!(len) + stringify!(hcall) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).syndbg) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio), + stringify!(kvm_hyperv_exit__bindgen_ty_1), "::", - stringify!(data) + stringify!(syndbg) ) ); } -impl Default for kvm_coalesced_mmio { +impl Default for kvm_hyperv_exit__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7752,58 +7905,57 @@ impl Default for kvm_coalesced_mmio { } } } -#[repr(C)] -pub struct kvm_coalesced_mmio_ring { - pub first: __u32, - pub last: __u32, - pub coalesced_mmio: __IncompleteArrayField, +impl ::std::fmt::Debug for kvm_hyperv_exit__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_hyperv_exit__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_coalesced_mmio_ring() { +fn bindgen_test_layout_kvm_hyperv_exit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_coalesced_mmio_ring)) + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_coalesced_mmio_ring)) + concat!("Alignment of ", stringify!(kvm_hyperv_exit)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).first as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_ring), + stringify!(kvm_hyperv_exit), "::", - stringify!(first) + stringify!(type_) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).last as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_ring), + stringify!(kvm_hyperv_exit), "::", - stringify!(last) + stringify!(pad1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).coalesced_mmio as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_coalesced_mmio_ring), + stringify!(kvm_hyperv_exit), "::", - stringify!(coalesced_mmio) + stringify!(u) ) ); } -impl Default for kvm_coalesced_mmio_ring { +impl Default for kvm_hyperv_exit { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7812,159 +7964,183 @@ impl Default for kvm_coalesced_mmio_ring { } } } +impl ::std::fmt::Debug for kvm_hyperv_exit { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_hyperv_exit {{ type: {:?}, pad1: {:?}, u: {:?} }}", + self.type_, self.pad1, self.u + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_xen_exit { + pub type_: __u32, + pub u: kvm_xen_exit__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_xen_exit__bindgen_ty_1 { + pub hcall: kvm_xen_exit__bindgen_ty_1__bindgen_ty_1, +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_translation { - pub linear_address: __u64, - pub physical_address: __u64, - pub valid: __u8, - pub writeable: __u8, - pub usermode: __u8, - pub pad: [__u8; 5usize], +pub struct kvm_xen_exit__bindgen_ty_1__bindgen_ty_1 { + pub longmode: __u32, + pub cpl: __u32, + pub input: __u64, + pub result: __u64, + pub params: [__u64; 6usize], } #[test] -fn bindgen_test_layout_kvm_translation() { +fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_translation)) + ::std::mem::size_of::(), + 72usize, + concat!( + "Size of: ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_translation)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).linear_address as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_translation), - "::", - stringify!(linear_address) + "Alignment of ", + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).physical_address as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).longmode) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_translation), + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(physical_address) + stringify!(longmode) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).valid as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).cpl) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_translation), + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(valid) + stringify!(cpl) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).writeable as *const _ as usize }, - 17usize, + unsafe { ::std::ptr::addr_of!((*ptr).input) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_translation), + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(writeable) + stringify!(input) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).usermode as *const _ as usize }, - 18usize, + unsafe { ::std::ptr::addr_of!((*ptr).result) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_translation), + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(usermode) + stringify!(result) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 19usize, + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_translation), + stringify!(kvm_xen_exit__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(pad) + stringify!(params) ) ); } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_s390_mem_op { - pub gaddr: __u64, - pub flags: __u64, - pub size: __u32, - pub op: __u32, - pub buf: __u64, - pub __bindgen_anon_1: kvm_s390_mem_op__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_s390_mem_op__bindgen_ty_1 { - pub ar: __u8, - pub sida_offset: __u32, - pub reserved: [__u8; 32usize], -} #[test] -fn bindgen_test_layout_kvm_s390_mem_op__bindgen_ty_1() { +fn bindgen_test_layout_kvm_xen_exit__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_s390_mem_op__bindgen_ty_1)) + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_xen_exit__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_mem_op__bindgen_ty_1)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_xen_exit__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ar as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hcall) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mem_op__bindgen_ty_1), + stringify!(kvm_xen_exit__bindgen_ty_1), "::", - stringify!(ar) + stringify!(hcall) ) ); - assert_eq!( +} +impl Default for kvm_xen_exit__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { - &(*(::std::ptr::null::())).sida_offset as *const _ - as usize - }, + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_xen_exit__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_xen_exit__bindgen_ty_1 {{ union }}") + } +} +#[test] +fn bindgen_test_layout_kvm_xen_exit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(kvm_xen_exit)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_xen_exit)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mem_op__bindgen_ty_1), + stringify!(kvm_xen_exit), "::", - stringify!(sida_offset) + stringify!(type_) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mem_op__bindgen_ty_1), + stringify!(kvm_xen_exit), "::", - stringify!(reserved) + stringify!(u) ) ); } -impl Default for kvm_s390_mem_op__bindgen_ty_1 { +impl Default for kvm_xen_exit { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -7973,2216 +8149,2194 @@ impl Default for kvm_s390_mem_op__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_xen_exit { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_xen_exit {{ type: {:?}, u: {:?} }}", + self.type_, self.u + ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run { + pub request_interrupt_window: __u8, + pub immediate_exit: __u8, + pub padding1: [__u8; 6usize], + pub exit_reason: __u32, + pub ready_for_interrupt_injection: __u8, + pub if_flag: __u8, + pub flags: __u16, + pub cr8: __u64, + pub apic_base: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1, + pub kvm_valid_regs: __u64, + pub kvm_dirty_regs: __u64, + pub s: kvm_run__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1 { + pub hw: kvm_run__bindgen_ty_1__bindgen_ty_1, + pub fail_entry: kvm_run__bindgen_ty_1__bindgen_ty_2, + pub ex: kvm_run__bindgen_ty_1__bindgen_ty_3, + pub io: kvm_run__bindgen_ty_1__bindgen_ty_4, + pub debug: kvm_run__bindgen_ty_1__bindgen_ty_5, + pub mmio: kvm_run__bindgen_ty_1__bindgen_ty_6, + pub iocsr_io: kvm_run__bindgen_ty_1__bindgen_ty_7, + pub hypercall: kvm_run__bindgen_ty_1__bindgen_ty_8, + pub tpr_access: kvm_run__bindgen_ty_1__bindgen_ty_9, + pub s390_sieic: kvm_run__bindgen_ty_1__bindgen_ty_10, + pub s390_reset_flags: __u64, + pub s390_ucontrol: kvm_run__bindgen_ty_1__bindgen_ty_11, + pub dcr: kvm_run__bindgen_ty_1__bindgen_ty_12, + pub internal: kvm_run__bindgen_ty_1__bindgen_ty_13, + pub emulation_failure: kvm_run__bindgen_ty_1__bindgen_ty_14, + pub osi: kvm_run__bindgen_ty_1__bindgen_ty_15, + pub papr_hcall: kvm_run__bindgen_ty_1__bindgen_ty_16, + pub s390_tsch: kvm_run__bindgen_ty_1__bindgen_ty_17, + pub epr: kvm_run__bindgen_ty_1__bindgen_ty_18, + pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_19, + pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_20, + pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_21, + pub hyperv: kvm_hyperv_exit, + pub arm_nisv: kvm_run__bindgen_ty_1__bindgen_ty_22, + pub msr: kvm_run__bindgen_ty_1__bindgen_ty_23, + pub xen: kvm_xen_exit, + pub riscv_sbi: kvm_run__bindgen_ty_1__bindgen_ty_24, + pub riscv_csr: kvm_run__bindgen_ty_1__bindgen_ty_25, + pub notify: kvm_run__bindgen_ty_1__bindgen_ty_26, + pub memory_fault: kvm_run__bindgen_ty_1__bindgen_ty_27, + pub padding: [::std::os::raw::c_char; 256usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_1 { + pub hardware_exit_reason: __u64, +} #[test] -fn bindgen_test_layout_kvm_s390_mem_op() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_s390_mem_op)) - ); +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::size_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_mem_op)) + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gaddr as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(gaddr) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).hardware_exit_reason) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mem_op), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(flags) + stringify!(hardware_exit_reason) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_2 { + pub hardware_entry_failure_reason: __u64, + pub cpu: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + ::std::mem::size_of::(), 16usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_mem_op), - "::", - stringify!(size) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, - 20usize, + unsafe { + ::std::ptr::addr_of!((*ptr).hardware_entry_failure_reason) as usize - ptr as usize + }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mem_op), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(op) + stringify!(hardware_entry_failure_reason) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).cpu) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mem_op), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_2), "::", - stringify!(buf) + stringify!(cpu) ) ); } -impl Default for kvm_s390_mem_op { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_interrupt { - pub irq: __u32, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_3 { + pub exception: __u32, + pub error_code: __u32, } #[test] -fn bindgen_test_layout_kvm_interrupt() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_interrupt)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_interrupt)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irq as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exception) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_interrupt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3), "::", - stringify!(irq) + stringify!(exception) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).error_code) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_3), + "::", + stringify!(error_code) ) ); } #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_dirty_log { - pub slot: __u32, - pub padding1: __u32, - pub __bindgen_anon_1: kvm_dirty_log__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_dirty_log__bindgen_ty_1 { - pub dirty_bitmap: *mut ::std::os::raw::c_void, - pub padding2: __u64, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_4 { + pub direction: __u8, + pub size: __u8, + pub port: __u16, + pub count: __u32, + pub data_offset: __u64, } #[test] -fn bindgen_test_layout_kvm_dirty_log__bindgen_ty_1() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_4() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_dirty_log__bindgen_ty_1)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_log__bindgen_ty_1)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dirty_bitmap as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_log__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), "::", - stringify!(dirty_bitmap) + stringify!(direction) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).padding2 as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_log__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), "::", - stringify!(padding2) + stringify!(size) ) ); -} -impl Default for kvm_dirty_log__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_dirty_log() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_dirty_log)) - ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_log)) + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), + "::", + stringify!(port) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_log), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), "::", - stringify!(slot) + stringify!(count) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding1 as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).data_offset) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_log), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_4), "::", - stringify!(padding1) + stringify!(data_offset) ) ); } -impl Default for kvm_dirty_log { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_clear_dirty_log { - pub slot: __u32, - pub num_pages: __u32, - pub first_page: __u64, - pub __bindgen_anon_1: kvm_clear_dirty_log__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_clear_dirty_log__bindgen_ty_1 { - pub dirty_bitmap: *mut ::std::os::raw::c_void, - pub padding2: __u64, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_5 { + pub arch: kvm_debug_exit_arch, } #[test] -fn bindgen_test_layout_kvm_clear_dirty_log__bindgen_ty_1() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_5() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_clear_dirty_log__bindgen_ty_1)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, concat!( "Alignment of ", - stringify!(kvm_clear_dirty_log__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dirty_bitmap as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log__bindgen_ty_1), - "::", - stringify!(dirty_bitmap) + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).padding2 as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_clear_dirty_log__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_5), "::", - stringify!(padding2) + stringify!(arch) ) ); } -impl Default for kvm_clear_dirty_log__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_6 { + pub phys_addr: __u64, + pub data: [__u8; 8usize], + pub len: __u32, + pub is_write: __u8, } #[test] -fn bindgen_test_layout_kvm_clear_dirty_log() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_6() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 24usize, - concat!("Size of: ", stringify!(kvm_clear_dirty_log)) + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_clear_dirty_log)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_clear_dirty_log), - "::", - stringify!(slot) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_pages as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_clear_dirty_log), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), "::", - stringify!(num_pages) + stringify!(phys_addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).first_page as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_clear_dirty_log), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), "::", - stringify!(first_page) + stringify!(data) ) ); -} -impl Default for kvm_clear_dirty_log { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct kvm_signal_mask { - pub len: __u32, - pub sigset: __IncompleteArrayField<__u8>, -} -#[test] -fn bindgen_test_layout_kvm_signal_mask() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_signal_mask)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_signal_mask)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_signal_mask), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), "::", stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sigset as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_signal_mask), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_6), "::", - stringify!(sigset) + stringify!(is_write) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_tpr_access_ctl { - pub enabled: __u32, - pub flags: __u32, - pub reserved: [__u32; 8usize], +pub struct kvm_run__bindgen_ty_1__bindgen_ty_7 { + pub phys_addr: __u64, + pub data: [__u8; 8usize], + pub len: __u32, + pub is_write: __u8, } #[test] -fn bindgen_test_layout_kvm_tpr_access_ctl() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_7() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_tpr_access_ctl)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_tpr_access_ctl)) + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).enabled as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_tpr_access_ctl), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", - stringify!(enabled) + stringify!(phys_addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_tpr_access_ctl), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", - stringify!(flags) + stringify!(data) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_tpr_access_ctl), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), "::", - stringify!(reserved) + stringify!(len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_7), + "::", + stringify!(is_write) ) ); } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_vapic_addr { - pub vapic_addr: __u64, +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_8 { + pub nr: __u64, + pub args: [__u64; 6usize], + pub ret: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + pub longmode: __u32, + pub flags: __u64, } #[test] -fn bindgen_test_layout_kvm_vapic_addr() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 8usize, - concat!("Size of: ", stringify!(kvm_vapic_addr)) + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_vapic_addr)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vapic_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).longmode) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_vapic_addr), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1), "::", - stringify!(vapic_addr) + stringify!(longmode) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_mp_state { - pub mp_state: __u32, -} -#[test] -fn bindgen_test_layout_kvm_mp_state() { - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_mp_state)) - ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_mp_state)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mp_state as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_mp_state), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1), "::", - stringify!(mp_state) + stringify!(flags) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_psw { - pub mask: __u64, - pub addr: __u64, +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_8__bindgen_ty_1 {{ union }}" + ) + } } #[test] -fn bindgen_test_layout_kvm_s390_psw() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_8() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_s390_psw)) + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_psw)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mask as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_psw), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), "::", - stringify!(mask) + stringify!(nr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_psw), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), "::", - stringify!(addr) + stringify!(args) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_8), + "::", + stringify!(ret) ) ); } +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_8 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_8 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_8 {{ nr: {:?}, args: {:?}, ret: {:?}, __bindgen_anon_1: {:?} }}" , self . nr , self . args , self . ret , self . __bindgen_anon_1) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_interrupt { - pub type_: __u32, - pub parm: __u32, - pub parm64: __u64, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_9 { + pub rip: __u64, + pub is_write: __u32, + pub pad: __u32, } #[test] -fn bindgen_test_layout_kvm_s390_interrupt() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_9() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(kvm_s390_interrupt)) + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_interrupt)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rip) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_interrupt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), "::", - stringify!(type_) + stringify!(rip) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).parm as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_interrupt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), "::", - stringify!(parm) + stringify!(is_write) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).parm64 as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_s390_interrupt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_9), "::", - stringify!(parm64) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_io_info { - pub subchannel_id: __u16, - pub subchannel_nr: __u16, - pub io_int_parm: __u32, - pub io_int_word: __u32, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_10 { + pub icptcode: __u8, + pub ipa: __u16, + pub ipb: __u32, } #[test] -fn bindgen_test_layout_kvm_s390_io_info() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_10() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(kvm_s390_io_info)) + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_s390_io_info)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).subchannel_id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).icptcode) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_io_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), "::", - stringify!(subchannel_id) + stringify!(icptcode) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).subchannel_nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ipa) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", - stringify!(kvm_s390_io_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), "::", - stringify!(subchannel_nr) + stringify!(ipa) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).io_int_parm as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ipb) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_io_info), - "::", - stringify!(io_int_parm) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).io_int_word as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_io_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_10), "::", - stringify!(io_int_word) + stringify!(ipb) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_ext_info { - pub ext_params: __u32, - pub pad: __u32, - pub ext_params2: __u64, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_11 { + pub trans_exc_code: __u64, + pub pgm_code: __u32, } #[test] -fn bindgen_test_layout_kvm_s390_ext_info() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_11() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(kvm_s390_ext_info)) + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_ext_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_params as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_ext_info), - "::", - stringify!(ext_params) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).trans_exc_code) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ext_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), "::", - stringify!(pad) + stringify!(trans_exc_code) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_params2 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pgm_code) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ext_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_11), "::", - stringify!(ext_params2) + stringify!(pgm_code) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_pgm_info { - pub trans_exc_code: __u64, - pub mon_code: __u64, - pub per_address: __u64, - pub data_exc_code: __u32, - pub code: __u16, - pub mon_class_nr: __u16, - pub per_code: __u8, - pub per_atmid: __u8, - pub exc_access_id: __u8, - pub per_access_id: __u8, - pub op_access_id: __u8, - pub flags: __u8, - pub pad: [__u8; 2usize], -} -#[test] -fn bindgen_test_layout_kvm_s390_pgm_info() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_s390_pgm_info)) +pub struct kvm_run__bindgen_ty_1__bindgen_ty_12 { + pub dcrn: __u32, + pub data: __u32, + pub is_write: __u8, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_12() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_pgm_info)) + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_exc_code as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dcrn) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), "::", - stringify!(trans_exc_code) + stringify!(dcrn) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mon_code as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), "::", - stringify!(mon_code) + stringify!(data) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_address as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).is_write) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_12), "::", - stringify!(per_address) + stringify!(is_write) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_13 { + pub suberror: __u32, + pub ndata: __u32, + pub data: [__u64; 16usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_13() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_exc_code as *const _ as usize }, - 24usize, + ::std::mem::size_of::(), + 136usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(data_exc_code) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 28usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(code) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mon_class_nr as *const _ as usize }, - 30usize, + unsafe { ::std::ptr::addr_of!((*ptr).suberror) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), "::", - stringify!(mon_class_nr) + stringify!(suberror) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_code as *const _ as usize }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), "::", - stringify!(per_code) + stringify!(ndata) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_atmid as *const _ as usize }, - 33usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_13), "::", - stringify!(per_atmid) + stringify!(data) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_14 { + pub suberror: __u32, + pub ndata: __u32, + pub flags: __u64, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1 { + pub insn_size: __u8, + pub insn_bytes: [__u8; 15usize], +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit< + kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1, + > = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).exc_access_id as *const _ as usize }, - 34usize, + ::std::mem::align_of::(), + 1usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(exc_access_id) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).per_access_id as *const _ as usize }, - 35usize, + unsafe { ::std::ptr::addr_of!((*ptr).insn_size) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(per_access_id) + stringify!(insn_size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).op_access_id as *const _ as usize }, - 36usize, + unsafe { ::std::ptr::addr_of!((*ptr).insn_bytes) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pgm_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(op_access_id) + stringify!(insn_bytes) ) ); +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1() { assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 37usize, + ::std::mem::size_of::(), + 16usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(flags) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 38usize, + ::std::mem::align_of::(), + 1usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_pgm_info), - "::", - stringify!(pad) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_prefix_info { - pub address: __u32, +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_14__bindgen_ty_1 {{ union }}" + ) + } } #[test] -fn bindgen_test_layout_kvm_s390_prefix_info() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_14() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_s390_prefix_info)) + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_prefix_info)) + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).suberror) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_prefix_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), "::", - stringify!(address) + stringify!(suberror) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_extcall_info { - pub code: __u16, -} -#[test] -fn bindgen_test_layout_kvm_s390_extcall_info() { - assert_eq!( - ::std::mem::size_of::(), - 2usize, - concat!("Size of: ", stringify!(kvm_s390_extcall_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(kvm_s390_extcall_info)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_extcall_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), "::", - stringify!(code) + stringify!(ndata) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_emerg_info { - pub code: __u16, -} -#[test] -fn bindgen_test_layout_kvm_s390_emerg_info() { - assert_eq!( - ::std::mem::size_of::(), - 2usize, - concat!("Size of: ", stringify!(kvm_s390_emerg_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(kvm_s390_emerg_info)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_emerg_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_14), "::", - stringify!(code) + stringify!(flags) ) ); } +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_14 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_14 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_14 {{ suberror: {:?}, ndata: {:?}, flags: {:?}, __bindgen_anon_1: {:?} }}" , self . suberror , self . ndata , self . flags , self . __bindgen_anon_1) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_stop_info { - pub flags: __u32, +pub struct kvm_run__bindgen_ty_1__bindgen_ty_15 { + pub gprs: [__u64; 32usize], } #[test] -fn bindgen_test_layout_kvm_s390_stop_info() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_15() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_s390_stop_info)) + ::std::mem::size_of::(), + 256usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_s390_stop_info)) + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gprs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_stop_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_15), "::", - stringify!(flags) + stringify!(gprs) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_mchk_info { - pub cr14: __u64, - pub mcic: __u64, - pub failing_storage_address: __u64, - pub ext_damage_code: __u32, - pub pad: __u32, - pub fixed_logout: [__u8; 16usize], +pub struct kvm_run__bindgen_ty_1__bindgen_ty_16 { + pub nr: __u64, + pub ret: __u64, + pub args: [__u64; 9usize], } #[test] -fn bindgen_test_layout_kvm_s390_mchk_info() { - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_s390_mchk_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_mchk_info)) - ); +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_16() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cr14 as *const _ as usize }, - 0usize, + ::std::mem::size_of::(), + 88usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(cr14) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mcic as *const _ as usize }, + ::std::mem::align_of::(), 8usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(mcic) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).failing_storage_address as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_mchk_info), - "::", - stringify!(failing_storage_address) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ext_damage_code as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mchk_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), "::", - stringify!(ext_damage_code) + stringify!(nr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 28usize, + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mchk_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), "::", - stringify!(pad) + stringify!(ret) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fixed_logout as *const _ as usize }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_s390_mchk_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_16), "::", - stringify!(fixed_logout) + stringify!(args) ) ); } #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_s390_irq { - pub type_: __u64, - pub u: kvm_s390_irq__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_s390_irq__bindgen_ty_1 { - pub io: kvm_s390_io_info, - pub ext: kvm_s390_ext_info, - pub pgm: kvm_s390_pgm_info, - pub emerg: kvm_s390_emerg_info, - pub extcall: kvm_s390_extcall_info, - pub prefix: kvm_s390_prefix_info, - pub stop: kvm_s390_stop_info, - pub mchk: kvm_s390_mchk_info, - pub reserved: [::std::os::raw::c_char; 64usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_17 { + pub subchannel_id: __u16, + pub subchannel_nr: __u16, + pub io_int_parm: __u32, + pub io_int_word: __u32, + pub ipb: __u32, + pub dequeued: __u8, } #[test] -fn bindgen_test_layout_kvm_s390_irq__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_s390_irq__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_irq__bindgen_ty_1)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).io as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(io) - ) - ); +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_17() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext as *const _ as usize }, - 0usize, + ::std::mem::size_of::(), + 20usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(ext) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pgm as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), - "::", - stringify!(pgm) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).emerg as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).subchannel_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(emerg) + stringify!(subchannel_id) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).extcall as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).subchannel_nr) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(extcall) + stringify!(subchannel_nr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).prefix as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).io_int_parm) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(prefix) + stringify!(io_int_parm) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).stop as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).io_int_word) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(stop) + stringify!(io_int_word) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mchk as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).ipb) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(mchk) + stringify!(ipb) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).dequeued) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_17), "::", - stringify!(reserved) + stringify!(dequeued) ) ); } -impl Default for kvm_s390_irq__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_18 { + pub epr: __u32, } #[test] -fn bindgen_test_layout_kvm_s390_irq() { - assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_s390_irq)) - ); +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_18() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_irq)) + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_irq), - "::", - stringify!(type_) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).epr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_18), "::", - stringify!(u) + stringify!(epr) ) ); } -impl Default for kvm_s390_irq { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_19 { + pub type_: __u32, + pub ndata: __u32, + pub __bindgen_anon_1: kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_irq_state { - pub buf: __u64, - pub flags: __u32, - pub len: __u32, - pub reserved: [__u32; 4usize], +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + pub flags: __u64, + pub data: [__u64; 16usize], } #[test] -fn bindgen_test_layout_kvm_s390_irq_state() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_s390_irq_state)) - ); +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_irq_state)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).buf as *const _ as usize }, - 0usize, + ::std::mem::size_of::(), + 128usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_irq_state), - "::", - stringify!(buf) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + ::std::mem::align_of::(), 8usize, concat!( - "Offset of field: ", - stringify!(kvm_s390_irq_state), - "::", - stringify!(flags) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq_state), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1), "::", - stringify!(len) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_irq_state), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1), "::", - stringify!(reserved) + stringify!(data) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_guest_debug { - pub control: __u32, - pub pad: __u32, - pub arch: kvm_guest_debug_arch, +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_run__bindgen_ty_1__bindgen_ty_19__bindgen_ty_1 {{ union }}" + ) + } } #[test] -fn bindgen_test_layout_kvm_guest_debug() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_guest_debug)) + ::std::mem::size_of::(), + 136usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_guest_debug)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).control as *const _ as usize }, - 0usize, concat!( - "Offset of field: ", - stringify!(kvm_guest_debug), - "::", - stringify!(control) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_guest_debug), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), "::", - stringify!(pad) + stringify!(type_) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).arch as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).ndata) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_guest_debug), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_19), "::", - stringify!(arch) + stringify!(ndata) ) ); } -pub const kvm_ioeventfd_flag_nr_datamatch: ::std::os::raw::c_uint = 0; -pub const kvm_ioeventfd_flag_nr_pio: ::std::os::raw::c_uint = 1; -pub const kvm_ioeventfd_flag_nr_deassign: ::std::os::raw::c_uint = 2; -pub const kvm_ioeventfd_flag_nr_virtio_ccw_notify: ::std::os::raw::c_uint = 3; -pub const kvm_ioeventfd_flag_nr_fast_mmio: ::std::os::raw::c_uint = 4; -pub const kvm_ioeventfd_flag_nr_max: ::std::os::raw::c_uint = 5; -pub type _bindgen_ty_1 = ::std::os::raw::c_uint; +impl Default for kvm_run__bindgen_ty_1__bindgen_ty_19 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1__bindgen_ty_19 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run__bindgen_ty_1__bindgen_ty_19 {{ type: {:?}, ndata: {:?}, __bindgen_anon_1: {:?} }}" , self . type_ , self . ndata , self . __bindgen_anon_1) + } +} #[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct kvm_ioeventfd { - pub datamatch: __u64, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_20 { pub addr: __u64, - pub len: __u32, - pub fd: __s32, - pub flags: __u32, - pub pad: [__u8; 36usize], + pub ar: __u8, + pub reserved: __u8, + pub fc: __u8, + pub sel1: __u8, + pub sel2: __u16, } #[test] -fn bindgen_test_layout_kvm_ioeventfd() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_20() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_ioeventfd)) + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_ioeventfd)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).datamatch as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ioeventfd), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(datamatch) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ar) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_ioeventfd), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(addr) + stringify!(ar) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 9usize, concat!( "Offset of field: ", - stringify!(kvm_ioeventfd), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(len) + stringify!(reserved) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).fc) as usize - ptr as usize }, + 10usize, concat!( "Offset of field: ", - stringify!(kvm_ioeventfd), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(fd) + stringify!(fc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).sel1) as usize - ptr as usize }, + 11usize, concat!( "Offset of field: ", - stringify!(kvm_ioeventfd), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(flags) + stringify!(sel1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 28usize, + unsafe { ::std::ptr::addr_of!((*ptr).sel2) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_ioeventfd), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_20), "::", - stringify!(pad) + stringify!(sel2) ) ); } -impl Default for kvm_ioeventfd { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} #[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct kvm_enable_cap { - pub cap: __u32, - pub flags: __u32, - pub args: [__u64; 4usize], - pub pad: [__u8; 64usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_21 { + pub vector: __u8, } #[test] -fn bindgen_test_layout_kvm_enable_cap() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_21() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 104usize, - concat!("Size of: ", stringify!(kvm_enable_cap)) + ::std::mem::size_of::(), + 1usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_enable_cap)) + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vector) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_enable_cap), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_21), "::", - stringify!(cap) + stringify!(vector) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_22 { + pub esr_iss: __u64, + pub fault_ipa: __u64, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_22() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, + ::std::mem::size_of::(), + 16usize, concat!( - "Offset of field: ", - stringify!(kvm_enable_cap), - "::", - stringify!(flags) + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).args as *const _ as usize }, + ::std::mem::align_of::(), 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).esr_iss) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_enable_cap), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22), "::", - stringify!(args) + stringify!(esr_iss) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).fault_ipa) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_enable_cap), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_22), "::", - stringify!(pad) + stringify!(fault_ipa) ) ); } -impl Default for kvm_enable_cap { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} #[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct kvm_ppc_pvinfo { - pub flags: __u32, - pub hcall: [__u32; 4usize], - pub pad: [__u8; 108usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_23 { + pub error: __u8, + pub pad: [__u8; 7usize], + pub reason: __u32, + pub index: __u32, + pub data: __u64, } #[test] -fn bindgen_test_layout_kvm_ppc_pvinfo() { - assert_eq!( - ::std::mem::size_of::(), - 128usize, - concat!("Size of: ", stringify!(kvm_ppc_pvinfo)) - ); +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_23() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_ppc_pvinfo)) + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_ppc_pvinfo), - "::", - stringify!(flags) + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hcall as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).error) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_pvinfo), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(hcall) + stringify!(error) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_pvinfo), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", stringify!(pad) ) ); -} -impl Default for kvm_ppc_pvinfo { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_one_page_size { - pub page_shift: __u32, - pub pte_enc: __u32, -} -#[test] -fn bindgen_test_layout_kvm_ppc_one_page_size() { assert_eq!( - ::std::mem::size_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).reason) as usize - ptr as usize }, 8usize, - concat!("Size of: ", stringify!(kvm_ppc_one_page_size)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_ppc_one_page_size)) + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), + "::", + stringify!(reason) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).page_shift as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_page_size), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(page_shift) + stringify!(index) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pte_enc as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_page_size), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_23), "::", - stringify!(pte_enc) + stringify!(data) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_one_seg_page_size { - pub page_shift: __u32, - pub slb_enc: __u32, - pub enc: [kvm_ppc_one_page_size; 8usize], +pub struct kvm_run__bindgen_ty_1__bindgen_ty_24 { + pub extension_id: ::std::os::raw::c_ulong, + pub function_id: ::std::os::raw::c_ulong, + pub args: [::std::os::raw::c_ulong; 6usize], + pub ret: [::std::os::raw::c_ulong; 2usize], } #[test] -fn bindgen_test_layout_kvm_ppc_one_seg_page_size() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_24() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_ppc_one_seg_page_size)) + ::std::mem::size_of::(), + 80usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_ppc_one_seg_page_size)) + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).page_shift as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).extension_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_seg_page_size), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(page_shift) + stringify!(extension_id) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).slb_enc as *const _ as usize - }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).function_id) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_seg_page_size), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(slb_enc) + stringify!(function_id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).enc as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), + "::", + stringify!(args) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ret) as usize - ptr as usize }, + 64usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_one_seg_page_size), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_24), "::", - stringify!(enc) + stringify!(ret) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_smmu_info { - pub flags: __u64, - pub slb_size: __u32, - pub data_keys: __u16, - pub instr_keys: __u16, - pub sps: [kvm_ppc_one_seg_page_size; 8usize], +pub struct kvm_run__bindgen_ty_1__bindgen_ty_25 { + pub csr_num: ::std::os::raw::c_ulong, + pub new_value: ::std::os::raw::c_ulong, + pub write_mask: ::std::os::raw::c_ulong, + pub ret_value: ::std::os::raw::c_ulong, } #[test] -fn bindgen_test_layout_kvm_ppc_smmu_info() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_25() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 592usize, - concat!("Size of: ", stringify!(kvm_ppc_smmu_info)) + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_ppc_smmu_info)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).csr_num) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), "::", - stringify!(flags) + stringify!(csr_num) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slb_size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).new_value) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), "::", - stringify!(slb_size) + stringify!(new_value) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data_keys as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).write_mask) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), "::", - stringify!(data_keys) + stringify!(write_mask) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).instr_keys as *const _ as usize }, - 14usize, + unsafe { ::std::ptr::addr_of!((*ptr).ret_value) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_25), "::", - stringify!(instr_keys) + stringify!(ret_value) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_run__bindgen_ty_1__bindgen_ty_26 { + pub flags: __u32, +} +#[test] +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_26() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sps as *const _ as usize }, - 16usize, + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_smmu_info), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_26), "::", - stringify!(sps) + stringify!(flags) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_ppc_resize_hpt { +pub struct kvm_run__bindgen_ty_1__bindgen_ty_27 { pub flags: __u64, - pub shift: __u32, - pub pad: __u32, + pub gpa: __u64, + pub size: __u64, } #[test] -fn bindgen_test_layout_kvm_ppc_resize_hpt() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_27() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_ppc_resize_hpt)) + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27) + ) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_ppc_resize_hpt)) + concat!( + "Alignment of ", + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_resize_hpt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), "::", stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).shift as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gpa) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_resize_hpt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), "::", - stringify!(shift) + stringify!(gpa) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_ppc_resize_hpt), + stringify!(kvm_run__bindgen_ty_1__bindgen_ty_27), "::", - stringify!(pad) + stringify!(size) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irq_routing_irqchip { - pub irqchip: __u32, - pub pin: __u32, -} #[test] -fn bindgen_test_layout_kvm_irq_routing_irqchip() { +fn bindgen_test_layout_kvm_run__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_routing_irqchip)) + ::std::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_irqchip)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).irqchip as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).hw) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_irqchip), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(irqchip) + stringify!(hw) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pin as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).fail_entry) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_irqchip), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pin) + stringify!(fail_entry) ) ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_irq_routing_msi { - pub address_lo: __u32, - pub address_hi: __u32, - pub data: __u32, - pub __bindgen_anon_1: kvm_irq_routing_msi__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_irq_routing_msi__bindgen_ty_1 { - pub pad: __u32, - pub devid: __u32, -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_msi__bindgen_ty_1() { assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(kvm_irq_routing_msi__bindgen_ty_1)) + unsafe { ::std::ptr::addr_of!((*ptr).ex) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(ex) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).io) as usize - ptr as usize }, + 0usize, concat!( - "Alignment of ", - stringify!(kvm_irq_routing_msi__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(io) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).debug) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pad) + stringify!(debug) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).devid as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).mmio) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(devid) + stringify!(mmio) ) ); -} -impl Default for kvm_irq_routing_msi__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_msi() { assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_irq_routing_msi)) + unsafe { ::std::ptr::addr_of!((*ptr).iocsr_io) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(iocsr_io) + ) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_msi)) + unsafe { ::std::ptr::addr_of!((*ptr).hypercall) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(hypercall) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_lo as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tpr_access) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(address_lo) + stringify!(tpr_access) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_hi as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_sieic) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(address_hi) + stringify!(s390_sieic) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_reset_flags) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_msi), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(data) + stringify!(s390_reset_flags) ) ); -} -impl Default for kvm_irq_routing_msi { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irq_routing_s390_adapter { - pub ind_addr: __u64, - pub summary_addr: __u64, - pub ind_offset: __u64, - pub summary_offset: __u32, - pub adapter_id: __u32, -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_s390_adapter() { assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_irq_routing_s390_adapter)) + unsafe { ::std::ptr::addr_of!((*ptr).s390_ucontrol) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_ucontrol) + ) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_s390_adapter)) + unsafe { ::std::ptr::addr_of!((*ptr).dcr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(dcr) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ind_addr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).internal) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(ind_addr) + stringify!(internal) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).summary_addr as *const _ - as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).emulation_failure) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(summary_addr) + stringify!(emulation_failure) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ind_offset as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).osi) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(ind_offset) + stringify!(osi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).summary_offset as *const _ - as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).papr_hcall) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(summary_offset) + stringify!(papr_hcall) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).adapter_id as *const _ as usize - }, - 28usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_tsch) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_s390_adapter), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(adapter_id) + stringify!(s390_tsch) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irq_routing_hv_sint { - pub vcpu: __u32, - pub sint: __u32, -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_hv_sint() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_routing_hv_sint)) - ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_hv_sint)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vcpu as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).epr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_hv_sint), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(vcpu) + stringify!(epr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sint as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).system_event) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_hv_sint), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(sint) + stringify!(system_event) ) ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_irq_routing_entry { - pub gsi: __u32, - pub type_: __u32, - pub flags: __u32, - pub pad: __u32, - pub u: kvm_irq_routing_entry__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_irq_routing_entry__bindgen_ty_1 { - pub irqchip: kvm_irq_routing_irqchip, - pub msi: kvm_irq_routing_msi, - pub adapter: kvm_irq_routing_s390_adapter, - pub hv_sint: kvm_irq_routing_hv_sint, - pub pad: [__u32; 8usize], -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_entry__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_irq_routing_entry__bindgen_ty_1)) - ); assert_eq!( - ::std::mem::align_of::(), - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).s390_stsi) as usize - ptr as usize }, + 0usize, concat!( - "Alignment of ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_run__bindgen_ty_1), + "::", + stringify!(s390_stsi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).irqchip as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).eoi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(irqchip) + stringify!(eoi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).msi as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).hyperv) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(msi) + stringify!(hyperv) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).adapter as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).arm_nisv) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(adapter) + stringify!(arm_nisv) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hv_sint as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).msr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(hv_sint) + stringify!(msr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).xen) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry__bindgen_ty_1), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pad) + stringify!(xen) ) ); -} -impl Default for kvm_irq_routing_entry__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_irq_routing_entry() { - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_irq_routing_entry)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_irq_routing_entry)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gsi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).riscv_sbi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(gsi) + stringify!(riscv_sbi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).riscv_csr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(type_) + stringify!(riscv_csr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).notify) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(flags) + stringify!(notify) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).memory_fault) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(pad) + stringify!(memory_fault) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing_entry), + stringify!(kvm_run__bindgen_ty_1), "::", - stringify!(u) + stringify!(padding) ) ); } -impl Default for kvm_irq_routing_entry { +impl Default for kvm_run__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -10191,56 +10345,54 @@ impl Default for kvm_irq_routing_entry { } } } +impl ::std::fmt::Debug for kvm_run__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_run__bindgen_ty_1 {{ union }}") + } +} #[repr(C)] -pub struct kvm_irq_routing { - pub nr: __u32, - pub flags: __u32, - pub entries: __IncompleteArrayField, +#[derive(Copy, Clone)] +pub union kvm_run__bindgen_ty_2 { + pub regs: kvm_sync_regs, + pub padding: [::std::os::raw::c_char; 2048usize], } #[test] -fn bindgen_test_layout_kvm_irq_routing() { +fn bindgen_test_layout_kvm_run__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_irq_routing)) + ::std::mem::size_of::(), + 2048usize, + concat!("Size of: ", stringify!(kvm_run__bindgen_ty_2)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_irq_routing)) + concat!("Alignment of ", stringify!(kvm_run__bindgen_ty_2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).regs) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing), - "::", - stringify!(nr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_irq_routing), + stringify!(kvm_run__bindgen_ty_2), "::", - stringify!(flags) + stringify!(regs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irq_routing), + stringify!(kvm_run__bindgen_ty_2), "::", - stringify!(entries) + stringify!(padding) ) ); } -impl Default for kvm_irq_routing { +impl Default for kvm_run__bindgen_ty_2 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -10249,1163 +10401,1316 @@ impl Default for kvm_irq_routing { } } } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_x86_mce { - pub status: __u64, - pub addr: __u64, - pub misc: __u64, - pub mcg_status: __u64, - pub bank: __u8, - pub pad1: [__u8; 7usize], - pub pad2: [__u64; 3usize], +impl ::std::fmt::Debug for kvm_run__bindgen_ty_2 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_run__bindgen_ty_2 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_x86_mce() { +fn bindgen_test_layout_kvm_run() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_x86_mce)) + ::std::mem::size_of::(), + 2352usize, + concat!("Size of: ", stringify!(kvm_run)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_x86_mce)) + concat!("Alignment of ", stringify!(kvm_run)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).request_interrupt_window) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(request_interrupt_window) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).immediate_exit) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(kvm_run), + "::", + stringify!(immediate_exit) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).status as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding1) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(status) + stringify!(padding1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exit_reason) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(addr) + stringify!(exit_reason) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).misc as *const _ as usize }, - 16usize, + unsafe { + ::std::ptr::addr_of!((*ptr).ready_for_interrupt_injection) as usize - ptr as usize + }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(misc) + stringify!(ready_for_interrupt_injection) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mcg_status as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).if_flag) as usize - ptr as usize }, + 13usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(mcg_status) + stringify!(if_flag) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bank as *const _ as usize }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 14usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(bank) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad1 as *const _ as usize }, - 33usize, + unsafe { ::std::ptr::addr_of!((*ptr).cr8) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(pad1) + stringify!(cr8) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad2 as *const _ as usize }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).apic_base) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_x86_mce), + stringify!(kvm_run), "::", - stringify!(pad2) + stringify!(apic_base) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_xen_hvm_config { - pub flags: __u32, - pub msr: __u32, - pub blob_addr_32: __u64, - pub blob_addr_64: __u64, - pub blob_size_32: __u8, - pub blob_size_64: __u8, - pub pad2: [__u8; 30usize], -} -#[test] -fn bindgen_test_layout_kvm_xen_hvm_config() { - assert_eq!( - ::std::mem::size_of::(), - 56usize, - concat!("Size of: ", stringify!(kvm_xen_hvm_config)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_hvm_config)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).kvm_valid_regs) as usize - ptr as usize }, + 288usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_config), + stringify!(kvm_run), "::", - stringify!(flags) + stringify!(kvm_valid_regs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).msr as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).kvm_dirty_regs) as usize - ptr as usize }, + 296usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_config), + stringify!(kvm_run), "::", - stringify!(msr) + stringify!(kvm_dirty_regs) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).blob_addr_32 as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).s) as usize - ptr as usize }, + 304usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_config), + stringify!(kvm_run), "::", - stringify!(blob_addr_32) + stringify!(s) ) ); +} +impl Default for kvm_run { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_run { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_run {{ request_interrupt_window: {:?}, immediate_exit: {:?}, padding1: {:?}, exit_reason: {:?}, ready_for_interrupt_injection: {:?}, if_flag: {:?}, flags: {:?}, cr8: {:?}, apic_base: {:?}, __bindgen_anon_1: {:?}, kvm_valid_regs: {:?}, kvm_dirty_regs: {:?}, s: {:?} }}" , self . request_interrupt_window , self . immediate_exit , self . padding1 , self . exit_reason , self . ready_for_interrupt_injection , self . if_flag , self . flags , self . cr8 , self . apic_base , self . __bindgen_anon_1 , self . kvm_valid_regs , self . kvm_dirty_regs , self . s) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_coalesced_mmio_zone { + pub addr: __u64, + pub size: __u32, + pub __bindgen_anon_1: kvm_coalesced_mmio_zone__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_coalesced_mmio_zone__bindgen_ty_1 { + pub pad: __u32, + pub pio: __u32, +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio_zone__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).blob_addr_64 as *const _ as usize }, - 16usize, + ::std::mem::size_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_xen_hvm_config), - "::", - stringify!(blob_addr_64) + "Size of: ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).blob_size_32 as *const _ as usize }, - 24usize, + ::std::mem::align_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_xen_hvm_config), - "::", - stringify!(blob_size_32) + "Alignment of ", + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).blob_size_64 as *const _ as usize }, - 25usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_config), + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), "::", - stringify!(blob_size_64) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad2 as *const _ as usize }, - 26usize, + unsafe { ::std::ptr::addr_of!((*ptr).pio) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_config), + stringify!(kvm_coalesced_mmio_zone__bindgen_ty_1), "::", - stringify!(pad2) + stringify!(pio) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_irqfd { - pub fd: __u32, - pub gsi: __u32, - pub flags: __u32, - pub resamplefd: __u32, - pub pad: [__u8; 16usize], +impl Default for kvm_coalesced_mmio_zone__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_zone__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_coalesced_mmio_zone__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_irqfd() { +fn bindgen_test_layout_kvm_coalesced_mmio_zone() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_irqfd)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio_zone)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_irqfd)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_coalesced_mmio_zone)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqfd), + stringify!(kvm_coalesced_mmio_zone), "::", - stringify!(fd) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gsi as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_irqfd), + stringify!(kvm_coalesced_mmio_zone), "::", - stringify!(gsi) + stringify!(size) + ) + ); +} +impl Default for kvm_coalesced_mmio_zone { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_zone { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_coalesced_mmio_zone {{ addr: {:?}, size: {:?}, __bindgen_anon_1: {:?} }}", + self.addr, self.size, self.__bindgen_anon_1 ) + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_coalesced_mmio { + pub phys_addr: __u64, + pub len: __u32, + pub __bindgen_anon_1: kvm_coalesced_mmio__bindgen_ty_1, + pub data: [__u8; 8usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_coalesced_mmio__bindgen_ty_1 { + pub pad: __u32, + pub pio: __u32, +} +#[test] +fn bindgen_test_layout_kvm_coalesced_mmio__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + ::std::mem::align_of::(), + 4usize, concat!( - "Offset of field: ", - stringify!(kvm_irqfd), - "::", - stringify!(flags) + "Alignment of ", + stringify!(kvm_coalesced_mmio__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).resamplefd as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqfd), + stringify!(kvm_coalesced_mmio__bindgen_ty_1), "::", - stringify!(resamplefd) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).pio) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_irqfd), + stringify!(kvm_coalesced_mmio__bindgen_ty_1), "::", - stringify!(pad) + stringify!(pio) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_clock_data { - pub clock: __u64, - pub flags: __u32, - pub pad: [__u32; 9usize], +impl Default for kvm_coalesced_mmio__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_coalesced_mmio__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_clock_data() { +fn bindgen_test_layout_kvm_coalesced_mmio() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_clock_data)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_clock_data)) + concat!("Alignment of ", stringify!(kvm_coalesced_mmio)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).clock as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).phys_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_clock_data), + stringify!(kvm_coalesced_mmio), "::", - stringify!(clock) + stringify!(phys_addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_clock_data), + stringify!(kvm_coalesced_mmio), "::", - stringify!(flags) + stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_clock_data), + stringify!(kvm_coalesced_mmio), "::", - stringify!(pad) + stringify!(data) ) ); } +impl Default for kvm_coalesced_mmio { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_coalesced_mmio {{ phys_addr: {:?}, len: {:?}, __bindgen_anon_1: {:?}, data: {:?} }}" , self . phys_addr , self . len , self . __bindgen_anon_1 , self . data) + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_config_tlb { - pub params: __u64, - pub array: __u64, - pub mmu_type: __u32, - pub array_len: __u32, +pub struct kvm_coalesced_mmio_ring { + pub first: __u32, + pub last: __u32, + pub coalesced_mmio: __IncompleteArrayField, } #[test] -fn bindgen_test_layout_kvm_config_tlb() { +fn bindgen_test_layout_kvm_coalesced_mmio_ring() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_config_tlb)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_coalesced_mmio_ring)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_config_tlb)) + concat!("Alignment of ", stringify!(kvm_coalesced_mmio_ring)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).params as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).first) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_config_tlb), + stringify!(kvm_coalesced_mmio_ring), "::", - stringify!(params) + stringify!(first) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).array as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).last) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_config_tlb), + stringify!(kvm_coalesced_mmio_ring), "::", - stringify!(array) + stringify!(last) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mmu_type as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).coalesced_mmio) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_config_tlb), + stringify!(kvm_coalesced_mmio_ring), "::", - stringify!(mmu_type) + stringify!(coalesced_mmio) ) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).array_len as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(kvm_config_tlb), - "::", - stringify!(array_len) +} +impl Default for kvm_coalesced_mmio_ring { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_coalesced_mmio_ring { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_coalesced_mmio_ring {{ first: {:?}, last: {:?}, coalesced_mmio: {:?} }}", + self.first, self.last, self.coalesced_mmio ) - ); + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_dirty_tlb { - pub bitmap: __u64, - pub num_dirty: __u32, +pub struct kvm_translation { + pub linear_address: __u64, + pub physical_address: __u64, + pub valid: __u8, + pub writeable: __u8, + pub usermode: __u8, + pub pad: [__u8; 5usize], } #[test] -fn bindgen_test_layout_kvm_dirty_tlb() { +fn bindgen_test_layout_kvm_translation() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_dirty_tlb)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_translation)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_tlb)) + concat!("Alignment of ", stringify!(kvm_translation)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bitmap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).linear_address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_tlb), + stringify!(kvm_translation), "::", - stringify!(bitmap) + stringify!(linear_address) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_dirty as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).physical_address) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_tlb), + stringify!(kvm_translation), "::", - stringify!(num_dirty) + stringify!(physical_address) ) ); -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct kvm_reg_list { - pub n: __u64, - pub reg: __IncompleteArrayField<__u64>, -} -#[test] -fn bindgen_test_layout_kvm_reg_list() { - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_reg_list)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_reg_list)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).n as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).valid) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_reg_list), + stringify!(kvm_translation), "::", - stringify!(n) + stringify!(valid) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reg as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).writeable) as usize - ptr as usize }, + 17usize, concat!( "Offset of field: ", - stringify!(kvm_reg_list), + stringify!(kvm_translation), "::", - stringify!(reg) + stringify!(writeable) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_one_reg { - pub id: __u64, - pub addr: __u64, -} -#[test] -fn bindgen_test_layout_kvm_one_reg() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_one_reg)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_one_reg)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).usermode) as usize - ptr as usize }, + 18usize, concat!( "Offset of field: ", - stringify!(kvm_one_reg), + stringify!(kvm_translation), "::", - stringify!(id) + stringify!(usermode) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 19usize, concat!( "Offset of field: ", - stringify!(kvm_one_reg), + stringify!(kvm_translation), "::", - stringify!(addr) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_msi { - pub address_lo: __u32, - pub address_hi: __u32, - pub data: __u32, - pub flags: __u32, - pub devid: __u32, - pub pad: [__u8; 12usize], +pub struct kvm_interrupt { + pub irq: __u32, } #[test] -fn bindgen_test_layout_kvm_msi() { +fn bindgen_test_layout_kvm_interrupt() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_msi)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_interrupt)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_msi)) + concat!("Alignment of ", stringify!(kvm_interrupt)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_lo as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irq) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_msi), - "::", - stringify!(address_lo) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).address_hi as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(kvm_msi), + stringify!(kvm_interrupt), "::", - stringify!(address_hi) + stringify!(irq) ) ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_dirty_log { + pub slot: __u32, + pub padding1: __u32, + pub __bindgen_anon_1: kvm_dirty_log__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_dirty_log__bindgen_ty_1 { + pub dirty_bitmap: *mut ::std::os::raw::c_void, + pub padding2: __u64, +} +#[test] +fn bindgen_test_layout_kvm_dirty_log__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, + ::std::mem::size_of::(), 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_msi), - "::", - stringify!(data) - ) + concat!("Size of: ", stringify!(kvm_dirty_log__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(kvm_msi), - "::", - stringify!(flags) - ) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_log__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).devid as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).dirty_bitmap) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_msi), + stringify!(kvm_dirty_log__bindgen_ty_1), "::", - stringify!(devid) + stringify!(dirty_bitmap) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding2) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_msi), + stringify!(kvm_dirty_log__bindgen_ty_1), "::", - stringify!(pad) + stringify!(padding2) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_arm_device_addr { - pub id: __u64, - pub addr: __u64, +impl Default for kvm_dirty_log__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_dirty_log__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_dirty_log__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_arm_device_addr() { +fn bindgen_test_layout_kvm_dirty_log() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 16usize, - concat!("Size of: ", stringify!(kvm_arm_device_addr)) + concat!("Size of: ", stringify!(kvm_dirty_log)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_arm_device_addr)) + concat!("Alignment of ", stringify!(kvm_dirty_log)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_arm_device_addr), + stringify!(kvm_dirty_log), "::", - stringify!(id) + stringify!(slot) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding1) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_arm_device_addr), + stringify!(kvm_dirty_log), "::", - stringify!(addr) + stringify!(padding1) ) ); } +impl Default for kvm_dirty_log { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_dirty_log { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_dirty_log {{ slot: {:?}, padding1: {:?}, __bindgen_anon_1: {:?} }}", + self.slot, self.padding1, self.__bindgen_anon_1 + ) + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_create_device { - pub type_: __u32, - pub fd: __u32, - pub flags: __u32, +#[derive(Copy, Clone)] +pub struct kvm_clear_dirty_log { + pub slot: __u32, + pub num_pages: __u32, + pub first_page: __u64, + pub __bindgen_anon_1: kvm_clear_dirty_log__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_clear_dirty_log__bindgen_ty_1 { + pub dirty_bitmap: *mut ::std::os::raw::c_void, + pub padding2: __u64, } #[test] -fn bindgen_test_layout_kvm_create_device() { - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(kvm_create_device)) - ); +fn bindgen_test_layout_kvm_clear_dirty_log__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_create_device)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_clear_dirty_log__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, + ::std::mem::align_of::(), + 8usize, concat!( - "Offset of field: ", - stringify!(kvm_create_device), - "::", - stringify!(type_) + "Alignment of ", + stringify!(kvm_clear_dirty_log__bindgen_ty_1) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).dirty_bitmap) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_create_device), + stringify!(kvm_clear_dirty_log__bindgen_ty_1), "::", - stringify!(fd) + stringify!(dirty_bitmap) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).padding2) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_create_device), + stringify!(kvm_clear_dirty_log__bindgen_ty_1), "::", - stringify!(flags) + stringify!(padding2) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_device_attr { - pub flags: __u32, - pub group: __u32, - pub attr: __u64, - pub addr: __u64, +impl Default for kvm_clear_dirty_log__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_clear_dirty_log__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_clear_dirty_log__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_device_attr() { +fn bindgen_test_layout_kvm_clear_dirty_log() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 24usize, - concat!("Size of: ", stringify!(kvm_device_attr)) + concat!("Size of: ", stringify!(kvm_clear_dirty_log)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_device_attr)) + concat!("Alignment of ", stringify!(kvm_clear_dirty_log)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_device_attr), + stringify!(kvm_clear_dirty_log), "::", - stringify!(flags) + stringify!(slot) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).group as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).num_pages) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_device_attr), + stringify!(kvm_clear_dirty_log), "::", - stringify!(group) + stringify!(num_pages) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).attr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).first_page) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_device_attr), - "::", - stringify!(attr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_device_attr), + stringify!(kvm_clear_dirty_log), "::", - stringify!(addr) + stringify!(first_page) ) ); } -pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20: kvm_device_type = 1; -pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_42: kvm_device_type = 2; -pub const kvm_device_type_KVM_DEV_TYPE_XICS: kvm_device_type = 3; -pub const kvm_device_type_KVM_DEV_TYPE_VFIO: kvm_device_type = 4; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2: kvm_device_type = 5; -pub const kvm_device_type_KVM_DEV_TYPE_FLIC: kvm_device_type = 6; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3: kvm_device_type = 7; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS: kvm_device_type = 8; -pub const kvm_device_type_KVM_DEV_TYPE_XIVE: kvm_device_type = 9; -pub const kvm_device_type_KVM_DEV_TYPE_ARM_PV_TIME: kvm_device_type = 10; -pub const kvm_device_type_KVM_DEV_TYPE_MAX: kvm_device_type = 11; -pub type kvm_device_type = ::std::os::raw::c_uint; +impl Default for kvm_clear_dirty_log { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_clear_dirty_log { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_clear_dirty_log {{ slot: {:?}, num_pages: {:?}, first_page: {:?}, __bindgen_anon_1: {:?} }}" , self . slot , self . num_pages , self . first_page , self . __bindgen_anon_1) + } +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_vfio_spapr_tce { - pub groupfd: __s32, - pub tablefd: __s32, +#[derive(Debug, Default)] +pub struct kvm_signal_mask { + pub len: __u32, + pub sigset: __IncompleteArrayField<__u8>, } #[test] -fn bindgen_test_layout_kvm_vfio_spapr_tce() { +fn bindgen_test_layout_kvm_signal_mask() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_vfio_spapr_tce)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_signal_mask)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_vfio_spapr_tce)) + concat!("Alignment of ", stringify!(kvm_signal_mask)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).groupfd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_vfio_spapr_tce), + stringify!(kvm_signal_mask), "::", - stringify!(groupfd) + stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tablefd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sigset) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_vfio_spapr_tce), + stringify!(kvm_signal_mask), "::", - stringify!(tablefd) + stringify!(sigset) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_ucas_mapping { - pub user_addr: __u64, - pub vcpu_addr: __u64, - pub length: __u64, +pub struct kvm_tpr_access_ctl { + pub enabled: __u32, + pub flags: __u32, + pub reserved: [__u32; 8usize], } #[test] -fn bindgen_test_layout_kvm_s390_ucas_mapping() { +fn bindgen_test_layout_kvm_tpr_access_ctl() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_s390_ucas_mapping)) + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(kvm_tpr_access_ctl)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_ucas_mapping)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_tpr_access_ctl)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).user_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).enabled) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ucas_mapping), + stringify!(kvm_tpr_access_ctl), "::", - stringify!(user_addr) + stringify!(enabled) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).vcpu_addr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ucas_mapping), + stringify!(kvm_tpr_access_ctl), "::", - stringify!(vcpu_addr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_ucas_mapping), + stringify!(kvm_tpr_access_ctl), "::", - stringify!(length) + stringify!(reserved) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_enc_region { - pub addr: __u64, - pub size: __u64, +pub struct kvm_vapic_addr { + pub vapic_addr: __u64, } #[test] -fn bindgen_test_layout_kvm_enc_region() { +fn bindgen_test_layout_kvm_vapic_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_enc_region)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_vapic_addr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_enc_region)) + concat!("Alignment of ", stringify!(kvm_vapic_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).vapic_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_enc_region), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_enc_region), + stringify!(kvm_vapic_addr), "::", - stringify!(size) + stringify!(vapic_addr) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_pv_sec_parm { - pub origin: __u64, - pub length: __u64, +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_mp_state { + pub mp_state: __u32, } #[test] -fn bindgen_test_layout_kvm_s390_pv_sec_parm() { +fn bindgen_test_layout_kvm_mp_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_s390_pv_sec_parm)) + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_mp_state)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_s390_pv_sec_parm)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_mp_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).origin as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mp_state) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_sec_parm), - "::", - stringify!(origin) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_s390_pv_sec_parm), + stringify!(kvm_mp_state), "::", - stringify!(length) + stringify!(mp_state) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_s390_pv_unp { - pub addr: __u64, - pub size: __u64, - pub tweak: __u64, +pub struct kvm_guest_debug { + pub control: __u32, + pub pad: __u32, + pub arch: kvm_guest_debug_arch, } #[test] -fn bindgen_test_layout_kvm_s390_pv_unp() { +fn bindgen_test_layout_kvm_guest_debug() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_s390_pv_unp)) + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(kvm_guest_debug)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_s390_pv_unp)) + concat!("Alignment of ", stringify!(kvm_guest_debug)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).control) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_unp), + stringify!(kvm_guest_debug), "::", - stringify!(addr) + stringify!(control) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_unp), + stringify!(kvm_guest_debug), "::", - stringify!(size) + stringify!(pad) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tweak as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).arch) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_s390_pv_unp), + stringify!(kvm_guest_debug), "::", - stringify!(tweak) + stringify!(arch) ) ); } -pub const pv_cmd_id_KVM_PV_ENABLE: pv_cmd_id = 0; -pub const pv_cmd_id_KVM_PV_DISABLE: pv_cmd_id = 1; -pub const pv_cmd_id_KVM_PV_SET_SEC_PARMS: pv_cmd_id = 2; -pub const pv_cmd_id_KVM_PV_UNPACK: pv_cmd_id = 3; -pub const pv_cmd_id_KVM_PV_VERIFY: pv_cmd_id = 4; -pub const pv_cmd_id_KVM_PV_PREP_RESET: pv_cmd_id = 5; -pub const pv_cmd_id_KVM_PV_UNSHARE_ALL: pv_cmd_id = 6; -pub type pv_cmd_id = ::std::os::raw::c_uint; +pub const kvm_ioeventfd_flag_nr_datamatch: _bindgen_ty_1 = 0; +pub const kvm_ioeventfd_flag_nr_pio: _bindgen_ty_1 = 1; +pub const kvm_ioeventfd_flag_nr_deassign: _bindgen_ty_1 = 2; +pub const kvm_ioeventfd_flag_nr_virtio_ccw_notify: _bindgen_ty_1 = 3; +pub const kvm_ioeventfd_flag_nr_fast_mmio: _bindgen_ty_1 = 4; +pub const kvm_ioeventfd_flag_nr_max: _bindgen_ty_1 = 5; +pub type _bindgen_ty_1 = ::std::os::raw::c_uint; #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_pv_cmd { - pub cmd: __u32, - pub rc: __u16, - pub rrc: __u16, - pub data: __u64, +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_ioeventfd { + pub datamatch: __u64, + pub addr: __u64, + pub len: __u32, + pub fd: __s32, pub flags: __u32, - pub reserved: [__u32; 3usize], + pub pad: [__u8; 36usize], } #[test] -fn bindgen_test_layout_kvm_pv_cmd() { +fn bindgen_test_layout_kvm_ioeventfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_pv_cmd)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_ioeventfd)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_pv_cmd)) + concat!("Alignment of ", stringify!(kvm_ioeventfd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cmd as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).datamatch) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(cmd) + stringify!(datamatch) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rc as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(rc) + stringify!(addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rrc as *const _ as usize }, - 6usize, + unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(rrc) + stringify!(len) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(data) + stringify!(fd) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 28usize, concat!( "Offset of field: ", - stringify!(kvm_pv_cmd), + stringify!(kvm_ioeventfd), "::", - stringify!(reserved) + stringify!(pad) ) ); } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_xen_hvm_attr { - pub type_: __u16, - pub pad: [__u16; 3usize], - pub u: kvm_xen_hvm_attr__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_xen_hvm_attr__bindgen_ty_1 { - pub long_mode: __u8, - pub vector: __u8, - pub shared_info: kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1, - pub pad: [__u64; 8usize], +impl Default for kvm_ioeventfd { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1 { - pub gfn: __u64, +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct kvm_enable_cap { + pub cap: __u32, + pub flags: __u32, + pub args: [__u64; 4usize], + pub pad: [__u8; 64usize], } #[test] -fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_enable_cap() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), + 104usize, + concat!("Size of: ", stringify!(kvm_enable_cap)) + ); + assert_eq!( + ::std::mem::align_of::(), 8usize, + concat!("Alignment of ", stringify!(kvm_enable_cap)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cap) as usize - ptr as usize }, + 0usize, concat!( - "Size of: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(cap) ) ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize }, 8usize, concat!( - "Alignment of ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_enable_cap), + "::", + stringify!(args) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gfn as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_enable_cap), "::", - stringify!(gfn) + stringify!(pad) ) ); } +impl Default for kvm_enable_cap { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_irqchip { + pub irqchip: __u32, + pub pin: __u32, +} #[test] -fn bindgen_test_layout_kvm_xen_hvm_attr__bindgen_ty_1() { +fn bindgen_test_layout_kvm_irq_routing_irqchip() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_xen_hvm_attr__bindgen_ty_1)) + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing_irqchip)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_hvm_attr__bindgen_ty_1)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_irqchip)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).long_mode as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).irqchip) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_irqchip), "::", - stringify!(long_mode) + stringify!(irqchip) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).vector as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).pin) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_irqchip), "::", - stringify!(vector) + stringify!(pin) ) ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_irq_routing_msi { + pub address_lo: __u32, + pub address_hi: __u32, + pub data: __u32, + pub __bindgen_anon_1: kvm_irq_routing_msi__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_routing_msi__bindgen_ty_1 { + pub pad: __u32, + pub devid: __u32, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing_msi__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).shared_info as *const _ - as usize - }, + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(kvm_irq_routing_msi__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(kvm_irq_routing_msi__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_msi__bindgen_ty_1), "::", - stringify!(shared_info) + stringify!(pad) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_msi__bindgen_ty_1), "::", - stringify!(pad) + stringify!(devid) ) ); } -impl Default for kvm_xen_hvm_attr__bindgen_ty_1 { +impl Default for kvm_irq_routing_msi__bindgen_ty_1 { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -11414,50 +11719,57 @@ impl Default for kvm_xen_hvm_attr__bindgen_ty_1 { } } } +impl ::std::fmt::Debug for kvm_irq_routing_msi__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_routing_msi__bindgen_ty_1 {{ union }}") + } +} #[test] -fn bindgen_test_layout_kvm_xen_hvm_attr() { - assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_xen_hvm_attr)) +fn bindgen_test_layout_kvm_irq_routing_msi() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_irq_routing_msi)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_hvm_attr)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_msi)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).address_lo) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr), + stringify!(kvm_irq_routing_msi), "::", - stringify!(type_) + stringify!(address_lo) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).address_hi) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr), + stringify!(kvm_irq_routing_msi), "::", - stringify!(pad) + stringify!(address_hi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_hvm_attr), + stringify!(kvm_irq_routing_msi), "::", - stringify!(u) + stringify!(data) ) ); } -impl Default for kvm_xen_hvm_attr { +impl Default for kvm_irq_routing_msi { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -11466,1598 +11778,1469 @@ impl Default for kvm_xen_hvm_attr { } } } -#[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_xen_vcpu_attr { - pub type_: __u16, - pub pad: [__u16; 3usize], - pub u: kvm_xen_vcpu_attr__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_xen_vcpu_attr__bindgen_ty_1 { - pub gpa: __u64, - pub pad: [__u64; 8usize], - pub runstate: kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1, +impl ::std::fmt::Debug for kvm_irq_routing_msi { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write ! (f , "kvm_irq_routing_msi {{ address_lo: {:?}, address_hi: {:?}, data: {:?}, __bindgen_anon_1: {:?} }}" , self . address_lo , self . address_hi , self . data , self . __bindgen_anon_1) + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1 { - pub state: __u64, - pub state_entry_time: __u64, - pub time_running: __u64, - pub time_runnable: __u64, - pub time_blocked: __u64, - pub time_offline: __u64, +pub struct kvm_irq_routing_s390_adapter { + pub ind_addr: __u64, + pub summary_addr: __u64, + pub ind_offset: __u64, + pub summary_offset: __u32, + pub adapter_id: __u32, } #[test] -fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1() { +fn bindgen_test_layout_kvm_irq_routing_s390_adapter() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!( - "Size of: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1) - ) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irq_routing_s390_adapter)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!( - "Alignment of ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1) - ) + concat!("Alignment of ", stringify!(kvm_irq_routing_s390_adapter)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).state - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ind_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(state) + stringify!(ind_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())) - .state_entry_time as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).summary_addr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(state_entry_time) + stringify!(summary_addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_running - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ind_offset) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(time_running) + stringify!(ind_offset) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_runnable - as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).summary_offset) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(time_runnable) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_blocked - as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(time_blocked) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).time_offline - as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(time_offline) - ) - ); -} -#[test] -fn bindgen_test_layout_kvm_xen_vcpu_attr__bindgen_ty_1() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_xen_vcpu_attr__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_xen_vcpu_attr__bindgen_ty_1)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).gpa as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), - "::", - stringify!(gpa) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pad as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(pad) + stringify!(summary_offset) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).runstate as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).adapter_id) as usize - ptr as usize }, + 28usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr__bindgen_ty_1), + stringify!(kvm_irq_routing_s390_adapter), "::", - stringify!(runstate) + stringify!(adapter_id) ) ); } -impl Default for kvm_xen_vcpu_attr__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_irq_routing_hv_sint { + pub vcpu: __u32, + pub sint: __u32, } #[test] -fn bindgen_test_layout_kvm_xen_vcpu_attr() { - assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_xen_vcpu_attr)) - ); +fn bindgen_test_layout_kvm_irq_routing_hv_sint() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::size_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_xen_vcpu_attr)) + concat!("Size of: ", stringify!(kvm_irq_routing_hv_sint)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_xen_vcpu_attr), - "::", - stringify!(type_) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_hv_sint)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, - 2usize, + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr), + stringify!(kvm_irq_routing_hv_sint), "::", - stringify!(pad) + stringify!(vcpu) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).u as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).sint) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_xen_vcpu_attr), + stringify!(kvm_irq_routing_hv_sint), "::", - stringify!(u) + stringify!(sint) ) ); } -impl Default for kvm_xen_vcpu_attr { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub const sev_cmd_id_KVM_SEV_INIT: sev_cmd_id = 0; -pub const sev_cmd_id_KVM_SEV_ES_INIT: sev_cmd_id = 1; -pub const sev_cmd_id_KVM_SEV_LAUNCH_START: sev_cmd_id = 2; -pub const sev_cmd_id_KVM_SEV_LAUNCH_UPDATE_DATA: sev_cmd_id = 3; -pub const sev_cmd_id_KVM_SEV_LAUNCH_UPDATE_VMSA: sev_cmd_id = 4; -pub const sev_cmd_id_KVM_SEV_LAUNCH_SECRET: sev_cmd_id = 5; -pub const sev_cmd_id_KVM_SEV_LAUNCH_MEASURE: sev_cmd_id = 6; -pub const sev_cmd_id_KVM_SEV_LAUNCH_FINISH: sev_cmd_id = 7; -pub const sev_cmd_id_KVM_SEV_SEND_START: sev_cmd_id = 8; -pub const sev_cmd_id_KVM_SEV_SEND_UPDATE_DATA: sev_cmd_id = 9; -pub const sev_cmd_id_KVM_SEV_SEND_UPDATE_VMSA: sev_cmd_id = 10; -pub const sev_cmd_id_KVM_SEV_SEND_FINISH: sev_cmd_id = 11; -pub const sev_cmd_id_KVM_SEV_RECEIVE_START: sev_cmd_id = 12; -pub const sev_cmd_id_KVM_SEV_RECEIVE_UPDATE_DATA: sev_cmd_id = 13; -pub const sev_cmd_id_KVM_SEV_RECEIVE_UPDATE_VMSA: sev_cmd_id = 14; -pub const sev_cmd_id_KVM_SEV_RECEIVE_FINISH: sev_cmd_id = 15; -pub const sev_cmd_id_KVM_SEV_GUEST_STATUS: sev_cmd_id = 16; -pub const sev_cmd_id_KVM_SEV_DBG_DECRYPT: sev_cmd_id = 17; -pub const sev_cmd_id_KVM_SEV_DBG_ENCRYPT: sev_cmd_id = 18; -pub const sev_cmd_id_KVM_SEV_CERT_EXPORT: sev_cmd_id = 19; -pub const sev_cmd_id_KVM_SEV_GET_ATTESTATION_REPORT: sev_cmd_id = 20; -pub const sev_cmd_id_KVM_SEV_SEND_CANCEL: sev_cmd_id = 21; -pub const sev_cmd_id_KVM_SEV_NR_MAX: sev_cmd_id = 22; -pub type sev_cmd_id = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_cmd { - pub id: __u32, - pub data: __u64, - pub error: __u32, - pub sev_fd: __u32, +pub struct kvm_irq_routing_xen_evtchn { + pub port: __u32, + pub vcpu: __u32, + pub priority: __u32, } #[test] -fn bindgen_test_layout_kvm_sev_cmd() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_sev_cmd)) - ); +fn bindgen_test_layout_kvm_irq_routing_xen_evtchn() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_cmd)) + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_irq_routing_xen_evtchn)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_cmd), - "::", - stringify!(id) - ) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irq_routing_xen_evtchn)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).data as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_xen_evtchn), "::", - stringify!(data) + stringify!(port) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).error as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).vcpu) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_xen_evtchn), "::", - stringify!(error) + stringify!(vcpu) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sev_fd as *const _ as usize }, - 20usize, + unsafe { ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_cmd), + stringify!(kvm_irq_routing_xen_evtchn), "::", - stringify!(sev_fd) + stringify!(priority) ) ); } #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_start { - pub handle: __u32, - pub policy: __u32, - pub dh_uaddr: __u64, - pub dh_len: __u32, - pub session_uaddr: __u64, - pub session_len: __u32, +#[derive(Copy, Clone)] +pub struct kvm_irq_routing_entry { + pub gsi: __u32, + pub type_: __u32, + pub flags: __u32, + pub pad: __u32, + pub u: kvm_irq_routing_entry__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_irq_routing_entry__bindgen_ty_1 { + pub irqchip: kvm_irq_routing_irqchip, + pub msi: kvm_irq_routing_msi, + pub adapter: kvm_irq_routing_s390_adapter, + pub hv_sint: kvm_irq_routing_hv_sint, + pub xen_evtchn: kvm_irq_routing_xen_evtchn, + pub pad: [__u32; 8usize], } #[test] -fn bindgen_test_layout_kvm_sev_launch_start() { +fn bindgen_test_layout_kvm_irq_routing_entry__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_sev_launch_start)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irq_routing_entry__bindgen_ty_1)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_start)) + concat!( + "Alignment of ", + stringify!(kvm_irq_routing_entry__bindgen_ty_1) + ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handle as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).irqchip) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(handle) + stringify!(irqchip) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).msi) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(policy) + stringify!(msi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dh_uaddr as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).adapter) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(dh_uaddr) + stringify!(adapter) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dh_len as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).hv_sint) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(dh_len) + stringify!(hv_sint) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_uaddr as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).xen_evtchn) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(session_uaddr) + stringify!(xen_evtchn) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_len as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_start), + stringify!(kvm_irq_routing_entry__bindgen_ty_1), "::", - stringify!(session_len) + stringify!(pad) ) ); } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_update_data { - pub uaddr: __u64, - pub len: __u32, +impl Default for kvm_irq_routing_entry__bindgen_ty_1 { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_entry__bindgen_ty_1 { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!(f, "kvm_irq_routing_entry__bindgen_ty_1 {{ union }}") + } } #[test] -fn bindgen_test_layout_kvm_sev_launch_update_data() { +fn bindgen_test_layout_kvm_irq_routing_entry() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_sev_launch_update_data)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_irq_routing_entry)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_update_data)) + concat!("Alignment of ", stringify!(kvm_irq_routing_entry)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).gsi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_update_data), + stringify!(kvm_irq_routing_entry), "::", - stringify!(uaddr) + stringify!(gsi) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_update_data), + stringify!(kvm_irq_routing_entry), "::", - stringify!(len) + stringify!(type_) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_secret { - pub hdr_uaddr: __u64, - pub hdr_len: __u32, - pub guest_uaddr: __u64, - pub guest_len: __u32, - pub trans_uaddr: __u64, - pub trans_len: __u32, -} -#[test] -fn bindgen_test_layout_kvm_sev_launch_secret() { - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_sev_launch_secret)) - ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_secret)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr_uaddr as *const _ as usize }, - 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irq_routing_entry), "::", - stringify!(hdr_uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hdr_len as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irq_routing_entry), "::", - stringify!(hdr_len) + stringify!(pad) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irq_routing_entry), "::", - stringify!(guest_uaddr) + stringify!(u) ) ); +} +impl Default for kvm_irq_routing_entry { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing_entry { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_routing_entry {{ gsi: {:?}, type: {:?}, flags: {:?}, pad: {:?}, u: {:?} }}", + self.gsi, self.type_, self.flags, self.pad, self.u + ) + } +} +#[repr(C)] +pub struct kvm_irq_routing { + pub nr: __u32, + pub flags: __u32, + pub entries: __IncompleteArrayField, +} +#[test] +fn bindgen_test_layout_kvm_irq_routing() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_irq_routing)) + ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).guest_len as *const _ as usize }, - 24usize, + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_irq_routing)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irq_routing), "::", - stringify!(guest_len) + stringify!(nr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_uaddr as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irq_routing), "::", - stringify!(trans_uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).trans_len as *const _ as usize }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_secret), + stringify!(kvm_irq_routing), "::", - stringify!(trans_len) + stringify!(entries) ) ); } +impl Default for kvm_irq_routing { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +impl ::std::fmt::Debug for kvm_irq_routing { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + write!( + f, + "kvm_irq_routing {{ nr: {:?}, flags: {:?}, entries: {:?} }}", + self.nr, self.flags, self.entries + ) + } +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_launch_measure { - pub uaddr: __u64, - pub len: __u32, +pub struct kvm_irqfd { + pub fd: __u32, + pub gsi: __u32, + pub flags: __u32, + pub resamplefd: __u32, + pub pad: [__u8; 16usize], } #[test] -fn bindgen_test_layout_kvm_sev_launch_measure() { +fn bindgen_test_layout_kvm_irqfd() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_sev_launch_measure)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_irqfd)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_launch_measure)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_irqfd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_measure), + stringify!(kvm_irqfd), "::", - stringify!(uaddr) + stringify!(fd) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).gsi) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_launch_measure), + stringify!(kvm_irqfd), "::", - stringify!(len) + stringify!(gsi) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_guest_status { - pub handle: __u32, - pub policy: __u32, - pub state: __u32, -} -#[test] -fn bindgen_test_layout_kvm_sev_guest_status() { - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(kvm_sev_guest_status)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_sev_guest_status)) - ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handle as *const _ as usize }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_guest_status), + stringify!(kvm_irqfd), "::", - stringify!(handle) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).resamplefd) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_guest_status), + stringify!(kvm_irqfd), "::", - stringify!(policy) + stringify!(resamplefd) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).state as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_guest_status), + stringify!(kvm_irqfd), "::", - stringify!(state) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_dbg { - pub src_uaddr: __u64, - pub dst_uaddr: __u64, - pub len: __u32, +#[cfg_attr( + feature = "serde", + derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) +)] +pub struct kvm_clock_data { + pub clock: __u64, + pub flags: __u32, + pub pad0: __u32, + pub realtime: __u64, + pub host_tsc: __u64, + pub pad: [__u32; 4usize], } #[test] -fn bindgen_test_layout_kvm_sev_dbg() { +fn bindgen_test_layout_kvm_clock_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_sev_dbg)) + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(kvm_clock_data)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_dbg)) + concat!("Alignment of ", stringify!(kvm_clock_data)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).clock) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_dbg), + stringify!(kvm_clock_data), "::", - stringify!(src_uaddr) + stringify!(clock) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst_uaddr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_dbg), + stringify!(kvm_clock_data), "::", - stringify!(dst_uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad0) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_dbg), + stringify!(kvm_clock_data), "::", - stringify!(len) + stringify!(pad0) ) ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_attestation_report { - pub mnonce: [__u8; 16usize], - pub uaddr: __u64, - pub len: __u32, -} -#[test] -fn bindgen_test_layout_kvm_sev_attestation_report() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(kvm_sev_attestation_report)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_attestation_report)) - ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mnonce as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).realtime) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_attestation_report), + stringify!(kvm_clock_data), "::", - stringify!(mnonce) + stringify!(realtime) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).uaddr as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).host_tsc) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_sev_attestation_report), + stringify!(kvm_clock_data), "::", - stringify!(uaddr) + stringify!(host_tsc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).len as *const _ as usize }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 32usize, concat!( "Offset of field: ", - stringify!(kvm_sev_attestation_report), + stringify!(kvm_clock_data), "::", - stringify!(len) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_send_start { - pub policy: __u32, - pub pdh_cert_uaddr: __u64, - pub pdh_cert_len: __u32, - pub plat_certs_uaddr: __u64, - pub plat_certs_len: __u32, - pub amd_certs_uaddr: __u64, - pub amd_certs_len: __u32, - pub session_uaddr: __u64, - pub session_len: __u32, +pub struct kvm_config_tlb { + pub params: __u64, + pub array: __u64, + pub mmu_type: __u32, + pub array_len: __u32, } #[test] -fn bindgen_test_layout_kvm_sev_send_start() { +fn bindgen_test_layout_kvm_config_tlb() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(kvm_sev_send_start)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_config_tlb)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_send_start)) + concat!("Alignment of ", stringify!(kvm_config_tlb)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_config_tlb), "::", - stringify!(policy) + stringify!(params) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).pdh_cert_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).array) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_config_tlb), "::", - stringify!(pdh_cert_uaddr) + stringify!(array) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdh_cert_len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mmu_type) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_config_tlb), "::", - stringify!(pdh_cert_len) + stringify!(mmu_type) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).plat_certs_uaddr as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).array_len) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_config_tlb), "::", - stringify!(plat_certs_uaddr) + stringify!(array_len) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_dirty_tlb { + pub bitmap: __u64, + pub num_dirty: __u32, +} +#[test] +fn bindgen_test_layout_kvm_dirty_tlb() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).plat_certs_len as *const _ as usize - }, - 32usize, + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_tlb)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_tlb)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bitmap) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_dirty_tlb), "::", - stringify!(plat_certs_len) + stringify!(bitmap) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).amd_certs_uaddr as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).num_dirty) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_dirty_tlb), "::", - stringify!(amd_certs_uaddr) + stringify!(num_dirty) ) ); +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct kvm_reg_list { + pub n: __u64, + pub reg: __IncompleteArrayField<__u64>, +} +#[test] +fn bindgen_test_layout_kvm_reg_list() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).amd_certs_len as *const _ as usize - }, - 48usize, + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_reg_list)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_reg_list)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).n) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_reg_list), "::", - stringify!(amd_certs_len) + stringify!(n) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reg) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_reg_list), + "::", + stringify!(reg) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_one_reg { + pub id: __u64, + pub addr: __u64, +} +#[test] +fn bindgen_test_layout_kvm_one_reg() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_one_reg)) + ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_uaddr as *const _ as usize - }, - 56usize, + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_one_reg)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_one_reg), "::", - stringify!(session_uaddr) + stringify!(id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).session_len as *const _ as usize }, - 64usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_start), + stringify!(kvm_one_reg), "::", - stringify!(session_len) + stringify!(addr) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_send_update_data { - pub hdr_uaddr: __u64, - pub hdr_len: __u32, - pub guest_uaddr: __u64, - pub guest_len: __u32, - pub trans_uaddr: __u64, - pub trans_len: __u32, +pub struct kvm_msi { + pub address_lo: __u32, + pub address_hi: __u32, + pub data: __u32, + pub flags: __u32, + pub devid: __u32, + pub pad: [__u8; 12usize], } #[test] -fn bindgen_test_layout_kvm_sev_send_update_data() { +fn bindgen_test_layout_kvm_msi() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_sev_send_update_data)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_msi)) ); assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(kvm_sev_send_update_data)) + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_msi)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).address_lo) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(hdr_uaddr) + stringify!(address_lo) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_len as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).address_hi) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(hdr_len) + stringify!(address_hi) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_uaddr as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(guest_uaddr) + stringify!(data) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_len as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(guest_len) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_uaddr as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).devid) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(trans_uaddr) + stringify!(devid) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_len as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_sev_send_update_data), + stringify!(kvm_msi), "::", - stringify!(trans_len) + stringify!(pad) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_receive_start { - pub handle: __u32, - pub policy: __u32, - pub pdh_uaddr: __u64, - pub pdh_len: __u32, - pub session_uaddr: __u64, - pub session_len: __u32, +pub struct kvm_arm_device_addr { + pub id: __u64, + pub addr: __u64, } #[test] -fn bindgen_test_layout_kvm_sev_receive_start() { +fn bindgen_test_layout_kvm_arm_device_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(kvm_sev_receive_start)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_arm_device_addr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_receive_start)) + concat!("Alignment of ", stringify!(kvm_arm_device_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).handle as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_arm_device_addr), "::", - stringify!(handle) + stringify!(id) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).policy as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_arm_device_addr), "::", - stringify!(policy) + stringify!(addr) ) ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_create_device { + pub type_: __u32, + pub fd: __u32, + pub flags: __u32, +} +#[test] +fn bindgen_test_layout_kvm_create_device() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdh_uaddr as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(kvm_sev_receive_start), - "::", - stringify!(pdh_uaddr) - ) + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(kvm_create_device)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pdh_len as *const _ as usize }, - 16usize, + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_create_device)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_create_device), "::", - stringify!(pdh_len) + stringify!(type_) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_uaddr as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_create_device), "::", - stringify!(session_uaddr) + stringify!(fd) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).session_len as *const _ as usize - }, - 32usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_start), + stringify!(kvm_create_device), "::", - stringify!(session_len) + stringify!(flags) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_sev_receive_update_data { - pub hdr_uaddr: __u64, - pub hdr_len: __u32, - pub guest_uaddr: __u64, - pub guest_len: __u32, - pub trans_uaddr: __u64, - pub trans_len: __u32, +pub struct kvm_device_attr { + pub flags: __u32, + pub group: __u32, + pub attr: __u64, + pub addr: __u64, } #[test] -fn bindgen_test_layout_kvm_sev_receive_update_data() { +fn bindgen_test_layout_kvm_device_attr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_sev_receive_update_data)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_device_attr)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_sev_receive_update_data)) + concat!("Alignment of ", stringify!(kvm_device_attr)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_uaddr as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(hdr_uaddr) + stringify!(flags) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hdr_len as *const _ as usize - }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).group) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(hdr_len) + stringify!(group) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_uaddr as *const _ as usize - }, - 16usize, + unsafe { ::std::ptr::addr_of!((*ptr).attr) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(guest_uaddr) + stringify!(attr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).guest_len as *const _ as usize - }, - 24usize, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_device_attr), "::", - stringify!(guest_len) + stringify!(addr) ) ); +} +pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20: kvm_device_type = 1; +pub const kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_42: kvm_device_type = 2; +pub const kvm_device_type_KVM_DEV_TYPE_XICS: kvm_device_type = 3; +pub const kvm_device_type_KVM_DEV_TYPE_VFIO: kvm_device_type = 4; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2: kvm_device_type = 5; +pub const kvm_device_type_KVM_DEV_TYPE_FLIC: kvm_device_type = 6; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3: kvm_device_type = 7; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_ITS: kvm_device_type = 8; +pub const kvm_device_type_KVM_DEV_TYPE_XIVE: kvm_device_type = 9; +pub const kvm_device_type_KVM_DEV_TYPE_ARM_PV_TIME: kvm_device_type = 10; +pub const kvm_device_type_KVM_DEV_TYPE_RISCV_AIA: kvm_device_type = 11; +pub const kvm_device_type_KVM_DEV_TYPE_MAX: kvm_device_type = 12; +pub type kvm_device_type = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_vfio_spapr_tce { + pub groupfd: __s32, + pub tablefd: __s32, +} +#[test] +fn bindgen_test_layout_kvm_vfio_spapr_tce() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(kvm_vfio_spapr_tce)) + ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_uaddr as *const _ as usize - }, - 32usize, + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(kvm_vfio_spapr_tce)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).groupfd) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_vfio_spapr_tce), "::", - stringify!(trans_uaddr) + stringify!(groupfd) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).trans_len as *const _ as usize - }, - 40usize, + unsafe { ::std::ptr::addr_of!((*ptr).tablefd) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(kvm_sev_receive_update_data), + stringify!(kvm_vfio_spapr_tce), "::", - stringify!(trans_len) + stringify!(tablefd) ) ); } #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_assigned_pci_dev { - pub assigned_dev_id: __u32, - pub busnr: __u32, - pub devfn: __u32, - pub flags: __u32, - pub segnr: __u32, - pub __bindgen_anon_1: kvm_assigned_pci_dev__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_assigned_pci_dev__bindgen_ty_1 { - pub reserved: [__u32; 11usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_enc_region { + pub addr: __u64, + pub size: __u64, } #[test] -fn bindgen_test_layout_kvm_assigned_pci_dev__bindgen_ty_1() { +fn bindgen_test_layout_kvm_enc_region() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 44usize, - concat!("Size of: ", stringify!(kvm_assigned_pci_dev__bindgen_ty_1)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_enc_region)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_enc_region)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, concat!( - "Alignment of ", - stringify!(kvm_assigned_pci_dev__bindgen_ty_1) + "Offset of field: ", + stringify!(kvm_enc_region), + "::", + stringify!(addr) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ - as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev__bindgen_ty_1), + stringify!(kvm_enc_region), "::", - stringify!(reserved) + stringify!(size) ) ); } -impl Default for kvm_assigned_pci_dev__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_dirty_gfn { + pub flags: __u32, + pub slot: __u32, + pub offset: __u64, } #[test] -fn bindgen_test_layout_kvm_assigned_pci_dev() { +fn bindgen_test_layout_kvm_dirty_gfn() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_assigned_pci_dev)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_dirty_gfn)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_pci_dev)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_dirty_gfn)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_dirty_gfn), "::", - stringify!(assigned_dev_id) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).busnr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_dirty_gfn), "::", - stringify!(busnr) + stringify!(slot) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).devfn as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_pci_dev), - "::", - stringify!(devfn) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(kvm_assigned_pci_dev), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).segnr as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(kvm_assigned_pci_dev), + stringify!(kvm_dirty_gfn), "::", - stringify!(segnr) + stringify!(offset) ) ); } -impl Default for kvm_assigned_pci_dev { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} +#[doc = " struct kvm_stats_header - Header of per vm/vcpu binary statistics data.\n @flags: Some extra information for header, always 0 for now.\n @name_size: The size in bytes of the memory which contains statistics\n name string including trailing '\\0'. The memory is allocated\n at the send of statistics descriptor.\n @num_desc: The number of statistics the vm or vcpu has.\n @id_offset: The offset of the vm/vcpu stats' id string in the file pointed\n by vm/vcpu stats fd.\n @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file\n pointd by vm/vcpu stats fd.\n @data_offset: The offset of the vm/vcpu stats' data block in the file\n pointed by vm/vcpu stats fd.\n\n This is the header userspace needs to read from stats fd before any other\n readings. It is used by userspace to discover all the information about the\n vm/vcpu's binary statistics.\n Userspace reads this header from the start of the vm/vcpu's stats fd."] #[repr(C)] -#[derive(Copy, Clone)] -pub struct kvm_assigned_irq { - pub assigned_dev_id: __u32, - pub host_irq: __u32, - pub guest_irq: __u32, +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct kvm_stats_header { pub flags: __u32, - pub __bindgen_anon_1: kvm_assigned_irq__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union kvm_assigned_irq__bindgen_ty_1 { - pub reserved: [__u32; 12usize], + pub name_size: __u32, + pub num_desc: __u32, + pub id_offset: __u32, + pub desc_offset: __u32, + pub data_offset: __u32, } #[test] -fn bindgen_test_layout_kvm_assigned_irq__bindgen_ty_1() { +fn bindgen_test_layout_kvm_stats_header() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(kvm_assigned_irq__bindgen_ty_1)) + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(kvm_stats_header)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_irq__bindgen_ty_1)) + concat!("Alignment of ", stringify!(kvm_stats_header)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).reserved as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq__bindgen_ty_1), + stringify!(kvm_stats_header), "::", - stringify!(reserved) + stringify!(flags) ) ); -} -impl Default for kvm_assigned_irq__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_kvm_assigned_irq() { - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(kvm_assigned_irq)) - ); assert_eq!( - ::std::mem::align_of::(), + unsafe { ::std::ptr::addr_of!((*ptr).name_size) as usize - ptr as usize }, 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_irq)) + concat!( + "Offset of field: ", + stringify!(kvm_stats_header), + "::", + stringify!(name_size) + ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, - 0usize, + unsafe { ::std::ptr::addr_of!((*ptr).num_desc) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(assigned_dev_id) + stringify!(num_desc) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).host_irq as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).id_offset) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(host_irq) + stringify!(id_offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).guest_irq as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).desc_offset) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(guest_irq) + stringify!(desc_offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).data_offset) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_irq), + stringify!(kvm_stats_header), "::", - stringify!(flags) + stringify!(data_offset) ) ); } -impl Default for kvm_assigned_irq { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} +#[doc = " struct kvm_stats_desc - Descriptor of a KVM statistics.\n @flags: Annotations of the stats, like type, unit, etc.\n @exponent: Used together with @flags to determine the unit.\n @size: The number of data items for this stats.\n Every data item is of type __u64.\n @offset: The offset of the stats to the start of stat structure in\n structure kvm or kvm_vcpu.\n @bucket_size: A parameter value used for histogram stats. It is only used\n\t\tfor linear histogram stats, specifying the size of the bucket;\n @name: The name string for the stats. Its size is indicated by the\n &kvm_stats_header->name_size."] #[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_assigned_msix_nr { - pub assigned_dev_id: __u32, - pub entry_nr: __u16, - pub padding: __u16, +#[derive(Debug, Default)] +pub struct kvm_stats_desc { + pub flags: __u32, + pub exponent: __s16, + pub size: __u16, + pub offset: __u32, + pub bucket_size: __u32, + pub name: __IncompleteArrayField<::std::os::raw::c_char>, } #[test] -fn bindgen_test_layout_kvm_assigned_msix_nr() { +fn bindgen_test_layout_kvm_stats_desc() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(kvm_assigned_msix_nr)) + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(kvm_stats_desc)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_msix_nr)) + concat!("Alignment of ", stringify!(kvm_stats_desc)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_nr), + stringify!(kvm_stats_desc), "::", - stringify!(assigned_dev_id) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entry_nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).exponent) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_nr), + stringify!(kvm_stats_desc), "::", - stringify!(entry_nr) + stringify!(exponent) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 6usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_nr), - "::", - stringify!(padding) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_assigned_msix_entry { - pub assigned_dev_id: __u32, - pub gsi: __u32, - pub entry: __u16, - pub padding: [__u16; 3usize], -} -#[test] -fn bindgen_test_layout_kvm_assigned_msix_entry() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_assigned_msix_entry)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_assigned_msix_entry)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).assigned_dev_id as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(assigned_dev_id) + stringify!(size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gsi as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(gsi) + stringify!(offset) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entry as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).bucket_size) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(entry) + stringify!(bucket_size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 10usize, + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_assigned_msix_entry), + stringify!(kvm_stats_desc), "::", - stringify!(padding) + stringify!(name) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_hyperv_eventfd { - pub conn_id: __u32, - pub fd: __s32, - pub flags: __u32, - pub padding: [__u32; 3usize], +pub struct kvm_memory_attributes { + pub address: __u64, + pub size: __u64, + pub attributes: __u64, + pub flags: __u64, } #[test] -fn bindgen_test_layout_kvm_hyperv_eventfd() { +fn bindgen_test_layout_kvm_memory_attributes() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(kvm_hyperv_eventfd)) + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(kvm_memory_attributes)) ); assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(kvm_hyperv_eventfd)) + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(kvm_memory_attributes)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).conn_id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(conn_id) + stringify!(address) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(fd) + stringify!(size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).attributes) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(flags) + stringify!(attributes) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).padding as *const _ as usize }, - 12usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 24usize, concat!( "Offset of field: ", - stringify!(kvm_hyperv_eventfd), + stringify!(kvm_memory_attributes), "::", - stringify!(padding) + stringify!(flags) ) ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct kvm_dirty_gfn { - pub flags: __u32, - pub slot: __u32, - pub offset: __u64, +pub struct kvm_create_guest_memfd { + pub size: __u64, + pub flags: __u64, + pub reserved: [__u64; 6usize], } #[test] -fn bindgen_test_layout_kvm_dirty_gfn() { +fn bindgen_test_layout_kvm_create_guest_memfd() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(kvm_dirty_gfn)) + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(kvm_create_guest_memfd)) ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(kvm_dirty_gfn)) + concat!("Alignment of ", stringify!(kvm_create_guest_memfd)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_gfn), + stringify!(kvm_create_guest_memfd), "::", - stringify!(flags) + stringify!(size) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot as *const _ as usize }, - 4usize, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_gfn), + stringify!(kvm_create_guest_memfd), "::", - stringify!(slot) + stringify!(flags) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 8usize, + unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(kvm_dirty_gfn), + stringify!(kvm_create_guest_memfd), "::", - stringify!(offset) + stringify!(reserved) ) ); } diff --git a/vendor/kvm-bindings/src/x86/fam_wrappers.rs b/vendor/kvm-bindings/src/x86_64/fam_wrappers.rs similarity index 60% rename from vendor/kvm-bindings/src/x86/fam_wrappers.rs rename to vendor/kvm-bindings/src/x86_64/fam_wrappers.rs index 9d397c3..fd4eee4 100644 --- a/vendor/kvm-bindings/src/x86/fam_wrappers.rs +++ b/vendor/kvm-bindings/src/x86_64/fam_wrappers.rs @@ -3,7 +3,7 @@ use vmm_sys_util::fam::{FamStruct, FamStructWrapper}; -use x86::bindings::*; +use x86_64::bindings::*; /// Maximum number of CPUID entries that can be returned by a call to KVM ioctls. /// @@ -94,10 +94,76 @@ impl PartialEq for kvm_msr_list { /// [FamStructWrapper](../vmm_sys_util/fam/struct.FamStructWrapper.html). pub type MsrList = FamStructWrapper; +/// Helper structure to treat post-5.17 [`kvm_xsave`] as a FamStruct. +/// +/// See also: [`Xsave`]. +#[repr(C)] +#[derive(Debug, Default)] +pub struct kvm_xsave2 { + /// The length, in bytes, of the FAM in [`kvm_xsave`]. + /// + /// Note that `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)` returns the size of the entire + /// `kvm_xsave` structure, e.g. the sum of header and FAM. Thus, this `len` field + /// is equal to `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) - 4096`. + pub len: usize, + pub xsave: kvm_xsave, +} + +// SAFETY: +// - `kvm_xsave2` is a POD +// - `kvm_xsave2` contains a flexible array member as its final field, due to `kvm_xsave` containing +// one, and being `repr(C)` +// - `Entry` is a POD +unsafe impl FamStruct for kvm_xsave2 { + type Entry = __u32; + + fn len(&self) -> usize { + self.len + } + + unsafe fn set_len(&mut self, len: usize) { + self.len = len; + } + + fn max_len() -> usize { + __u32::MAX as usize + } + + fn as_slice(&self) -> &[::Entry] { + let len = self.len(); + // SAFETY: By the invariants that the caller of `set_len` has to uphold, `len` matches + // the actual in-memory length of the FAM + unsafe { self.xsave.extra.as_slice(len) } + } + + fn as_mut_slice(&mut self) -> &mut [::Entry] { + let len = self.len(); + // SAFETY: By the invariants that the caller of `set_len` has to uphold, `len` matches + // the actual in-memory length of the FAM + unsafe { self.xsave.extra.as_mut_slice(len) } + } +} + +/// Wrapper over the post-5.17 [`kvm_xsave`] structure. +/// +/// In linux 5.17, kvm_xsave got turned into a FamStruct by adding the flexible "extra" member +/// to its definition. However, unlike all other such structs, it does not contain a "length" +/// field. Instead, the length of the flexible array member has to be determined by querying +/// the [`KVM_CAP_XSAVE2`] capability. This requires access to a VM file descriptor, and thus +/// cannot happen in the [`FamStruct::len`] trait method. To work around this, we define a wrapper +/// struct that caches the length of a previous `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)` call, +/// and implement [`FamStruct`] for this wrapper. Then in kvm-ioctls, we can expose a function +/// that first queries `KVM_CAP_XSAVE2`, then invokes [`KVM_GET_XSAVE2`] to retrives the `kvm_xsave` +/// structure, and finally combine them into the [`kvm_xsave2`] helper structure to be managed as a +/// `FamStruct`. +pub type Xsave = FamStructWrapper; + #[cfg(test)] mod tests { - use super::{CpuId, MsrList, Msrs}; - use x86::bindings::kvm_cpuid_entry2; + use super::{CpuId, MsrList, Msrs, Xsave}; + use x86_64::bindings::kvm_cpuid_entry2; + + use vmm_sys_util::fam::FamStruct; #[test] fn test_cpuid_eq() { @@ -120,10 +186,15 @@ mod tests { let mut wrapper2 = wrapper.clone(); assert!(wrapper == wrapper2); - - wrapper.as_mut_fam_struct().pad = 1; + // SAFETY: We are not modifying the `nmsrs` field + unsafe { + wrapper.as_mut_fam_struct().pad = 1; + } assert!(wrapper != wrapper2); - wrapper2.as_mut_fam_struct().pad = 1; + // SAFETY: We are not modifying the `nmsrs` field + unsafe { + wrapper2.as_mut_fam_struct().pad = 1; + } assert!(wrapper == wrapper2); wrapper.as_mut_slice()[1].data = 1; @@ -146,4 +217,11 @@ mod tests { wrapper2.as_mut_slice()[0] = 1; assert!(wrapper == wrapper2); } + #[test] + fn test_xsave() { + let wrapper = Xsave::new(1).unwrap(); + assert_eq!(wrapper.as_slice().len(), 1); + assert_eq!(wrapper.as_fam_struct_ref().len(), 1); + assert_eq!(wrapper.as_fam_struct_ref().len, 1); + } } diff --git a/vendor/kvm-bindings/src/x86_64/mod.rs b/vendor/kvm-bindings/src/x86_64/mod.rs new file mode 100644 index 0000000..08e1bab --- /dev/null +++ b/vendor/kvm-bindings/src/x86_64/mod.rs @@ -0,0 +1,14 @@ +// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +#[allow(clippy::undocumented_unsafe_blocks)] +#[allow(clippy::all)] +pub mod bindings; +#[cfg(feature = "fam-wrappers")] +pub mod fam_wrappers; + +#[cfg(feature = "serde")] +mod serialize; + +pub use self::bindings::*; +#[cfg(feature = "fam-wrappers")] +pub use self::fam_wrappers::*; diff --git a/vendor/kvm-bindings/src/x86_64/serialize.rs b/vendor/kvm-bindings/src/x86_64/serialize.rs new file mode 100644 index 0000000..4b3fe36 --- /dev/null +++ b/vendor/kvm-bindings/src/x86_64/serialize.rs @@ -0,0 +1,156 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +use bindings::{ + kvm_clock_data, kvm_cpuid2, kvm_cpuid_entry2, kvm_debugregs, kvm_dtable, kvm_irqchip, + kvm_irqchip__bindgen_ty_1, kvm_lapic_state, kvm_mp_state, kvm_msr_entry, kvm_msrs, + kvm_pit_channel_state, kvm_pit_state2, kvm_regs, kvm_segment, kvm_sregs, kvm_vcpu_events, + kvm_xcr, kvm_xcrs, kvm_xsave, +}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use zerocopy::{transmute, AsBytes, FromBytes, FromZeroes}; + +serde_impls!( + kvm_regs, + kvm_segment, + kvm_dtable, + kvm_sregs, + kvm_msr_entry, + kvm_cpuid_entry2, + kvm_pit_channel_state, + kvm_pit_state2, + kvm_vcpu_events, + kvm_debugregs, + kvm_xcr, + kvm_xcrs, + kvm_mp_state, + kvm_clock_data, + kvm_lapic_state, + kvm_msrs, + kvm_cpuid2, + kvm_xsave, + kvm_irqchip +); + +// SAFETY: zerocopy's derives explicitly disallow deriving for unions where +// the fields have different sizes, due to the smaller fields having padding. +// Miri however does not complain about these implementations (e.g. about +// reading the "padding" for one union field as valid data for a bigger one) +unsafe impl FromZeroes for kvm_irqchip__bindgen_ty_1 { + fn only_derive_is_allowed_to_implement_this_trait() + where + Self: Sized, + { + } +} + +// SAFETY: zerocopy's derives explicitly disallow deriving for unions where +// the fields have different sizes, due to the smaller fields having padding. +// Miri however does not complain about these implementations (e.g. about +// reading the "padding" for one union field as valid data for a bigger one) +unsafe impl FromBytes for kvm_irqchip__bindgen_ty_1 { + fn only_derive_is_allowed_to_implement_this_trait() + where + Self: Sized, + { + } +} + +// SAFETY: zerocopy's derives explicitly disallow deriving for unions where +// the fields have different sizes, due to the smaller fields having padding. +// Miri however does not complain about these implementations (e.g. about +// reading the "padding" for one union field as valid data for a bigger one) +unsafe impl AsBytes for kvm_irqchip__bindgen_ty_1 { + fn only_derive_is_allowed_to_implement_this_trait() + where + Self: Sized, + { + } +} + +#[cfg(test)] +mod tests { + use super::*; + use bindings::*; + + fn is_serde Deserialize<'de> + Default>() { + let serialized = bincode::serialize(&T::default()).unwrap(); + let deserialized = bincode::deserialize::(serialized.as_ref()).unwrap(); + let serialized_again = bincode::serialize(&deserialized).unwrap(); + // Compare the serialized state after a roundtrip, to work around issues with + // bindings not implementing `PartialEq`. + assert_eq!(serialized, serialized_again); + } + + #[test] + fn static_assert_serde_implementations() { + // This test statically (= at compile-time) asserts that various bindgen generated + // structures implement serde's `Serialize` and `Deserialize` traits. + // This is to make sure that we do not accidentally remove those implementations + // when regenerating bindings. If this test fails to compile, please add + // + // #[cfg_attr( + // feature = "serde", + // derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::FromZeroes) + // )] + // + // to all structures causing compilation errors (we need the zerocopy traits, as the + // `Serialize` and `Deserialize` implementations are provided by the `serde_impls!` macro + // above, which implements serialization based on zerocopy's `FromBytes` and `AsBytes` + // traits that it expects to be derived). + // + // NOTE: This only include "top-level" items, and does not list out bindgen-anonymous types + // (e.g. types like `kvm_vcpu_events__bindgen_ty_5`). These types can change name across + // bindgen versions. If after re-adding the derives to all the below items you can compile + // errors about anonymous types not implementing `Serialize`/`Deserialize`, please also add + // the derives to all anonymous types references in the definitions of the below items. + + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + is_serde::(); + } + + fn is_serde_json Deserialize<'de> + Default>() { + let serialized = serde_json::to_string(&T::default()).unwrap(); + let deserialized = serde_json::from_str::(serialized.as_ref()).unwrap(); + let serialized_again = serde_json::to_string(&deserialized).unwrap(); + // Compare the serialized state after a roundtrip, to work around issues with + // bindings not implementing `PartialEq`. + assert_eq!(serialized, serialized_again); + } + + #[test] + fn test_json_serde() { + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + is_serde_json::(); + } +} diff --git a/vendor/kvm-ioctls/.cargo-checksum.json b/vendor/kvm-ioctls/.cargo-checksum.json index 99c8773..9953ab5 100644 --- a/vendor/kvm-ioctls/.cargo-checksum.json +++ b/vendor/kvm-ioctls/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"836f769bf8baab397f24ad3d9daddc0a9570383e0fc262bfd7cc5505ceca2cf8","CODEOWNERS":"3db77159229a7245a1130bfe8636ba8a12806bb4589f23c15f68c6d036394f9b","Cargo.toml":"616f139019b40179d63ef8ac1630857a621e0baf80d1d5b9de306d01def3eece","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"6ae314acf8e015716cdfbed46fdc6ded0a599411b8b98cd61c87f9940f85ffc7","README.md":"fe70ffb039d3e5e7a229643407735558d95aaf6018e80368a607d6bdfabe9fb6","THIRD-PARTY":"a6d3ebd1c2f37d4fd83d0676621f695fc0cc2d8c6e646cdbb831b46e0650c208","build.rs":"9e07404d93cd2f4179028a061099992e67737558e75f80f3c7d3ca41c733aaed","coverage_config_aarch64.json":"2defd2846ef32131b20cfe4eaa1ec649cb5db59b6343c6bb4ec936780ab20c8d","coverage_config_x86_64.json":"0f48198a737dd4b4eea1d7ea20dbd663205d1ece3f9ad8d41a2e2f1be6b09282","src/cap.rs":"ca1976bdcc9dda968a9575050f1b1f390af0255c5a83167a6c348ea21a04818b","src/ioctls/device.rs":"6f7b10e0e1f20943990f525928b6bf8a19471e0488138993400fa9031d0765a5","src/ioctls/mod.rs":"4646a418c64faf1592539ea2807d72ebfaf76ef93ad4cbd978cc7059a1757726","src/ioctls/system.rs":"6e97a75558dc777198c9de2e8b19ee0a2afe3d7bd94894a4c05a26f11b8eb0a6","src/ioctls/vcpu.rs":"b374bfe01626c27fdffe8a1a8bd168a057edb2ca94f40bc66188aa7164496dac","src/ioctls/vm.rs":"bcd6c4428ac61810dc11f97f475590ec2490287cc18c4ebe292d84254da4c785","src/kvm_ioctls.rs":"bf1007e31224001c54b0173e13e350ac84794a2d2f86f8362062a6f0c42a6119","src/lib.rs":"f7b75bf1694dab48509e2d1034d3447f86270d5dae8706f47c00512d4fed9d86"},"package":"9bdde2b46ee7b6587ef79f751019c4726c4f2d3e4628df5d69f3f9c5cb6c6bd4"} \ No newline at end of file +{"files":{"CHANGELOG.md":"919de491099dcbf3ee4ad4f88d31f9357d11bac0c6ecce857268aca42b95a10c","CODEOWNERS":"aac8f130c705d49fae7d10f1852fa3077d94d7f18d0031d381c58a96588fa1ec","Cargo.toml":"2e3c9be524193be18551759becc413707ae5c7218771cc5a29c1232944596612","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"6ae314acf8e015716cdfbed46fdc6ded0a599411b8b98cd61c87f9940f85ffc7","README.md":"7dcd03b99cf6cf67b7aeb4477890ad498c6caaba88ba847bef8c9f7c4606dcdd","THIRD-PARTY":"a6d3ebd1c2f37d4fd83d0676621f695fc0cc2d8c6e646cdbb831b46e0650c208","build.rs":"b54b20e2cdb6edb0093a526ba6bdb0411ef9fe2b1366cb881d299a7d120936bb","coverage_config_aarch64.json":"2defd2846ef32131b20cfe4eaa1ec649cb5db59b6343c6bb4ec936780ab20c8d","coverage_config_x86_64.json":"d16a82b6a1c483fa0adfbd651f19b5c18fd2f802da63574b084ba7383a470ea0","src/cap.rs":"608dec81f08b946a8fcb81ab41f98fa6e160cb30ec51c1733b8159881fb83d0d","src/ioctls/device.rs":"aa97106ebe39df05a772a0f8dc9f110381451b7991c213e68f194e425b7c0afb","src/ioctls/mod.rs":"1b1fbd036173bf68ec2259afb14682084dec22c119f608cb1030d00dcb86db71","src/ioctls/system.rs":"b01b679ab12bf922d2ab8bd9b68a62c05c3ea707a388e0f995c74eab14688fc0","src/ioctls/vcpu.rs":"457b2d22655b2941818d55e432e5cf9605d52be16fc55faea993e49733a471fa","src/ioctls/vm.rs":"b960389204fc1b437719355f07b5b80f58466d1316cc38e91e8309104588a70c","src/kvm_ioctls.rs":"5446cb404310d99f2b64bcfd06313fdd590e2b2770bd140a7e9537781c273afc","src/lib.rs":"2ae6bbbdcdc6ffdfcaa2ba1e280b72d1044ebaaa79866d62f6edc739164b66c6"},"package":"e013ae7fcd2c6a8f384104d16afe7ea02969301ea2bb2a56e44b011ebc907cab"} \ No newline at end of file diff --git a/vendor/kvm-ioctls/CHANGELOG.md b/vendor/kvm-ioctls/CHANGELOG.md index 752408d..f46e5b6 100644 --- a/vendor/kvm-ioctls/CHANGELOG.md +++ b/vendor/kvm-ioctls/CHANGELOG.md @@ -1,12 +1,73 @@ -# Upcoming Release +# Changelog -## Added +## Upcoming Release -## Changed +## v0.19.1 -# v0.15.0 +### Fixed -## Added +- [[#298](https://github.com/rust-vmm/kvm/pull/298)]: Fixed incorrect usage of `ioctl_wit_ref` in the + `create_device` method. Replace it with `ioctl_wit_mut_ref` as the passed parameter may be mutated by the + ioctl. + +## v0.19.0 + +### Added + +- [[#275](https://github.com/rust-vmm/kvm-ioctls/pull/275)]: Introduce `riscv64` ioctls. + +### Removed + +- [[#289](https://github.com/rust-vmm/kvm-ioctls/pull/289)]: Drop `x86` 32-bit + and `arm` 32-bit support. + +### Changed + +- [[#273](https://github.com/rust-vmm/kvm-ioctls/pull/273)]: `DeviceFd::get_device_attr` is now + marked as unsafe. +- [[#277](https://github.com/rust-vmm/kvm-ioctls/pull/277)]: Updated kvm-bindings to 0.9.1. + +## v0.18.0 + +### Added + +- [[#264](https://github.com/rust-vmm/kvm-ioctls/pull/264)]: Added `KVM_SET_USER_MEMORY_REGION2`, + `KVM_CREATE_GUEST_MEMFD` and `KVM_SET_MEMORY_ATTRIBUTES` ioctls. +- [[#267](https://github.com/rust-vmm/kvm-ioctls/pull/267)]: Added `HypercallExit` field to + `VcpuExit::Hypercall` and added `ExitHypercall` to `Cap`. +- [[#270](https://github.com/rust-vmm/kvm-ioctls/pull/270)]: Added `MemoryFaultInfo` to `Cap` and + propagated `MemoryFault` exit reason in `KVM_RUN`. + +## v0.17.0 + +### Changed + +- [[#255](https://github.com/rust-vmm/kvm-ioctls/issues/255)]: Fixed a + soundness issue when accessing the `kvm_run` struct. `VcpuFd::run()` and + `VcpuFd::set_kvm_immediate_exit()` now take `&mut self` as a consequence. +- [[#260](https://github.com/rust-vmm/kvm-ioctls/pull/260)]: Updated kvm-bindings to 0.8.0. + +## v0.16.0 + +### Added +- [[#242](https://github.com/rust-vmm/kvm-ioctls/pull/242)] x86: add support + for SMI injection via `Vcpu::smi()` (`KVM_SMI` ioctl). +- [[#241](https://github.com/rust-vmm/kvm-ioctls/pull/241)] Add support for + userspace MSR handling. +- [[#246](https://github.com/rust-vmm/kvm-ioctls/pull/246)] Add support for + userspace NMI injection (`KVM_NMI` ioctl). +- [[#244](https://github.com/rust-vmm/kvm-ioctls/pull/244)] add support for + coalesced MMIO (`KVM_CAP_COALESCED_MMIO` / `KVM_CAP_COALESCED_PIO`) + +### Changed +- [[#234](https://github.com/rust-vmm/kvm-ioctls/issues/234)] vcpu: export +reg_size as a public method. +- [[#243](https://github.com/rust-vmm/kvm-ioctls/pull/243)] derived the `Copy` + trait for `IoEventAddress` and `NoDatamatch`. + +## v0.15.0 + +### Added - [[#230](https://github.com/rust-vmm/kvm-ioctls/pull/230)] Added `check_extension_raw` method to use raw integer values instead of `Cap` enum. @@ -15,36 +76,36 @@ support for vCPU SVE feature. - [[#219](https://github.com/rust-vmm/kvm-ioctls/pull/226)] Add `Cap::ArmPtrAuthAddress` and `Cap::ArmPtrAuthGeneric` capabilities. -# v0.14.0 +## v0.14.0 -## Added +### Added - [[#219](https://github.com/rust-vmm/kvm-ioctls/pull/219)] Support for `KVM_GET_MSR_FEATURE_INDEX_LIST` and `KVM_GET_MSRS` system ioctls. - [[#221](https://github.com/rust-vmm/kvm-ioctls/pull/221)] Add `Cap::ArmPmuV3`. - -## Changed + +### Changed - [[#223](https://github.com/rust-vmm/kvm-ioctls/pull/223)] aarch64: Updated `get/set_one_reg` to support different registers sizes through byte slices. -# v0.13.0 +## v0.13.0 -## Added +### Added - [[#213](https://github.com/rust-vmm/kvm-ioctls/pull/213)] Add `Kvm::new_with_path()` and `Kvm::open_with_cloexec_at()` to allow using kvm device files other than `/dev/kvm`. -# v0.12.0 +## v0.12.0 -## Added +### Added -- [[#187](https://github.com/rust-vmm/kvm-ioctls/pull/187)] Support for +- [[#187](https://github.com/rust-vmm/kvm-ioctls/pull/187)] Support for `KVM_SET_IDENTITY_MAP_ADDR` - Derive Debug for all exported structs and enums -- [[#189](https://github.com/rust-vmm/kvm-ioctls/pull/189)] Expose `KVM_SET_` and +- [[#189](https://github.com/rust-vmm/kvm-ioctls/pull/189)] Expose `KVM_SET_` and `KVM_HAS_DEVICE_ATTR` for vcpu - [[#191](https://github.com/rust-vmm/kvm-ioctls/pull/191)] Add `KVM_TRANSLATE` support and the `translate_gva` function that translates guest virtual address to the physical address @@ -59,7 +120,7 @@ support for vCPU SVE feature. - [[#202](https://github.com/rust-vmm/kvm-ioctls/pull/202)] Added `check_extension_int` which allows checking the capabilities that return numbers instead of booleans -## Changed +### Changed - Updated vmm-sys-util to 0.11.0 - Updated kvm-bindings to 0.6.0 @@ -69,14 +130,14 @@ support for vCPU SVE feature. - [[#195](https://github.com/rust-vmm/kvm-ioctls/pull/195)] Do not panic on unsupported `KVM_EXIT` reason - [[#196](https://github.com/rust-vmm/kvm-ioctls/pull/196)] Expose a mutable reference - to the `kvm_run` structure to allow proper handling of unsupported exit reasons + to the `kvm_run` structure to allow proper handling of unsupported exit reasons - [[#200](https://github.com/rust-vmm/kvm-ioctls/pull/200)] Fix wrong `target_arch` gate preventing `set_guest_debug` from being exported on ARM - [[#206](https://github.com/rust-vmm/kvm-ioctls/pull/206)] use `u128` in `get/set_on_reg` -# v0.11.0 +## v0.11.0 -## Added +### Added - [[#178](https://github.com/rust-vmm/kvm-ioctls/pull/178)] Support for the AMD Security Encrypted Virtualization (SEV) through the following VM ioctls: `encrypt_op`, `encrypt_op_sev`, `register_enc_memory_region` and @@ -84,54 +145,54 @@ support for vCPU SVE feature. - [[#184](https://github.com/rust-vmm/kvm-ioctls/pull/184)] `DeviceFd` now derives `Debug`. -# v0.10.0 +## v0.10.0 -## Changed +### Changed - Now depends on kvm-bindings >=0.5.0 which replaced the v4.20 KVM bindings with the v5.13 ones. - Updated `VcpuExit::Debug` to return architecture specific information for the debug event. -# v0.9.0 +## v0.9.0 -## Added +### Added - Support for accessing and controlling the Time Stamp Counter on x86 platforms through the `get_tsc_khz` and `set_tsc_khz` functions. -## Changed +### Changed - Updated `create_vm` on `aarch64` to create a VM fd from the KVM fd using the host's maximum IPA size. -# v0.8.0 +## v0.8.0 -## Added +### Added - Support for specifying VM type (an opaque platform and architecture specific constant) when creating a VM (`KVM_CREATE_VM` ioctl) via the `Kvm::create_vm_with_type` function. -## Changed +### Changed - Now depends on kvm-bindings >=0.4.0 to support use of a newer vmm-sys-utils dependency. -# v0.7.0 +## v0.7.0 -## Added +### Added - Support for the system API that returns the maximum allowed vCPU ID (`KVM_CAP_MAX_VCPU_ID`). - Support for `KVM_MEMORY_ENCRYPT_OP`. -## Fixed +### Fixed - [[#119](https://github.com/rust-vmm/kvm-ioctls/issues/119)]: Disallow invalid number of cpuid entries to be passed to `get_supported_cpuid` and `get_emulated_cpuid`. -## Changed +### Changed - [[#123](https://github.com/rust-vmm/kvm-ioctls/issues/123)]: Updated `create_vcpu` to use `u64` as the parameter for the number of vCPUs. -# v0.6.0 +## v0.6.0 -## Added +### Added - Support for the vcpu ioctls: `KVM_SET_GUEST_DEBUG`, `KVM_KVMCLOCK_CTRL`, and `KVM_GET_REG_LIST`. - Support for the vm ioctl `KVM_GET_DEVICE_ATTR`. @@ -144,31 +205,31 @@ support for vCPU SVE feature. - Support for checking the VM capabilities via `Vm::check_extension`. - Create a VM with flexible IPA size using `Kvm::create_vm_with_ipa_size`. -## Removed +### Removed - Removed `Kvm::new_with_fd_number`. The same functionality is offered by the `Kvm` [FromRawFd](https://doc.rust-lang.org/std/os/unix/io/trait.FromRawFd.html) trait implementation. -## Changed +### Changed - The VM ioctl `unregister_ioevent` now correctly unregisters the events that correspond to the data match passed as a parameter. - The `SystemEvent` Vcpu Exit now also contains the relevant type and flags. - Updated `get_dirty_log` such that it does not assume the page size is 4K, but instead reads it using `libc::sysconf`. -# v0.5.0 +## v0.5.0 -## Added +### Added - Support for the vcpu ioctls `KVM_GET/SET_VCPU_EVENTS` and `KVM_GET_DIRTY_LOG` on `aarch64`. - Support for the vcpu ioctl `KVM_IRQ_LINE`. -# v0.4.0 +## v0.4.0 -## Added +### Added - Support for unregistering ioeventfds through `KVM_IOEVENTFD`. -## Changed +### Changed - Functions working with event FDs now require vmm_sys_util::eventfd::EventFd in their interface instead of RawFd. @@ -182,15 +243,15 @@ support for vCPU SVE feature. not have to use kvm_ioctls::Result outside the crate. - kvm_ioctls::Error now works with errno::Error instead of io::Error. -## Removed +### Removed - CpuId safe wrapper over FAM struct kvm_cpuid2. The safe wrapper is now provided by the kvm_bindings crate starting with v0.2.0. - KVM_MAX_MSR_ENTRIES and MAX_KVM_CPUID_ENTRIES. Equivalent constants are provided by the kvm_bindings crate starting with v0.2.0. -# v0.3.0 +## v0.3.0 -## Added +### Added - Support for setting vcpu `kvm_immediate_exit` flag - Support for the vcpu ioctl `KVM_GET_CPUID2` - Support for the vcpu ioctl `KVM_GET_MP_STATE` @@ -211,23 +272,23 @@ support for vCPU SVE feature. - Support for the vm ioctl `KVM_SET_PIT2` - Support for the vcpu ioctl `KVM_GET_ONE_REG` -## Changed +### Changed - Function offering support for `KVM_SET_MSRS` also returns the number of MSR entries successfully written. -# v0.2.0 +## v0.2.0 -## Added +### Added - Add support for `KVM_ENABLE_CAP`. - Add support for `KVM_SIGNAL_MSI`. -## Fixed +### Fixed - Fix bug in KvmRunWrapper. The memory for kvm_run struct was not unmapped after the KvmRunWrapper object got out of scope. - Return proper value when receiving the EOI KVM exit. - Mark set_user_memory_region as unsafe. -# v0.1.0 +## v0.1.0 First release of the kvm-ioctls crate. diff --git a/vendor/kvm-ioctls/CODEOWNERS b/vendor/kvm-ioctls/CODEOWNERS index 9649f2d..064bfa2 100644 --- a/vendor/kvm-ioctls/CODEOWNERS +++ b/vendor/kvm-ioctls/CODEOWNERS @@ -1,3 +1,3 @@ # These owners will be the default owners for everything in # the repo. -* @acatangiu @aghecenco @andreeaflorescu @lauralt @sameo @roypat @JonathanWoollett-Light +* @acatangiu @aghecenco @andreeaflorescu @lauralt @sameo @roypat @ShadowCurse diff --git a/vendor/kvm-ioctls/Cargo.toml b/vendor/kvm-ioctls/Cargo.toml index a60571a..5b858b6 100644 --- a/vendor/kvm-ioctls/Cargo.toml +++ b/vendor/kvm-ioctls/Cargo.toml @@ -12,23 +12,36 @@ [package] edition = "2021" name = "kvm-ioctls" -version = "0.15.0" +version = "0.19.1" authors = ["Amazon Firecracker Team "] +build = "build.rs" +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false description = "Safe wrappers over KVM ioctls" readme = "README.md" keywords = ["kvm"] license = "Apache-2.0 OR MIT" repository = "https://github.com/rust-vmm/kvm-ioctls" +[lib] +name = "kvm_ioctls" +path = "src/lib.rs" + +[dependencies.bitflags] +version = "2.4.1" + [dependencies.kvm-bindings] -version = "0.6.0" +version = "0.10.0" features = ["fam-wrappers"] [dependencies.libc] version = "0.2.39" [dependencies.vmm-sys-util] -version = "0.11.0" +version = "0.12.1" [dev-dependencies.byteorder] version = "1.2.1" diff --git a/vendor/kvm-ioctls/README.md b/vendor/kvm-ioctls/README.md index faedf93..2b4a5fd 100644 --- a/vendor/kvm-ioctls/README.md +++ b/vendor/kvm-ioctls/README.md @@ -18,10 +18,7 @@ as the code documentation. ## Supported Platforms -The kvm-ioctls can be used on x86_64 and aarch64. Right now the aarch64 support -is considered experimental. For a production ready version, please check the -progress in the corresponding -[GitHub issue](https://github.com/rust-vmm/kvm-ioctls/issues/8). +The kvm-ioctls can be used on x86_64, aarch64 and riscv64 (experimental). ## Running the tests @@ -31,14 +28,16 @@ For the complete list of tests, check our [CI pipeline](https://buildkite.com/rust-vmm/kvm-ioctls-ci). Each individual test runs in a container. To reproduce a test locally, you can -use the dev-container on both x86 and arm64. +use the dev-container on x86_64, arm64 and riscv64. ```bash +# For running riscv64 tests, replace v47 with v47-riscv. This provides an +# emulated riscv64 environment on a x86_64 host. docker run --device=/dev/kvm \ -it \ --security-opt seccomp=unconfined \ --volume $(pwd)/kvm-ioctls:/kvm-ioctls \ - rustvmm/dev:v16 + rustvmm/dev:v47 cd kvm-ioctls/ cargo test ``` diff --git a/vendor/kvm-ioctls/build.rs b/vendor/kvm-ioctls/build.rs index 60b655a..067a65d 100644 --- a/vendor/kvm-ioctls/build.rs +++ b/vendor/kvm-ioctls/build.rs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT fn main() { + // Add `has_sev` to expected attributes. + println!("cargo:rustc-check-cfg=cfg(has_sev)"); // Define a `has_sev` attribute, which is used for conditional // execution of SEV-specific tests and examples. if std::path::Path::new("/dev/sev").exists() { diff --git a/vendor/kvm-ioctls/coverage_config_x86_64.json b/vendor/kvm-ioctls/coverage_config_x86_64.json index 2ab10dd..08c0327 100644 --- a/vendor/kvm-ioctls/coverage_config_x86_64.json +++ b/vendor/kvm-ioctls/coverage_config_x86_64.json @@ -1,5 +1,5 @@ { - "coverage_score": 84.6, + "coverage_score": 92.61, "exclude_path": "", "crate_features": "" } diff --git a/vendor/kvm-ioctls/src/cap.rs b/vendor/kvm-ioctls/src/cap.rs index 99c5c16..617c2a9 100644 --- a/vendor/kvm-ioctls/src/cap.rs +++ b/vendor/kvm-ioctls/src/cap.rs @@ -41,33 +41,29 @@ pub enum Cap { Iommu = KVM_CAP_IOMMU, DestroyMemoryRegionWorks = KVM_CAP_DESTROY_MEMORY_REGION_WORKS, UserNmi = KVM_CAP_USER_NMI, + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "s390x"))] SetGuestDebug = KVM_CAP_SET_GUEST_DEBUG, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] ReinjectControl = KVM_CAP_REINJECT_CONTROL, IrqRouting = KVM_CAP_IRQ_ROUTING, IrqInjectStatus = KVM_CAP_IRQ_INJECT_STATUS, AssignDevIrq = KVM_CAP_ASSIGN_DEV_IRQ, JoinMemoryRegionsWorks = KVM_CAP_JOIN_MEMORY_REGIONS_WORKS, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] Mce = KVM_CAP_MCE, Irqfd = KVM_CAP_IRQFD, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] Pit2 = KVM_CAP_PIT2, SetBootCpuId = KVM_CAP_SET_BOOT_CPU_ID, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] PitState2 = KVM_CAP_PIT_STATE2, Ioeventfd = KVM_CAP_IOEVENTFD, SetIdentityMapAddr = KVM_CAP_SET_IDENTITY_MAP_ADDR, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] XenHvm = KVM_CAP_XEN_HVM, AdjustClock = KVM_CAP_ADJUST_CLOCK, InternalErrorData = KVM_CAP_INTERNAL_ERROR_DATA, - #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" - ))] + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] VcpuEvents = KVM_CAP_VCPU_EVENTS, S390Psw = KVM_CAP_S390_PSW, PpcSegstate = KVM_CAP_PPC_SEGSTATE, @@ -77,15 +73,15 @@ pub enum Cap { PciSegment = KVM_CAP_PCI_SEGMENT, PpcPairedSingles = KVM_CAP_PPC_PAIRED_SINGLES, IntrShadow = KVM_CAP_INTR_SHADOW, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] Debugregs = KVM_CAP_DEBUGREGS, X86RobustSinglestep = KVM_CAP_X86_ROBUST_SINGLESTEP, PpcOsi = KVM_CAP_PPC_OSI, PpcUnsetIrq = KVM_CAP_PPC_UNSET_IRQ, EnableCap = KVM_CAP_ENABLE_CAP, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] Xsave = KVM_CAP_XSAVE, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] Xcrs = KVM_CAP_XCRS, PpcGetPvinfo = KVM_CAP_PPC_GET_PVINFO, PpcIrqLevel = KVM_CAP_PPC_IRQ_LEVEL, @@ -138,7 +134,9 @@ pub enum Cap { PpcEnableHcall = KVM_CAP_PPC_ENABLE_HCALL, CheckExtensionVm = KVM_CAP_CHECK_EXTENSION_VM, S390UserSigp = KVM_CAP_S390_USER_SIGP, - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] + X86Smm = KVM_CAP_X86_SMM, + #[cfg(target_arch = "x86_64")] SplitIrqchip = KVM_CAP_SPLIT_IRQCHIP, ArmPmuV3 = KVM_CAP_ARM_PMU_V3, ImmediateExit = KVM_CAP_IMMEDIATE_EXIT, @@ -149,10 +147,17 @@ pub enum Cap { DebugHwBps = KVM_CAP_GUEST_DEBUG_HW_BPS, DebugHwWps = KVM_CAP_GUEST_DEBUG_HW_WPS, GetMsrFeatures = KVM_CAP_GET_MSR_FEATURES, + CoalescedPio = KVM_CAP_COALESCED_PIO, #[cfg(target_arch = "aarch64")] ArmSve = KVM_CAP_ARM_SVE, - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] ArmPtrAuthAddress = KVM_CAP_ARM_PTRAUTH_ADDRESS, - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] ArmPtrAuthGeneric = KVM_CAP_ARM_PTRAUTH_GENERIC, + #[cfg(target_arch = "x86_64")] + X86UserSpaceMsr = KVM_CAP_X86_USER_SPACE_MSR, + #[cfg(target_arch = "x86_64")] + ExitHypercall = KVM_CAP_EXIT_HYPERCALL, + #[cfg(target_arch = "x86_64")] + MemoryFaultInfo = KVM_CAP_MEMORY_FAULT_INFO, } diff --git a/vendor/kvm-ioctls/src/ioctls/device.rs b/vendor/kvm-ioctls/src/ioctls/device.rs index 6669570..fc13104 100644 --- a/vendor/kvm-ioctls/src/ioctls/device.rs +++ b/vendor/kvm-ioctls/src/ioctls/device.rs @@ -1,3 +1,5 @@ +// Copyright © 2024 Institute of Software, CAS. All rights reserved. +// // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT @@ -41,36 +43,46 @@ impl DeviceFd { /// /// # Example /// + /// Configuring a VFIO device using `set_device_attr`. Note that VFIO + /// devices are not yet available on RISC-V The patch for QEMU: + /// https://lore.kernel.org/all/20240903201633.93182-1-dbarboza@ventanamicro.com/ + /// and patch for linux kernel + /// https://github.com/ventanamicro/linux/tree/dev-upstream are both not + /// upstreamed. Disabling VFIO device test for RISC-V at the time being. + /// /// ```rust /// # extern crate kvm_ioctls; /// # extern crate kvm_bindings; /// # use kvm_ioctls::Kvm; - /// # use kvm_bindings::{ - /// kvm_device_type_KVM_DEV_TYPE_VFIO, - /// KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD, KVM_CREATE_DEVICE_TEST - /// }; /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// - /// let mut device = kvm_bindings::kvm_create_device { - /// type_: kvm_device_type_KVM_DEV_TYPE_VFIO, - /// fd: 0, - /// flags: KVM_CREATE_DEVICE_TEST, - /// }; + /// #[cfg(not(target_arch = "riscv64"))] + /// { + /// # use kvm_bindings::{ + /// # kvm_device_type_KVM_DEV_TYPE_VFIO, + /// # KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD, KVM_CREATE_DEVICE_TEST + /// # }; + /// let mut device = kvm_bindings::kvm_create_device { + /// type_: kvm_device_type_KVM_DEV_TYPE_VFIO, + /// fd: 0, + /// flags: KVM_CREATE_DEVICE_TEST, + /// }; /// - /// let device_fd = vm - /// .create_device(&mut device) - /// .expect("Cannot create KVM device"); + /// let device_fd = vm + /// .create_device(&mut device) + /// .expect("Cannot create KVM device"); /// - /// let dist_attr = kvm_bindings::kvm_device_attr { - /// group: KVM_DEV_VFIO_GROUP, - /// attr: u64::from(KVM_DEV_VFIO_GROUP_ADD), - /// addr: 0x0, - /// flags: 0, - /// }; + /// let dist_attr = kvm_bindings::kvm_device_attr { + /// group: KVM_DEV_VFIO_GROUP, + /// attr: u64::from(KVM_DEV_VFIO_GROUP_ADD), + /// addr: 0x0, + /// flags: 0, + /// }; /// - /// if (device_fd.has_device_attr(&dist_attr).is_ok()) { - /// device_fd.set_device_attr(&dist_attr).unwrap(); + /// if (device_fd.has_device_attr(&dist_attr).is_ok()) { + /// device_fd.set_device_attr(&dist_attr).unwrap(); + /// } /// } /// ``` pub fn set_device_attr(&self, device_attr: &kvm_device_attr) -> Result<()> { @@ -102,6 +114,11 @@ impl DeviceFd { /// * `device_attr` - The `addr` field of the `device_attr` structure will point to /// the device attribute data. /// + /// # Safety + /// + /// The caller is responsible for the validity of the `device_attr` argument, + /// including that it is safe to write to the `addr` member. + /// /// # Examples /// ```rust /// # extern crate kvm_ioctls; @@ -138,14 +155,16 @@ impl DeviceFd { /// let mut data: u32 = 0; /// let mut gic_attr = kvm_bindings::kvm_device_attr::default(); /// gic_attr.group = KVM_DEV_ARM_VGIC_GRP_NR_IRQS; - /// gic_attr.addr = &mut data as *const u32 as u64; + /// gic_attr.addr = &mut data as *mut u32 as u64; /// - /// device_fd.get_device_attr(&mut gic_attr).unwrap(); + /// // SAFETY: gic_attr.addr is safe to write to. + /// unsafe { device_fd.get_device_attr(&mut gic_attr) }.unwrap(); /// } /// ``` - pub fn get_device_attr(&self, device_attr: &mut kvm_device_attr) -> Result<()> { - // SAFETY: We are calling this function with a Device fd, and we trust the kernel. - let ret = unsafe { ioctl_with_mut_ref(self, KVM_GET_DEVICE_ATTR(), device_attr) }; + pub unsafe fn get_device_attr(&self, device_attr: &mut kvm_device_attr) -> Result<()> { + // SAFETY: Caller has ensured device_attr.addr is safe to write to. + // We are calling this function with a Device fd, we trust the kernel. + let ret = ioctl_with_mut_ref(self, KVM_GET_DEVICE_ATTR(), device_attr); if ret != 0 { return Err(errno::Error::last()); } @@ -183,21 +202,18 @@ mod tests { #![allow(clippy::undocumented_unsafe_blocks)] use super::*; use crate::ioctls::system::Kvm; - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] use kvm_bindings::{ kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3, kvm_device_type_KVM_DEV_TYPE_VFIO, KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD, }; #[cfg(target_arch = "aarch64")] - use kvm_bindings::{ - KVM_DEV_ARM_VGIC_CTRL_INIT, KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_VFIO_GROUP, - KVM_DEV_VFIO_GROUP_ADD, - }; + use kvm_bindings::{KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD}; use kvm_bindings::KVM_CREATE_DEVICE_TEST; #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_create_device() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); @@ -208,7 +224,7 @@ mod tests { flags: KVM_CREATE_DEVICE_TEST, }; // This fails on x86_64 because there is no VGIC there. - assert!(vm.create_device(&mut gic_device).is_err()); + vm.create_device(&mut gic_device).unwrap_err(); gic_device.type_ = kvm_device_type_KVM_DEV_TYPE_VFIO; @@ -233,16 +249,16 @@ mod tests { // We are just creating a test device. Creating a real device would make the CI dependent // on host configuration (like having /dev/vfio). We expect this to fail. - assert!(device_fd.has_device_attr(&dist_attr).is_err()); - assert!(device_fd.get_device_attr(&mut dist_attr_mut).is_err()); - assert!(device_fd.set_device_attr(&dist_attr).is_err()); + device_fd.has_device_attr(&dist_attr).unwrap_err(); + unsafe { device_fd.get_device_attr(&mut dist_attr_mut) }.unwrap_err(); + device_fd.set_device_attr(&dist_attr).unwrap_err(); assert_eq!(errno::Error::last().errno(), 25); } #[test] #[cfg(target_arch = "aarch64")] fn test_create_device() { - use crate::ioctls::vm::{create_gic_device, set_supported_nr_irqs}; + use crate::ioctls::vm::{create_gic_device, request_gic_init, set_supported_nr_irqs}; use kvm_bindings::{ kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, }; @@ -258,7 +274,7 @@ mod tests { }; // This fails on aarch64 as it does not use MPIC (MultiProcessor Interrupt Controller), // it uses the VGIC. - assert!(vm.create_device(&mut gic_device).is_err()); + vm.create_device(&mut gic_device).unwrap_err(); let device_fd = create_gic_device(&vm, 0); @@ -279,21 +295,13 @@ mod tests { addr: 0x0, flags: 0, }; - assert!(device_fd.has_device_attr(&dist_attr).is_err()); + device_fd.has_device_attr(&dist_attr).unwrap_err(); // Set maximum supported number of IRQs of the vGIC device to 128. set_supported_nr_irqs(&device_fd, 128); - // Following attribute works with VGIC, they should be accepted. - let dist_attr = kvm_bindings::kvm_device_attr { - group: KVM_DEV_ARM_VGIC_GRP_CTRL, - attr: u64::from(KVM_DEV_ARM_VGIC_CTRL_INIT), - addr: 0x0, - flags: 0, - }; - - assert!(device_fd.has_device_attr(&dist_attr).is_ok()); - assert!(device_fd.set_device_attr(&dist_attr).is_ok()); + // Initialize valid vGIC device. + request_gic_init(&device_fd); // Test `get_device_attr`. Here we try to extract the maximum supported number of IRQs. // This value should be saved in the address provided to the ioctl. @@ -307,13 +315,98 @@ mod tests { // Without properly providing the address to where the // value will be stored, the ioctl fails with EFAULT. - let res = device_fd.get_device_attr(&mut gic_attr); + let res = unsafe { device_fd.get_device_attr(&mut gic_attr) }; assert_eq!(res, Err(Error::new(libc::EFAULT))); - gic_attr.addr = &mut data as *const u32 as u64; - assert!(device_fd.get_device_attr(&mut gic_attr).is_ok()); + gic_attr.addr = &mut data as *mut u32 as u64; + unsafe { device_fd.get_device_attr(&mut gic_attr) }.unwrap(); // The maximum supported number of IRQs should be 128, same as the value // when we initialize the GIC. assert_eq!(data, 128); } + + #[test] + #[cfg(target_arch = "riscv64")] + fn test_create_device() { + use crate::ioctls::vm::{create_aia_device, request_aia_init, set_supported_nr_irqs}; + use kvm_bindings::{ + kvm_device_attr, kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20, + KVM_DEV_RISCV_AIA_ADDR_APLIC, KVM_DEV_RISCV_AIA_CONFIG_SRCS, + KVM_DEV_RISCV_AIA_GRP_ADDR, KVM_DEV_RISCV_AIA_GRP_CONFIG, + }; + use vmm_sys_util::errno::Error; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + + let mut aia_device = kvm_bindings::kvm_create_device { + type_: kvm_device_type_KVM_DEV_TYPE_FSL_MPIC_20, + fd: 0, + flags: KVM_CREATE_DEVICE_TEST, + }; + // This fails on riscv64 as it does not use MPIC (MultiProcessor Interrupt Controller), + // it uses the vAIA. + vm.create_device(&mut aia_device).unwrap_err(); + + let device_fd = create_aia_device(&vm, 0); + + // AIA on riscv64 requires at least one online vCPU prior to setting + // device attributes. Otherwise it would fail when trying to set address + // of IMSIC. + vm.create_vcpu(0).unwrap(); + + // Following lines to re-construct device_fd are used to test + // DeviceFd::from_raw_fd() and DeviceFd::as_raw_fd(). + let raw_fd = unsafe { libc::dup(device_fd.as_raw_fd()) }; + assert!(raw_fd >= 0); + let device_fd = unsafe { DeviceFd::from_raw_fd(raw_fd) }; + + // Set maximum supported number of IRQs of the vAIA device to 128. + set_supported_nr_irqs(&device_fd, 128); + + // Before request vAIA device to initialize, APLIC and IMSIC must be set + let aplic_addr: u64 = 0x4000; + device_fd + .set_device_attr(&kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_ADDR, + attr: u64::from(KVM_DEV_RISCV_AIA_ADDR_APLIC), + addr: &aplic_addr as *const u64 as u64, + flags: 0, + }) + .unwrap(); + let imsic_addr: u64 = 0x8000; + device_fd + .set_device_attr(&kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_ADDR, + attr: 1u64, + addr: &imsic_addr as *const u64 as u64, + flags: 0, + }) + .unwrap(); + + // Initialize valid vAIA device. + request_aia_init(&device_fd); + + // Test `get_device_attr`. Here we try to extract the maximum supported number of IRQs. + // This value should be saved in the address provided to the ioctl. + let mut data: u32 = 0; + + let mut aia_attr = kvm_bindings::kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_CONFIG, + attr: u64::from(KVM_DEV_RISCV_AIA_CONFIG_SRCS), + addr: data as u64, + ..Default::default() + }; + + // Without properly providing the address to where the + // value will be stored, the ioctl fails with EFAULT. + let res = unsafe { device_fd.get_device_attr(&mut aia_attr) }; + assert_eq!(res, Err(Error::new(libc::EFAULT))); + + aia_attr.addr = &mut data as *mut u32 as u64; + unsafe { device_fd.get_device_attr(&mut aia_attr) }.unwrap(); + // The maximum supported number of IRQs should be 128, same as the value + // when we initialize the AIA. + assert_eq!(data, 128); + } } diff --git a/vendor/kvm-ioctls/src/ioctls/mod.rs b/vendor/kvm-ioctls/src/ioctls/mod.rs index 9079acc..a5f96c1 100644 --- a/vendor/kvm-ioctls/src/ioctls/mod.rs +++ b/vendor/kvm-ioctls/src/ioctls/mod.rs @@ -5,10 +5,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. +use std::mem::size_of; use std::os::unix::io::AsRawFd; -use std::ptr::null_mut; +use std::ptr::{null_mut, NonNull}; -use kvm_bindings::kvm_run; +use kvm_bindings::{ + kvm_coalesced_mmio, kvm_coalesced_mmio_ring, kvm_run, KVM_COALESCED_MMIO_PAGE_OFFSET, +}; use vmm_sys_util::errno; /// Wrappers over KVM device ioctls. @@ -26,13 +29,108 @@ pub mod vm; /// is otherwise a direct mapping to Result. pub type Result = std::result::Result; +/// A wrapper around the coalesced MMIO ring page. +#[derive(Debug)] +pub(crate) struct KvmCoalescedIoRing { + addr: NonNull, + page_size: usize, +} + +impl KvmCoalescedIoRing { + /// Maps the coalesced MMIO ring from the vCPU file descriptor. + pub(crate) fn mmap_from_fd(fd: &F) -> Result { + // SAFETY: We trust the sysconf libc function and we're calling it + // with a correct parameter. + let page_size = match unsafe { libc::sysconf(libc::_SC_PAGESIZE) } { + -1 => return Err(errno::Error::last()), + ps => ps as usize, + }; + + let offset = KVM_COALESCED_MMIO_PAGE_OFFSET * page_size as u32; + // SAFETY: KVM guarantees that there is a page at offset + // KVM_COALESCED_MMIO_PAGE_OFFSET * PAGE_SIZE if the appropriate + // capability is available. If it is not, the call will simply + // fail. + let addr = unsafe { + libc::mmap( + null_mut(), + page_size, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_SHARED, + fd.as_raw_fd(), + offset.into(), + ) + }; + let addr = NonNull::new(addr) + .filter(|addr| addr.as_ptr() != libc::MAP_FAILED) + .ok_or_else(errno::Error::last)?; + + Ok(Self { + addr: addr.cast(), + page_size, + }) + } + + /// Compute the size of the MMIO ring. + /// Taken from [include/uapi/linux/kvm.h](https://elixir.bootlin.com/linux/v6.6/source/include/uapi/linux/kvm.h#L562) + const fn ring_max(&self) -> usize { + (self.page_size - size_of::()) / size_of::() + } + + /// Gets a mutable reference to the ring + fn ring_mut(&mut self) -> &mut kvm_coalesced_mmio_ring { + // SAFETY: We have a `&mut self` and the pointer is private, so this + // access is exclusive. + unsafe { self.addr.as_mut() } + } + + /// Reads a single entry from the MMIO ring. + /// + /// # Returns + /// + /// An entry from the MMIO ring buffer, or [`None`] if the ring is empty. + pub(crate) fn read_entry(&mut self) -> Option { + let ring_max = self.ring_max(); + + let ring = self.ring_mut(); + if ring.first == ring.last { + return None; + } + + let entries = ring.coalesced_mmio.as_ptr(); + // SAFETY: `ring.first` is an `u32` coming from mapped memory filled + // by the kernel, so we trust it. `entries` is a pointer coming from + // mmap(), so pointer arithmetic cannot overflow. We have a `&mut self`, + // so nobody else has access to the contents of the pointer. + let elem = unsafe { entries.add(ring.first as usize).read() }; + ring.first = (ring.first + 1) % ring_max as u32; + + Some(elem) + } +} + +impl Drop for KvmCoalescedIoRing { + fn drop(&mut self) { + // SAFETY: This is safe because we mmap the page ourselves, and nobody + // else is holding a reference to it. + unsafe { + libc::munmap(self.addr.as_ptr().cast(), self.page_size); + } + } +} + +// SAFETY: See safety comments about [`KvmRunWrapper`]. +unsafe impl Send for KvmCoalescedIoRing {} +// SAFETY: See safety comments about [`KvmRunWrapper`]. +unsafe impl Sync for KvmCoalescedIoRing {} + /// Safe wrapper over the `kvm_run` struct. /// /// The wrapper is needed for sending the pointer to `kvm_run` between /// threads as raw pointers do not implement `Send` and `Sync`. #[derive(Debug)] pub struct KvmRunWrapper { - kvm_run_ptr: *mut u8, + kvm_run_ptr: NonNull, // This field is need so we can `munmap` the memory mapped to hold `kvm_run`. mmap_size: usize, } @@ -51,7 +149,7 @@ impl KvmRunWrapper { /// # Arguments /// * `fd` - File descriptor to mmap from. /// * `size` - Size of memory region in bytes. - pub fn mmap_from_fd(fd: &dyn AsRawFd, size: usize) -> Result { + pub fn mmap_from_fd(fd: &F, size: usize) -> Result { // SAFETY: This is safe because we are creating a mapping in a place not already used by // any other area in this process. let addr = unsafe { @@ -64,25 +162,30 @@ impl KvmRunWrapper { 0, ) }; - if addr == libc::MAP_FAILED { - return Err(errno::Error::last()); - } + let addr = NonNull::new(addr) + .filter(|addr| addr.as_ptr() != libc::MAP_FAILED) + .ok_or_else(errno::Error::last)?; Ok(KvmRunWrapper { - kvm_run_ptr: addr as *mut u8, + kvm_run_ptr: addr.cast(), mmap_size: size, }) } /// Returns a mutable reference to `kvm_run`. - #[allow(clippy::mut_from_ref)] - pub fn as_mut_ref(&self) -> &mut kvm_run { - #[allow(clippy::cast_ptr_alignment)] + pub fn as_mut_ref(&mut self) -> &mut kvm_run { + // SAFETY: Safe because we know we mapped enough memory to hold the kvm_run struct because + // the kernel told us how large it was. Nobody else has access to this pointer so it cannot + // be aliased. + unsafe { self.kvm_run_ptr.as_mut() } + } +} + +impl AsRef for KvmRunWrapper { + fn as_ref(&self) -> &kvm_run { // SAFETY: Safe because we know we mapped enough memory to hold the kvm_run struct because // the kernel told us how large it was. - unsafe { - &mut *(self.kvm_run_ptr as *mut kvm_run) - } + unsafe { self.kvm_run_ptr.as_ref() } } } @@ -91,7 +194,7 @@ impl Drop for KvmRunWrapper { // SAFETY: This is safe because we mmap the area at kvm_run_ptr ourselves, // and nobody else is holding a reference to it. unsafe { - libc::munmap(self.kvm_run_ptr as *mut libc::c_void, self.mmap_size); + libc::munmap(self.kvm_run_ptr.as_ptr().cast(), self.mmap_size); } } } diff --git a/vendor/kvm-ioctls/src/ioctls/system.rs b/vendor/kvm-ioctls/src/ioctls/system.rs index 69f48d7..83d41fc 100644 --- a/vendor/kvm-ioctls/src/ioctls/system.rs +++ b/vendor/kvm-ioctls/src/ioctls/system.rs @@ -14,12 +14,12 @@ use crate::cap::Cap; use crate::ioctls::vm::{new_vmfd, VmFd}; use crate::ioctls::Result; use crate::kvm_ioctls::*; -#[cfg(any(target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] use kvm_bindings::KVM_VM_TYPE_ARM_IPA_SIZE_MASK; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] use kvm_bindings::{CpuId, MsrList, Msrs, KVM_MAX_CPUID_ENTRIES, KVM_MAX_MSR_ENTRIES}; use vmm_sys_util::errno; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] use vmm_sys_util::ioctl::ioctl_with_mut_ptr; use vmm_sys_util::ioctl::{ioctl, ioctl_with_val}; @@ -96,7 +96,7 @@ impl Kvm { /// ``` pub fn open_with_cloexec(close_on_exec: bool) -> Result { // SAFETY: Safe because we give a constant nul-terminated string. - let kvm_path = unsafe { CStr::from_bytes_with_nul_unchecked(b"/dev/kvm\0") }; + let kvm_path = c"/dev/kvm"; Self::open_with_cloexec_at(kvm_path, close_on_exec) } @@ -193,7 +193,7 @@ impl Kvm { /// use kvm_ioctls::Cap; /// /// let kvm = Kvm::new().unwrap(); - /// assert!(kvm.check_extension_raw(Cap::MaxVcpuId as c_ulong) > 0); + /// assert!(kvm.check_extension_raw(Cap::MaxVcpus as c_ulong) > 0); /// ``` pub fn check_extension_raw(&self, c: c_ulong) -> i32 { // SAFETY: Safe because we know that our file is a KVM fd. @@ -217,7 +217,7 @@ impl Kvm { /// use kvm_ioctls::Cap; /// /// let kvm = Kvm::new().unwrap(); - /// assert!(kvm.check_extension_int(Cap::MaxVcpuId) > 0); + /// assert!(kvm.check_extension_int(Cap::MaxVcpus) > 0); /// ``` pub fn check_extension_int(&self, c: Cap) -> i32 { self.check_extension_raw(c as c_ulong) @@ -352,7 +352,7 @@ impl Kvm { } } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn get_cpuid(&self, kind: u64, num_entries: usize) -> Result { if num_entries > KVM_MAX_CPUID_ENTRIES { // Returns the same error the underlying `ioctl` would have sent. @@ -395,7 +395,7 @@ impl Kvm { /// let cpuid_entries = cpuid.as_mut_slice(); /// assert!(cpuid_entries.len() <= KVM_MAX_CPUID_ENTRIES); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_emulated_cpuid(&self, num_entries: usize) -> Result { self.get_cpuid(KVM_GET_EMULATED_CPUID(), num_entries) } @@ -424,7 +424,7 @@ impl Kvm { /// let cpuid_entries = cpuid.as_mut_slice(); /// assert!(cpuid_entries.len() <= KVM_MAX_CPUID_ENTRIES); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_supported_cpuid(&self, num_entries: usize) -> Result { self.get_cpuid(KVM_GET_SUPPORTED_CPUID(), num_entries) } @@ -441,7 +441,7 @@ impl Kvm { /// let kvm = Kvm::new().unwrap(); /// let msr_index_list = kvm.get_msr_index_list().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_msr_index_list(&self) -> Result { let mut msr_list = MsrList::new(KVM_MAX_MSR_ENTRIES).map_err(|_| errno::Error::new(libc::ENOMEM))?; @@ -477,7 +477,7 @@ impl Kvm { /// let kvm = Kvm::new().unwrap(); /// let msr_feature_index_list = kvm.get_msr_feature_index_list().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_msr_feature_index_list(&self) -> Result { let mut msr_list = MsrList::new(KVM_MAX_MSR_ENTRIES).map_err(|_| errno::Error::new(libc::ENOMEM))?; @@ -531,7 +531,7 @@ impl Kvm { /// .unwrap(); /// let ret = kvm.get_msrs(&mut msrs).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_msrs(&self, msrs: &mut Msrs) -> Result { // SAFETY: Here we trust the kernel not to read past the end of the kvm_msrs struct. let ret = unsafe { ioctl_with_mut_ptr(self, KVM_GET_MSRS(), msrs.as_mut_fam_struct_ptr()) }; @@ -576,7 +576,7 @@ impl Kvm { /// // Check that the VM mmap size is the same reported by `KVM_GET_VCPU_MMAP_SIZE`. /// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap()); /// ``` - #[cfg(any(target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] pub fn create_vm(&self) -> Result { let mut ipa_size = 0; // Create using default VM type if self.check_extension(Cap::ArmVmIPASize) { @@ -615,7 +615,7 @@ impl Kvm { /// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap()); /// } /// ``` - #[cfg(any(target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] pub fn create_vm_with_ipa_size(&self, ipa_size: u32) -> Result { self.create_vm_with_type((ipa_size & KVM_VM_TYPE_ARM_IPA_SIZE_MASK).into()) } @@ -729,10 +729,9 @@ impl FromRawFd for Kvm { mod tests { #![allow(clippy::undocumented_unsafe_blocks)] use super::*; - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - use kvm_bindings::KVM_MAX_CPUID_ENTRIES; use libc::{fcntl, FD_CLOEXEC, F_GETFD}; - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + use std::os::fd::IntoRawFd; + #[cfg(target_arch = "x86_64")] use vmm_sys_util::fam::FamStruct; #[test] @@ -742,7 +741,7 @@ mod tests { #[test] fn test_kvm_new_with_path() { - let kvm_path = unsafe { CStr::from_bytes_with_nul_unchecked(b"/dev/kvm\0") }; + let kvm_path = c"/dev/kvm"; Kvm::new_with_path(kvm_path).unwrap(); } @@ -848,7 +847,7 @@ mod tests { } #[test] - #[cfg(any(target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] fn test_create_vm_with_ipa_size() { let kvm = Kvm::new().unwrap(); if kvm.check_extension(Cap::ArmVmIPASize) { @@ -858,18 +857,17 @@ mod tests { kvm.create_vm_with_ipa_size(host_ipa_limit as u32).unwrap(); // Test invalid input values // Case 1: IPA size is smaller than 32. - assert!(kvm.create_vm_with_ipa_size(31).is_err()); + kvm.create_vm_with_ipa_size(31).unwrap_err(); // Case 2: IPA size is bigger than Host_IPA_Limit. - assert!(kvm - .create_vm_with_ipa_size((host_ipa_limit + 1) as u32) - .is_err()); + kvm.create_vm_with_ipa_size((host_ipa_limit + 1) as u32) + .unwrap_err(); } else { // Unsupported, we can't provide an IPA size. Only KVM type=0 works. - assert!(kvm.create_vm_with_type(0).is_err()); + kvm.create_vm_with_type(0).unwrap_err(); } } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn test_get_supported_cpuid() { let kvm = Kvm::new().unwrap(); @@ -880,11 +878,11 @@ mod tests { // Test case for more than MAX entries let cpuid_err = kvm.get_emulated_cpuid(KVM_MAX_CPUID_ENTRIES + 1_usize); - assert!(cpuid_err.is_err()); + cpuid_err.unwrap_err(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_get_emulated_cpuid() { let kvm = Kvm::new().unwrap(); let mut cpuid = kvm.get_emulated_cpuid(KVM_MAX_CPUID_ENTRIES).unwrap(); @@ -894,10 +892,10 @@ mod tests { // Test case for more than MAX entries let cpuid_err = kvm.get_emulated_cpuid(KVM_MAX_CPUID_ENTRIES + 1_usize); - assert!(cpuid_err.is_err()); + cpuid_err.unwrap_err(); } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn test_cpuid_clone() { let kvm = Kvm::new().unwrap(); @@ -912,7 +910,7 @@ mod tests { } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn get_msr_index_list() { let kvm = Kvm::new().unwrap(); let msr_list = kvm.get_msr_index_list().unwrap(); @@ -920,7 +918,7 @@ mod tests { } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn get_msr_feature_index_list() { let kvm = Kvm::new().unwrap(); let msr_feature_index_list = kvm.get_msr_feature_index_list().unwrap(); @@ -928,7 +926,7 @@ mod tests { } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn get_msrs() { use kvm_bindings::kvm_msr_entry; @@ -963,7 +961,7 @@ mod tests { ); assert_eq!(faulty_kvm.get_nr_vcpus(), 4); assert_eq!(faulty_kvm.get_nr_memslots(), 32); - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] { assert_eq!( faulty_kvm.get_emulated_cpuid(4).err().unwrap().errno(), @@ -980,5 +978,9 @@ mod tests { ); } assert_eq!(faulty_kvm.create_vm().err().unwrap().errno(), badf_errno); + + // Don't drop the File object, or it'll notice the file it's trying to close is + // invalid and abort the process. + let _ = faulty_kvm.kvm.into_raw_fd(); } } diff --git a/vendor/kvm-ioctls/src/ioctls/vcpu.rs b/vendor/kvm-ioctls/src/ioctls/vcpu.rs index 0da5f12..8b2caa9 100644 --- a/vendor/kvm-ioctls/src/ioctls/vcpu.rs +++ b/vendor/kvm-ioctls/src/ioctls/vcpu.rs @@ -1,3 +1,5 @@ +// Copyright © 2024 Institute of Software, CAS. All rights reserved. +// // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT // @@ -10,21 +12,81 @@ use libc::EINVAL; use std::fs::File; use std::os::unix::io::{AsRawFd, RawFd}; -use crate::ioctls::{KvmRunWrapper, Result}; +use crate::ioctls::{KvmCoalescedIoRing, KvmRunWrapper, Result}; use crate::kvm_ioctls::*; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -use kvm_bindings::{CpuId, Msrs, KVM_MAX_CPUID_ENTRIES}; use vmm_sys_util::errno; use vmm_sys_util::ioctl::{ioctl, ioctl_with_mut_ref, ioctl_with_ref}; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] use vmm_sys_util::ioctl::{ioctl_with_mut_ptr, ioctl_with_ptr, ioctl_with_val}; /// Helper method to obtain the size of the register through its id -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] -fn reg_size(reg_id: u64) -> usize { +#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] +pub fn reg_size(reg_id: u64) -> usize { 2_usize.pow(((reg_id & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT) as u32) } +/// Information about a [`VcpuExit`] triggered by an Hypercall (`KVM_EXIT_HYPERCALL`). +#[derive(Debug)] +pub struct HypercallExit<'a> { + /// The hypercall number. + pub nr: u64, + /// The arguments for the hypercall. + pub args: [u64; 6], + /// The return code to be indicated to the guest. + pub ret: &'a mut u64, + /// Whether the hypercall was executed in long mode. + pub longmode: u32, +} + +/// Information about a [`VcpuExit`] triggered by an MSR read (`KVM_EXIT_X86_RDMSR`). +#[derive(Debug)] +pub struct ReadMsrExit<'a> { + /// Must be set to 1 by the the user if the read access should fail. This + /// will inject a #GP fault into the guest when the VCPU is executed + /// again. + pub error: &'a mut u8, + /// The reason for this exit. + pub reason: MsrExitReason, + /// The MSR the guest wants to read. + pub index: u32, + /// The data to be supplied by the user as the MSR Contents to the guest. + pub data: &'a mut u64, +} + +/// Information about a [`VcpuExit`] triggered by an MSR write (`KVM_EXIT_X86_WRMSR`). +#[derive(Debug)] +pub struct WriteMsrExit<'a> { + /// Must be set to 1 by the the user if the write access should fail. This + /// will inject a #GP fault into the guest when the VCPU is executed + /// again. + pub error: &'a mut u8, + /// The reason for this exit. + pub reason: MsrExitReason, + /// The MSR the guest wants to write. + pub index: u32, + /// The data the guest wants to write into the MSR. + pub data: u64, +} + +bitflags::bitflags! { + /// The reason for a [`VcpuExit::X86Rdmsr`] or[`VcpuExit::X86Wrmsr`]. This + /// is also used when enabling + /// [`Cap::X86UserSpaceMsr`](crate::Cap::X86UserSpaceMsr) to specify which + /// reasons should be forwarded to the user via those exits. + #[derive(Clone, Copy, Debug, PartialEq, Eq)] + pub struct MsrExitReason: u32 { + /// Corresponds to [`KVM_MSR_EXIT_REASON_UNKNOWN`]. The exit was + /// triggered by an access to an MSR that is unknown to KVM. + const Unknown = KVM_MSR_EXIT_REASON_UNKNOWN; + /// Corresponds to [`KVM_MSR_EXIT_REASON_INVAL`]. The exit was + /// triggered by an access to an invalid MSR or to reserved bits. + const Inval = KVM_MSR_EXIT_REASON_INVAL; + /// Corresponds to [`KVM_MSR_EXIT_REASON_FILTER`]. The exit was + /// triggered by an access to a filtered MSR. + const Filter = KVM_MSR_EXIT_REASON_FILTER; + } +} + /// Reasons for vCPU exits. /// /// The exit reasons are mapped to the `KVM_EXIT_*` defines in the @@ -50,7 +112,7 @@ pub enum VcpuExit<'a> { /// Corresponds to KVM_EXIT_EXCEPTION. Exception, /// Corresponds to KVM_EXIT_HYPERCALL. - Hypercall, + Hypercall(HypercallExit<'a>), /// Corresponds to KVM_EXIT_DEBUG. /// /// Provides architecture specific information for the debug event. @@ -95,13 +157,26 @@ pub enum VcpuExit<'a> { /// Corresponds to KVM_EXIT_EPR. Epr, /// Corresponds to KVM_EXIT_SYSTEM_EVENT. - SystemEvent(u32 /* type */, u64 /* flags */), + SystemEvent(u32 /* type */, &'a [u64] /* data */), /// Corresponds to KVM_EXIT_S390_STSI. S390Stsi, /// Corresponds to KVM_EXIT_IOAPIC_EOI. IoapicEoi(u8 /* vector */), /// Corresponds to KVM_EXIT_HYPERV. Hyperv, + /// Corresponds to KVM_EXIT_X86_RDMSR. + X86Rdmsr(ReadMsrExit<'a>), + /// Corresponds to KVM_EXIT_X86_WRMSR. + X86Wrmsr(WriteMsrExit<'a>), + /// Corresponds to KVM_EXIT_MEMORY_FAULT. + MemoryFault { + /// flags + flags: u64, + /// gpa + gpa: u64, + /// size + size: u64, + }, /// Corresponds to an exit reason that is unknown from the current version /// of the kvm-ioctls crate. Let the consumer decide about what to do with /// it. @@ -113,12 +188,14 @@ pub enum VcpuExit<'a> { pub struct VcpuFd { vcpu: File, kvm_run_ptr: KvmRunWrapper, + /// A pointer to the coalesced MMIO page + coalesced_mmio_ring: Option, } /// KVM Sync Registers used to tell KVM which registers to sync #[repr(u32)] #[derive(Debug, Copy, Clone)] -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] pub enum SyncReg { /// General purpose registers, Register = KVM_SYNC_X86_REGS, @@ -145,10 +222,9 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] /// let regs = vcpu.get_regs().unwrap(); /// ``` - #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] + #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] pub fn get_regs(&self) -> Result { let mut regs = kvm_regs::default(); // SAFETY: Safe because we know that our file is a vCPU fd, we know the kernel will only @@ -258,16 +334,13 @@ impl VcpuFd { /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); /// - /// #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] - /// { - /// // Get the current vCPU registers. - /// let mut regs = vcpu.get_regs().unwrap(); - /// // Set a new value for the Instruction Pointer. - /// regs.rip = 0x100; - /// vcpu.set_regs(®s).unwrap(); - /// } + /// // Get the current vCPU registers. + /// let mut regs = vcpu.get_regs().unwrap(); + /// // Set a new value for the Instruction Pointer. + /// regs.rip = 0x100; + /// vcpu.set_regs(®s).unwrap(); /// ``` - #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] + #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] pub fn set_regs(&self, regs: &kvm_regs) -> Result<()> { // SAFETY: Safe because we know that our file is a vCPU fd, we know the kernel will only // read the correct amount of memory from our pointer, and we verify the return result. @@ -292,10 +365,9 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] /// let sregs = vcpu.get_sregs().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_sregs(&self) -> Result { let mut regs = kvm_sregs::default(); // SAFETY: Safe because we know that our file is a vCPU fd, we know the kernel will only @@ -322,16 +394,14 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] - /// { - /// let mut sregs = vcpu.get_sregs().unwrap(); - /// // Update the code segment (cs). - /// sregs.cs.base = 0; - /// sregs.cs.selector = 0; - /// vcpu.set_sregs(&sregs).unwrap(); - /// } + /// + /// let mut sregs = vcpu.get_sregs().unwrap(); + /// // Update the code segment (cs). + /// sregs.cs.base = 0; + /// sregs.cs.selector = 0; + /// vcpu.set_sregs(&sregs).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_sregs(&self, sregs: &kvm_sregs) -> Result<()> { // SAFETY: Safe because we know that our file is a vCPU fd, we know the kernel will only // read the correct amount of memory from our pointer, and we verify the return result. @@ -356,10 +426,10 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// let fpu = vcpu.get_fpu().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_fpu(&self) -> Result { let mut fpu = kvm_fpu::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_fpu struct. @@ -387,7 +457,7 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// { /// let KVM_FPU_CWD: u16 = 0x37f; /// let fpu = kvm_fpu { @@ -397,7 +467,7 @@ impl VcpuFd { /// vcpu.set_fpu(&fpu).unwrap(); /// } /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_fpu(&self, fpu: &kvm_fpu) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_fpu struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_FPU(), fpu) }; @@ -442,7 +512,7 @@ impl VcpuFd { /// vcpu.set_cpuid2(&kvm_cpuid).unwrap(); /// ``` /// - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_cpuid2(&self, cpuid: &CpuId) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_cpuid2 struct. let ret = unsafe { ioctl_with_ptr(self, KVM_SET_CPUID2(), cpuid.as_fam_struct_ptr()) }; @@ -475,7 +545,7 @@ impl VcpuFd { /// let cpuid = vcpu.get_cpuid2(KVM_MAX_CPUID_ENTRIES).unwrap(); /// ``` /// - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_cpuid2(&self, num_entries: usize) -> Result { if num_entries > KVM_MAX_CPUID_ENTRIES { // Returns the same error the underlying `ioctl` would have sent. @@ -511,7 +581,7 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let mut cap: kvm_enable_cap = Default::default(); - /// if cfg!(target_arch = "x86") || cfg!(target_arch = "x86_64") { + /// if cfg!(target_arch = "x86_64") { /// // KVM_CAP_HYPERV_SYNIC needs KVM_CAP_SPLIT_IRQCHIP enabled /// cap.cap = KVM_CAP_SPLIT_IRQCHIP; /// cap.args[0] = 24; @@ -526,7 +596,7 @@ impl VcpuFd { /// } /// ``` /// - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn enable_cap(&self, cap: &kvm_enable_cap) -> Result<()> { // SAFETY: The ioctl is safe because we allocated the struct and we know the // kernel will write exactly the size of the struct. @@ -556,7 +626,7 @@ impl VcpuFd { /// let vcpu = vm.create_vcpu(0).unwrap(); /// let lapic = vcpu.get_lapic().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_lapic(&self) -> Result { let mut klapic = kvm_lapic_state::default(); @@ -601,7 +671,7 @@ impl VcpuFd { /// // Update the value of LAPIC. /// vcpu.set_lapic(&lapic).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_lapic(&self, klapic: &kvm_lapic_state) -> Result<()> { // SAFETY: The ioctl is safe because the kernel will only read from the klapic struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_LAPIC(), klapic) }; @@ -647,7 +717,7 @@ impl VcpuFd { /// let read = vcpu.get_msrs(&mut msrs).unwrap(); /// assert_eq!(read, 2); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_msrs(&self, msrs: &mut Msrs) -> Result { // SAFETY: Here we trust the kernel not to read past the end of the kvm_msrs struct. let ret = unsafe { ioctl_with_mut_ptr(self, KVM_GET_MSRS(), msrs.as_mut_fam_struct_ptr()) }; @@ -686,7 +756,7 @@ impl VcpuFd { /// let written = vcpu.set_msrs(&msrs).unwrap(); /// assert_eq!(written, 1); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_msrs(&self, msrs: &Msrs) -> Result { // SAFETY: Here we trust the kernel not to read past the end of the kvm_msrs struct. let ret = unsafe { ioctl_with_ptr(self, KVM_SET_MSRS(), msrs.as_fam_struct_ptr()) }; @@ -717,11 +787,10 @@ impl VcpuFd { /// let mp_state = vcpu.get_mp_state().unwrap(); /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", target_arch = "aarch64", - target_arch = "s390" + target_arch = "riscv64", + target_arch = "s390x" ))] pub fn get_mp_state(&self) -> Result { let mut mp_state = Default::default(); @@ -755,11 +824,10 @@ impl VcpuFd { /// vcpu.set_mp_state(mp_state).unwrap(); /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", target_arch = "aarch64", - target_arch = "s390" + target_arch = "riscv64", + target_arch = "s390x" ))] pub fn set_mp_state(&self, mp_state: kvm_mp_state) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_mp_state struct. @@ -789,7 +857,7 @@ impl VcpuFd { /// let vcpu = vm.create_vcpu(0).unwrap(); /// let xsave = vcpu.get_xsave().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_xsave(&self) -> Result { let mut xsave = Default::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_xsave struct. @@ -821,7 +889,7 @@ impl VcpuFd { /// // Your `xsave` manipulation here. /// vcpu.set_xsave(&xsave).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_xsave(&self, xsave: &kvm_xsave) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_xsave struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_XSAVE(), xsave) }; @@ -850,7 +918,7 @@ impl VcpuFd { /// let vcpu = vm.create_vcpu(0).unwrap(); /// let xcrs = vcpu.get_xcrs().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_xcrs(&self) -> Result { let mut xcrs = Default::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_xcrs struct. @@ -882,7 +950,7 @@ impl VcpuFd { /// // Your `xcrs` manipulation here. /// vcpu.set_xcrs(&xcrs).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_xcrs(&self, xcrs: &kvm_xcrs) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_xcrs struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_XCRS(), xcrs) }; @@ -911,7 +979,7 @@ impl VcpuFd { /// let vcpu = vm.create_vcpu(0).unwrap(); /// let debug_regs = vcpu.get_debug_regs().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_debug_regs(&self) -> Result { let mut debug_regs = Default::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_debugregs struct. @@ -943,7 +1011,7 @@ impl VcpuFd { /// // Your `debug_regs` manipulation here. /// vcpu.set_debug_regs(&debug_regs).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_debug_regs(&self, debug_regs: &kvm_debugregs) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_debugregs struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_DEBUGREGS(), debug_regs) }; @@ -975,12 +1043,7 @@ impl VcpuFd { /// let vcpu_events = vcpu.get_vcpu_events().unwrap(); /// } /// ``` - #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" - ))] + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] pub fn get_vcpu_events(&self) -> Result { let mut vcpu_events = Default::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_vcpu_events struct. @@ -1014,13 +1077,7 @@ impl VcpuFd { /// vcpu.set_vcpu_events(&vcpu_events).unwrap(); /// } /// ``` - #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" - ))] - + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] pub fn set_vcpu_events(&self, vcpu_events: &kvm_vcpu_events) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_vcpu_events struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_VCPU_EVENTS(), vcpu_events) }; @@ -1056,7 +1113,7 @@ impl VcpuFd { /// vm.get_preferred_target(&mut kvi).unwrap(); /// vcpu.vcpu_init(&kvi).unwrap(); /// ``` - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] pub fn vcpu_init(&self, kvi: &kvm_vcpu_init) -> Result<()> { // SAFETY: This is safe because we allocated the struct and we know the kernel will read // exactly the size of the struct. @@ -1143,16 +1200,19 @@ impl VcpuFd { /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); /// - /// // KVM_GET_REG_LIST demands that the vcpus be initalized. - /// let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); - /// vm.get_preferred_target(&mut kvi).unwrap(); - /// vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu"); + /// // KVM_GET_REG_LIST on Aarch64 demands that the vcpus be initialized. + /// #[cfg(target_arch = "aarch64")] + /// { + /// let mut kvi = kvm_bindings::kvm_vcpu_init::default(); + /// vm.get_preferred_target(&mut kvi).unwrap(); + /// vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu"); /// - /// let mut reg_list = RegList::new(500).unwrap(); - /// vcpu.get_reg_list(&mut reg_list).unwrap(); - /// assert!(reg_list.as_fam_struct_ref().n > 0); + /// let mut reg_list = RegList::new(500).unwrap(); + /// vcpu.get_reg_list(&mut reg_list).unwrap(); + /// assert!(reg_list.as_fam_struct_ref().n > 0); + /// } /// ``` - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] pub fn get_reg_list(&self, reg_list: &mut RegList) -> Result<()> { let ret = // SAFETY: This is safe because we allocated the struct and we trust the kernel will read @@ -1186,7 +1246,7 @@ impl VcpuFd { /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); /// - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))] + /// #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] /// { /// let debug_struct = kvm_guest_debug { /// // Configure the vcpu so that a KVM_DEBUG_EXIT would be generated @@ -1201,11 +1261,10 @@ impl VcpuFd { /// } /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64", - target_arch = "s390", - target_arch = "ppc" + target_arch = "s390x", + target_arch = "powerpc" ))] pub fn set_guest_debug(&self, debug_struct: &kvm_guest_debug) -> Result<()> { // SAFETY: Safe because we allocated the structure and we trust the kernel. @@ -1230,7 +1289,7 @@ impl VcpuFd { /// /// `data` should be equal or bigger then the register size /// oterwise function will return EINVAL error - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] pub fn set_one_reg(&self, reg_id: u64, data: &[u8]) -> Result { let reg_size = reg_size(reg_id); if data.len() < reg_size { @@ -1262,7 +1321,7 @@ impl VcpuFd { /// /// `data` should be equal or bigger then the register size /// oterwise function will return EINVAL error - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] pub fn get_one_reg(&self, reg_id: u64, data: &mut [u8]) -> Result { let reg_size = reg_size(reg_id); if data.len() < reg_size { @@ -1285,7 +1344,7 @@ impl VcpuFd { /// /// See the documentation for `KVM_KVMCLOCK_CTRL` in the /// [KVM API documentation](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt). - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn kvmclock_ctrl(&self) -> Result<()> { // SAFETY: Safe because we know that our file is a KVM fd and that the request // is one of the ones defined by kernel. @@ -1346,7 +1405,7 @@ impl VcpuFd { /// slice.write(&x86_code).unwrap(); /// } /// - /// let vcpu_fd = vm.create_vcpu(0).unwrap(); + /// let mut vcpu_fd = vm.create_vcpu(0).unwrap(); /// /// let mut vcpu_sregs = vcpu_fd.get_sregs().unwrap(); /// vcpu_sregs.cs.base = 0; @@ -1371,7 +1430,7 @@ impl VcpuFd { /// } /// } /// ``` - pub fn run(&self) -> Result { + pub fn run(&mut self) -> Result { // SAFETY: Safe because we know that our file is a vCPU fd and we verify the return result. let ret = unsafe { ioctl(self, KVM_RUN()) }; if ret == 0 { @@ -1391,18 +1450,29 @@ impl VcpuFd { // SAFETY: The data_offset is defined by the kernel to be some number of bytes // into the kvm_run stucture, which we have fully mmap'd. let data_ptr = unsafe { run_start.offset(io.data_offset as isize) }; - // SAFETY: The slice's lifetime is limited to the lifetime of this vCPU, which is equal - // to the mmap of the `kvm_run` struct that this is slicing from. - let data_slice = unsafe { - std::slice::from_raw_parts_mut::(data_ptr as *mut u8, data_size) - }; + let data_slice = + // SAFETY: The slice's lifetime is limited to the lifetime of this vCPU, which is equal + // to the mmap of the `kvm_run` struct that this is slicing from. + unsafe { std::slice::from_raw_parts_mut::(data_ptr, data_size) }; match u32::from(io.direction) { KVM_EXIT_IO_IN => Ok(VcpuExit::IoIn(port, data_slice)), KVM_EXIT_IO_OUT => Ok(VcpuExit::IoOut(port, data_slice)), _ => Err(errno::Error::new(EINVAL)), } } - KVM_EXIT_HYPERCALL => Ok(VcpuExit::Hypercall), + KVM_EXIT_HYPERCALL => { + // SAFETY: Safe because the exit_reason (which comes from the kernel) told us + // which union field to use. + let hypercall = unsafe { &mut run.__bindgen_anon_1.hypercall }; + Ok(VcpuExit::Hypercall(HypercallExit { + nr: hypercall.nr, + args: hypercall.args, + ret: &mut hypercall.ret, + // SAFETY: Safe because the exit_reason (which comes from the kernel) told us + // which union field to use. + longmode: unsafe { hypercall.__bindgen_anon_1.longmode }, + })) + } KVM_EXIT_DEBUG => { // SAFETY: Safe because the exit_reason (which comes from the kernel) told us // which union field to use. @@ -1423,6 +1493,30 @@ impl VcpuFd { Ok(VcpuExit::MmioRead(addr, data_slice)) } } + KVM_EXIT_X86_RDMSR => { + // SAFETY: Safe because the exit_reason (which comes from the kernel) told us + // which union field to use. + let msr = unsafe { &mut run.__bindgen_anon_1.msr }; + let exit = ReadMsrExit { + error: &mut msr.error, + reason: MsrExitReason::from_bits_truncate(msr.reason), + index: msr.index, + data: &mut msr.data, + }; + Ok(VcpuExit::X86Rdmsr(exit)) + } + KVM_EXIT_X86_WRMSR => { + // SAFETY: Safe because the exit_reason (which comes from the kernel) told us + // which union field to use. + let msr = unsafe { &mut run.__bindgen_anon_1.msr }; + let exit = WriteMsrExit { + error: &mut msr.error, + reason: MsrExitReason::from_bits_truncate(msr.reason), + index: msr.index, + data: msr.data, + }; + Ok(VcpuExit::X86Wrmsr(exit)) + } KVM_EXIT_IRQ_WINDOW_OPEN => Ok(VcpuExit::IrqWindowOpen), KVM_EXIT_SHUTDOWN => Ok(VcpuExit::Shutdown), KVM_EXIT_FAIL_ENTRY => { @@ -1452,10 +1546,10 @@ impl VcpuFd { // SAFETY: Safe because the exit_reason (which comes from the kernel) told us // which union field to use. let system_event = unsafe { &mut run.__bindgen_anon_1.system_event }; - Ok(VcpuExit::SystemEvent( - system_event.type_, - system_event.flags, - )) + let ndata = system_event.ndata; + // SAFETY: Safe because we only populate with valid data (based on ndata) + let data = unsafe { &system_event.__bindgen_anon_1.data[0..ndata as usize] }; + Ok(VcpuExit::SystemEvent(system_event.type_, data)) } KVM_EXIT_S390_STSI => Ok(VcpuExit::S390Stsi), KVM_EXIT_IOAPIC_EOI => { @@ -1468,7 +1562,30 @@ impl VcpuFd { r => Ok(VcpuExit::Unsupported(r)), } } else { - Err(errno::Error::last()) + let errno = errno::Error::last(); + let run = self.kvm_run_ptr.as_mut_ref(); + // From https://docs.kernel.org/virt/kvm/api.html#kvm-run : + // + // KVM_EXIT_MEMORY_FAULT is unique among all KVM exit reasons in that it accompanies + // a return code of ‘-1’, not ‘0’! errno will always be set to EFAULT or EHWPOISON + // when KVM exits with KVM_EXIT_MEMORY_FAULT, userspace should assume kvm_run.exit_reason + // is stale/undefined for all other error numbers. + if ret == -1 + && (errno == errno::Error::new(libc::EFAULT) + || errno == errno::Error::new(libc::EHWPOISON)) + && run.exit_reason == KVM_EXIT_MEMORY_FAULT + { + // SAFETY: Safe because the exit_reason (which comes from the kernel) told us + // which union field to use. + let fault = unsafe { &mut run.__bindgen_anon_1.memory_fault }; + Ok(VcpuExit::MemoryFault { + flags: fault.flags, + gpa: fault.gpa, + size: fault.size, + }) + } else { + Err(errno) + } } } @@ -1478,7 +1595,7 @@ impl VcpuFd { } /// Sets the `immediate_exit` flag on the `kvm_run` struct associated with this vCPU to `val`. - pub fn set_kvm_immediate_exit(&self, val: u8) { + pub fn set_kvm_immediate_exit(&mut self, val: u8) { let kvm_run = self.kvm_run_ptr.as_mut_ref(); kvm_run.immediate_exit = val; } @@ -1496,7 +1613,7 @@ impl VcpuFd { /// let tsc_khz = vcpu.get_tsc_khz().unwrap(); /// ``` /// - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_tsc_khz(&self) -> Result { // SAFETY: Safe because we know that our file is a KVM fd and that the request is one of // the ones defined by kernel. @@ -1513,7 +1630,7 @@ impl VcpuFd { /// # Arguments /// /// * `freq` - The frequency unit is KHz as per the KVM API documentation - /// for `KVM_SET_TSC_KHZ`. + /// for `KVM_SET_TSC_KHZ`. /// /// # Example /// @@ -1528,7 +1645,7 @@ impl VcpuFd { /// } /// ``` /// - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_tsc_khz(&self, freq: u32) -> Result<()> { // SAFETY: Safe because we know that our file is a KVM fd and that the request is one of // the ones defined by kernel. @@ -1558,10 +1675,10 @@ impl VcpuFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let vcpu = vm.create_vcpu(0).unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// let tr = vcpu.translate_gva(0x10000).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn translate_gva(&self, gva: u64) -> Result { let mut tr = kvm_translation { linear_address: gva, @@ -1595,9 +1712,9 @@ impl VcpuFd { /// vcpu.set_sync_valid_reg(SyncReg::SystemRegister); /// vcpu.set_sync_valid_reg(SyncReg::VcpuEvents); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_sync_valid_reg(&mut self, reg: SyncReg) { - let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); + let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); kvm_run.kvm_valid_regs |= reg as u64; } @@ -1617,9 +1734,9 @@ impl VcpuFd { /// let mut vcpu = vm.create_vcpu(0).unwrap(); /// vcpu.set_sync_dirty_reg(SyncReg::Register); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_sync_dirty_reg(&mut self, reg: SyncReg) { - let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); + let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); kvm_run.kvm_dirty_regs |= reg as u64; } @@ -1639,9 +1756,9 @@ impl VcpuFd { /// let mut vcpu = vm.create_vcpu(0).unwrap(); /// vcpu.clear_sync_valid_reg(SyncReg::Register); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn clear_sync_valid_reg(&mut self, reg: SyncReg) { - let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); + let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); kvm_run.kvm_valid_regs &= !(reg as u64); } @@ -1661,9 +1778,9 @@ impl VcpuFd { /// let mut vcpu = vm.create_vcpu(0).unwrap(); /// vcpu.clear_sync_dirty_reg(SyncReg::Register); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn clear_sync_dirty_reg(&mut self, reg: SyncReg) { - let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); + let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); kvm_run.kvm_dirty_regs &= !(reg as u64); } @@ -1683,9 +1800,9 @@ impl VcpuFd { /// let guest_rax = vcpu.sync_regs().regs.rax; /// } /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn sync_regs(&self) -> kvm_sync_regs { - let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); + let kvm_run = self.kvm_run_ptr.as_ref(); // SAFETY: Accessing this union field could be out of bounds if the `kvm_run` // allocation isn't large enough. The `kvm_run` region is set using @@ -1712,7 +1829,7 @@ impl VcpuFd { /// vcpu.run(); /// } /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn sync_regs_mut(&mut self) -> &mut kvm_sync_regs { let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref(); @@ -1721,6 +1838,104 @@ impl VcpuFd { // `get_vcpu_map_size`, so this region is in bounds unsafe { &mut kvm_run.s.regs } } + + /// Triggers an SMI on the virtual CPU. + /// + /// See documentation for `KVM_SMI`. + /// + /// ```rust + /// # use kvm_ioctls::{Kvm, Cap}; + /// let kvm = Kvm::new().unwrap(); + /// let vm = kvm.create_vm().unwrap(); + /// let vcpu = vm.create_vcpu(0).unwrap(); + /// if kvm.check_extension(Cap::X86Smm) { + /// vcpu.smi().unwrap(); + /// } + /// ``` + #[cfg(target_arch = "x86_64")] + pub fn smi(&self) -> Result<()> { + // SAFETY: Safe because we call this with a Vcpu fd and we trust the kernel. + let ret = unsafe { ioctl(self, KVM_SMI()) }; + match ret { + 0 => Ok(()), + _ => Err(errno::Error::last()), + } + } + + /// Queues an NMI on the thread's vcpu. Only usable if `KVM_CAP_USER_NMI` + /// is available. + /// + /// See the documentation for `KVM_NMI`. + /// + /// # Example + /// + /// ```rust + /// # use kvm_ioctls::{Kvm, Cap}; + /// let kvm = Kvm::new().unwrap(); + /// let vm = kvm.create_vm().unwrap(); + /// let vcpu = vm.create_vcpu(0).unwrap(); + /// if kvm.check_extension(Cap::UserNmi) { + /// vcpu.nmi().unwrap(); + /// } + /// ``` + #[cfg(target_arch = "x86_64")] + pub fn nmi(&self) -> Result<()> { + // SAFETY: Safe because we call this with a Vcpu fd and we trust the kernel. + let ret = unsafe { ioctl(self, KVM_NMI()) }; + match ret { + 0 => Ok(()), + _ => Err(errno::Error::last()), + } + } + + /// Maps the coalesced MMIO ring page. This allows reading entries from + /// the ring via [`coalesced_mmio_read()`](VcpuFd::coalesced_mmio_read). + /// + /// # Returns + /// + /// Returns an error if the buffer could not be mapped, usually because + /// `KVM_CAP_COALESCED_MMIO` ([`Cap::CoalescedMmio`](crate::Cap::CoalescedMmio)) + /// is not available. + /// + /// # Examples + /// + /// ```rust + /// # use kvm_ioctls::{Kvm, Cap}; + /// let kvm = Kvm::new().unwrap(); + /// let vm = kvm.create_vm().unwrap(); + /// let mut vcpu = vm.create_vcpu(0).unwrap(); + /// if kvm.check_extension(Cap::CoalescedMmio) { + /// vcpu.map_coalesced_mmio_ring().unwrap(); + /// } + /// ``` + pub fn map_coalesced_mmio_ring(&mut self) -> Result<()> { + if self.coalesced_mmio_ring.is_none() { + let ring = KvmCoalescedIoRing::mmap_from_fd(&self.vcpu)?; + self.coalesced_mmio_ring = Some(ring); + } + Ok(()) + } + + /// Read a single entry from the coalesced MMIO ring. + /// For entries to be appended to the ring by the kernel, addresses must be registered + /// via [`VmFd::register_coalesced_mmio()`](crate::VmFd::register_coalesced_mmio()). + /// + /// [`map_coalesced_mmio_ring()`](VcpuFd::map_coalesced_mmio_ring) must have been called beforehand. + /// + /// See the documentation for `KVM_(UN)REGISTER_COALESCED_MMIO`. + /// + /// # Returns + /// + /// * An error if [`map_coalesced_mmio_ring()`](VcpuFd::map_coalesced_mmio_ring) + /// was not called beforehand. + /// * [`Ok`] if the ring is empty. + /// * [`Ok>`] if an entry was successfully read. + pub fn coalesced_mmio_read(&mut self) -> Result> { + self.coalesced_mmio_ring + .as_mut() + .ok_or(errno::Error::new(libc::EIO)) + .map(|ring| ring.read_entry()) + } } /// Helper function to create a new `VcpuFd`. @@ -1729,7 +1944,11 @@ impl VcpuFd { /// `create_vcpu` from `VmFd`. The function cannot be part of the `VcpuFd` implementation because /// then it would be exported with the public `VcpuFd` interface. pub fn new_vcpu(vcpu: File, kvm_run_ptr: KvmRunWrapper) -> VcpuFd { - VcpuFd { vcpu, kvm_run_ptr } + VcpuFd { + vcpu, + kvm_run_ptr, + coalesced_mmio_ring: None, + } } impl AsRawFd for VcpuFd { @@ -1744,18 +1963,14 @@ mod tests { extern crate byteorder; use super::*; - #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" - ))] + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] use crate::cap::Cap; use crate::ioctls::system::Kvm; + use std::ptr::NonNull; // Helper function for memory mapping `size` bytes of anonymous memory. // Panics if the mmap fails. - fn mmap_anonymous(size: usize) -> *mut u8 { + fn mmap_anonymous(size: usize) -> NonNull { use std::ptr::null_mut; let addr = unsafe { @@ -1772,7 +1987,7 @@ mod tests { panic!("mmap failed."); } - addr as *mut u8 + NonNull::new(addr).unwrap().cast() } #[test] @@ -1780,7 +1995,7 @@ mod tests { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); - assert!(vm.create_vcpu(0).is_ok()); + vm.create_vcpu(0).unwrap(); } #[cfg(target_arch = "x86_64")] @@ -1925,7 +2140,7 @@ mod tests { assert!(kvm.check_extension(Cap::Irqchip)); let vm = kvm.create_vm().unwrap(); // The get_lapic ioctl will fail if there is no irqchip created beforehand. - assert!(vm.create_irq_chip().is_ok()); + vm.create_irq_chip().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); let mut klapic: kvm_lapic_state = vcpu.get_lapic().unwrap(); @@ -1994,11 +2209,10 @@ mod tests { } #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", target_arch = "aarch64", - target_arch = "s390" + target_arch = "riscv64", + target_arch = "s390x" ))] #[test] fn mpstate_test() { @@ -2011,7 +2225,7 @@ mod tests { assert_eq!(mp_state, other_mp_state); } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn xsave_test() { let kvm = Kvm::new().unwrap(); @@ -2023,7 +2237,7 @@ mod tests { assert_eq!(&xsave.region[..], &other_xsave.region[..]); } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn xcrs_test() { let kvm = Kvm::new().unwrap(); @@ -2035,7 +2249,7 @@ mod tests { assert_eq!(xcrs, other_xcrs); } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn debugregs_test() { let kvm = Kvm::new().unwrap(); @@ -2047,12 +2261,7 @@ mod tests { assert_eq!(debugregs, other_debugregs); } - #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" - ))] + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] #[test] fn vcpu_events_test() { let kvm = Kvm::new().unwrap(); @@ -2090,7 +2299,7 @@ mod tests { ]; let mem_size = 0x20000; - let load_addr = mmap_anonymous(mem_size); + let load_addr = mmap_anonymous(mem_size).as_ptr(); let guest_addr: u64 = 0x10000; let slot: u32 = 0; let mem_region = kvm_userspace_memory_region { @@ -2111,8 +2320,8 @@ mod tests { slice.write_all(&code).unwrap(); } - let vcpu_fd = vm.create_vcpu(0).unwrap(); - let mut kvi = kvm_bindings::kvm_vcpu_init::default(); + let mut vcpu_fd = vm.create_vcpu(0).unwrap(); + let mut kvi = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi).unwrap(); kvi.features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2; vcpu_fd.vcpu_init(&kvi).unwrap(); @@ -2162,9 +2371,101 @@ mod tests { .sum(); assert_eq!(dirty_pages, 1); } - VcpuExit::SystemEvent(type_, flags) => { + VcpuExit::SystemEvent(type_, data) => { assert_eq!(type_, KVM_SYSTEM_EVENT_SHUTDOWN); - assert_eq!(flags, 0); + assert_eq!(data[0], 0); + break; + } + r => panic!("unexpected exit reason: {:?}", r), + } + } + } + + #[cfg(target_arch = "riscv64")] + #[test] + fn test_run_code() { + use std::io::Write; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + #[rustfmt::skip] + let code = [ + 0x13, 0x05, 0x50, 0x40, // li a0, 0x0405; + 0x23, 0x20, 0xac, 0x00, // sw a0, 0(s8); test physical memory write + 0x03, 0xa5, 0x0c, 0x00, // lw a0, 0(s9); test MMIO read + 0x93, 0x05, 0x70, 0x60, // li a1, 0x0607; + 0x23, 0xa0, 0xbc, 0x00, // sw a1, 0(s9); test MMIO write + 0x6f, 0x00, 0x00, 0x00, // j .; shouldn't get here, but if so loop forever + ]; + + let mem_size = 0x20000; + let load_addr = mmap_anonymous(mem_size).as_ptr(); + let guest_addr: u64 = 0x10000; + let slot: u32 = 0; + let mem_region = kvm_userspace_memory_region { + slot, + guest_phys_addr: guest_addr, + memory_size: mem_size as u64, + userspace_addr: load_addr as u64, + flags: KVM_MEM_LOG_DIRTY_PAGES, + }; + unsafe { + vm.set_user_memory_region(mem_region).unwrap(); + } + + unsafe { + // Get a mutable slice of `mem_size` from `load_addr`. + // This is safe because we mapped it before. + let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size); + slice.write_all(&code).unwrap(); + } + + let mut vcpu_fd = vm.create_vcpu(0).unwrap(); + + let core_reg_base: u64 = 0x8030_0000_0200_0000; + let mmio_addr: u64 = guest_addr + mem_size as u64; + + // Set the PC to the guest address where we loaded the code. + vcpu_fd + .set_one_reg(core_reg_base, &(guest_addr as u128).to_le_bytes()) + .unwrap(); + + // Set s8 and s9 to the addresses the guest test code needs + vcpu_fd + .set_one_reg( + core_reg_base + 24, + &(guest_addr as u128 + 0x10000).to_le_bytes(), + ) + .unwrap(); + vcpu_fd + .set_one_reg(core_reg_base + 25, &(mmio_addr as u128).to_le_bytes()) + .unwrap(); + + loop { + match vcpu_fd.run().expect("run failed") { + VcpuExit::MmioRead(addr, data) => { + assert_eq!(addr, mmio_addr); + assert_eq!(data.len(), 4); + data[3] = 0x0; + data[2] = 0x0; + data[1] = 0x5; + data[0] = 0x6; + } + VcpuExit::MmioWrite(addr, data) => { + assert_eq!(addr, mmio_addr); + assert_eq!(data.len(), 4); + assert_eq!(data[3], 0x0); + assert_eq!(data[2], 0x0); + assert_eq!(data[1], 0x6); + assert_eq!(data[0], 0x7); + // The code snippet dirties one page at guest_addr + 0x10000. + // The code page should not be dirty, as it's not written by the guest. + let dirty_pages_bitmap = vm.get_dirty_log(slot, mem_size).unwrap(); + let dirty_pages: u32 = dirty_pages_bitmap + .into_iter() + .map(|page| page.count_ones()) + .sum(); + assert_eq!(dirty_pages, 1); break; } r => panic!("unexpected exit reason: {:?}", r), @@ -2195,7 +2496,7 @@ mod tests { let expected_rips: [u64; 3] = [0x1003, 0x1005, 0x1007]; let mem_size = 0x4000; - let load_addr = mmap_anonymous(mem_size); + let load_addr = mmap_anonymous(mem_size).as_ptr(); let guest_addr: u64 = 0x1000; let slot: u32 = 0; let mem_region = kvm_userspace_memory_region { @@ -2216,7 +2517,7 @@ mod tests { slice.write_all(&code).unwrap(); } - let vcpu_fd = vm.create_vcpu(0).unwrap(); + let mut vcpu_fd = vm.create_vcpu(0).unwrap(); let mut vcpu_sregs = vcpu_fd.get_sregs().unwrap(); assert_ne!(vcpu_sregs.cs.base, 0); @@ -2300,91 +2601,132 @@ mod tests { } #[test] - #[cfg(target_arch = "x86_64")] + #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64" + ))] fn test_faulty_vcpu_fd() { - use std::os::unix::io::FromRawFd; + use std::os::unix::io::{FromRawFd, IntoRawFd}; let badf_errno = libc::EBADF; - let faulty_vcpu_fd = VcpuFd { + let mut faulty_vcpu_fd = VcpuFd { vcpu: unsafe { File::from_raw_fd(-2) }, kvm_run_ptr: KvmRunWrapper { - kvm_run_ptr: mmap_anonymous(10), + kvm_run_ptr: mmap_anonymous(10).cast(), mmap_size: 10, }, + coalesced_mmio_ring: None, }; - assert_eq!(faulty_vcpu_fd.get_regs().unwrap_err().errno(), badf_errno); assert_eq!( - faulty_vcpu_fd - .set_regs(&unsafe { std::mem::zeroed() }) - .unwrap_err() - .errno(), + faulty_vcpu_fd.get_mp_state().unwrap_err().errno(), badf_errno ); - assert_eq!(faulty_vcpu_fd.get_sregs().unwrap_err().errno(), badf_errno); assert_eq!( faulty_vcpu_fd - .set_sregs(&unsafe { std::mem::zeroed() }) + .set_mp_state(kvm_mp_state::default()) .unwrap_err() .errno(), badf_errno ); - assert_eq!(faulty_vcpu_fd.get_fpu().unwrap_err().errno(), badf_errno); + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] assert_eq!( - faulty_vcpu_fd - .set_fpu(&unsafe { std::mem::zeroed() }) - .unwrap_err() - .errno(), + faulty_vcpu_fd.get_vcpu_events().unwrap_err().errno(), badf_errno ); + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] assert_eq!( faulty_vcpu_fd - .set_cpuid2( - &Kvm::new() - .unwrap() - .get_supported_cpuid(KVM_MAX_CPUID_ENTRIES) - .unwrap() - ) + .set_vcpu_events(&kvm_vcpu_events::default()) .unwrap_err() .errno(), badf_errno ); - assert_eq!( - faulty_vcpu_fd.get_cpuid2(1).err().unwrap().errno(), - badf_errno - ); - // `kvm_lapic_state` does not implement debug by default so we cannot - // use unwrap_err here. - assert!(faulty_vcpu_fd.get_lapic().is_err()); - assert_eq!( - faulty_vcpu_fd - .set_lapic(&unsafe { std::mem::zeroed() }) + assert_eq!(faulty_vcpu_fd.run().unwrap_err().errno(), badf_errno); + + // Don't drop the File object, or it'll notice the file it's trying to close is + // invalid and abort the process. + let _ = faulty_vcpu_fd.vcpu.into_raw_fd(); + } + + #[test] + #[cfg(target_arch = "x86_64")] + fn test_faulty_vcpu_fd_x86_64() { + use std::os::unix::io::{FromRawFd, IntoRawFd}; + + let badf_errno = libc::EBADF; + + let faulty_vcpu_fd = VcpuFd { + vcpu: unsafe { File::from_raw_fd(-2) }, + kvm_run_ptr: KvmRunWrapper { + kvm_run_ptr: mmap_anonymous(10).cast(), + mmap_size: 10, + }, + coalesced_mmio_ring: None, + }; + + assert_eq!(faulty_vcpu_fd.get_regs().unwrap_err().errno(), badf_errno); + assert_eq!( + faulty_vcpu_fd + .set_regs(&unsafe { std::mem::zeroed() }) .unwrap_err() .errno(), badf_errno ); + assert_eq!(faulty_vcpu_fd.get_sregs().unwrap_err().errno(), badf_errno); assert_eq!( faulty_vcpu_fd - .get_msrs(&mut Msrs::new(1).unwrap()) + .set_sregs(&unsafe { std::mem::zeroed() }) .unwrap_err() .errno(), badf_errno ); + assert_eq!(faulty_vcpu_fd.get_fpu().unwrap_err().errno(), badf_errno); assert_eq!( faulty_vcpu_fd - .set_msrs(&Msrs::new(1).unwrap()) + .set_fpu(&unsafe { std::mem::zeroed() }) .unwrap_err() .errno(), badf_errno ); assert_eq!( - faulty_vcpu_fd.get_mp_state().unwrap_err().errno(), + faulty_vcpu_fd + .set_cpuid2( + &Kvm::new() + .unwrap() + .get_supported_cpuid(KVM_MAX_CPUID_ENTRIES) + .unwrap() + ) + .unwrap_err() + .errno(), badf_errno ); + assert_eq!( + faulty_vcpu_fd.get_cpuid2(1).err().unwrap().errno(), + badf_errno + ); + // `kvm_lapic_state` does not implement debug by default so we cannot + // use unwrap_err here. + faulty_vcpu_fd.get_lapic().unwrap_err(); assert_eq!( faulty_vcpu_fd - .set_mp_state(kvm_mp_state::default()) + .set_lapic(&unsafe { std::mem::zeroed() }) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .get_msrs(&mut Msrs::new(1).unwrap()) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .set_msrs(&Msrs::new(1).unwrap()) .unwrap_err() .errno(), badf_errno @@ -2421,56 +2763,191 @@ mod tests { badf_errno ); assert_eq!( - faulty_vcpu_fd.get_vcpu_events().unwrap_err().errno(), + faulty_vcpu_fd.kvmclock_ctrl().unwrap_err().errno(), + badf_errno + ); + faulty_vcpu_fd.get_tsc_khz().unwrap_err(); + faulty_vcpu_fd.set_tsc_khz(1000000).unwrap_err(); + faulty_vcpu_fd.translate_gva(u64::MAX).unwrap_err(); + + // Don't drop the File object, or it'll notice the file it's trying to close is + // invalid and abort the process. + let _ = faulty_vcpu_fd.vcpu.into_raw_fd(); + } + + #[test] + #[cfg(target_arch = "aarch64")] + fn test_faulty_vcpu_target_aarch64() { + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + let vcpu = vm.create_vcpu(0).unwrap(); + + // KVM defines valid targets as 0 to KVM_ARM_NUM_TARGETS-1, so pick a big raw number + // greater than that as target to be invalid + let kvi = kvm_vcpu_init { + target: 300, + ..Default::default() + }; + + vcpu.vcpu_init(&kvi).unwrap_err(); + } + + #[test] + #[cfg(target_arch = "aarch64")] + fn test_faulty_vcpu_fd_aarch64() { + use std::os::unix::io::{FromRawFd, IntoRawFd}; + + let badf_errno = libc::EBADF; + + let faulty_vcpu_fd = VcpuFd { + vcpu: unsafe { File::from_raw_fd(-2) }, + kvm_run_ptr: KvmRunWrapper { + kvm_run_ptr: mmap_anonymous(10).cast(), + mmap_size: 10, + }, + coalesced_mmio_ring: None, + }; + + let device_attr = kvm_device_attr { + group: KVM_ARM_VCPU_PMU_V3_CTRL, + attr: u64::from(KVM_ARM_VCPU_PMU_V3_INIT), + addr: 0x0, + flags: 0, + }; + + let reg_id = 0x6030_0000_0010_0042; + let mut reg_data = 0u128.to_le_bytes(); + + assert_eq!( + faulty_vcpu_fd + .set_device_attr(&device_attr) + .unwrap_err() + .errno(), badf_errno ); assert_eq!( faulty_vcpu_fd - .set_vcpu_events(&kvm_vcpu_events::default()) + .has_device_attr(&device_attr) .unwrap_err() .errno(), badf_errno ); - assert_eq!(faulty_vcpu_fd.run().unwrap_err().errno(), badf_errno); assert_eq!( - faulty_vcpu_fd.kvmclock_ctrl().unwrap_err().errno(), + faulty_vcpu_fd + .vcpu_init(&kvm_vcpu_init::default()) + .unwrap_err() + .errno(), badf_errno ); - assert!(faulty_vcpu_fd.get_tsc_khz().is_err()); - assert!(faulty_vcpu_fd.set_tsc_khz(1000000).is_err()); - assert!(faulty_vcpu_fd.translate_gva(u64::MAX).is_err()); + assert_eq!( + faulty_vcpu_fd + .vcpu_finalize(&(KVM_ARM_VCPU_SVE as i32)) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .get_reg_list(&mut RegList::new(500).unwrap()) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .set_one_reg(reg_id, ®_data) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .get_one_reg(reg_id, &mut reg_data) + .unwrap_err() + .errno(), + badf_errno + ); + + // Don't drop the File object, or it'll notice the file it's trying to close is + // invalid and abort the process. + faulty_vcpu_fd.vcpu.into_raw_fd(); } #[test] - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "riscv64")] + fn test_faulty_vcpu_fd_riscv64() { + use std::os::unix::io::{FromRawFd, IntoRawFd}; + + let badf_errno = libc::EBADF; + + let faulty_vcpu_fd = VcpuFd { + vcpu: unsafe { File::from_raw_fd(-2) }, + kvm_run_ptr: KvmRunWrapper { + kvm_run_ptr: mmap_anonymous(10).cast(), + mmap_size: 10, + }, + coalesced_mmio_ring: None, + }; + + let reg_id = 0x8030_0000_0200_000a; + let mut reg_data = 0u128.to_le_bytes(); + + assert_eq!( + faulty_vcpu_fd + .get_reg_list(&mut RegList::new(200).unwrap()) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .set_one_reg(reg_id, ®_data) + .unwrap_err() + .errno(), + badf_errno + ); + assert_eq!( + faulty_vcpu_fd + .get_one_reg(reg_id, &mut reg_data) + .unwrap_err() + .errno(), + badf_errno + ); + + // Don't drop the File object, or it'll notice the file it's trying to close is + // invalid and abort the process. + faulty_vcpu_fd.vcpu.into_raw_fd(); + } + + #[test] + #[cfg(target_arch = "aarch64")] fn test_get_preferred_target() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); - assert!(vcpu.vcpu_init(&kvi).is_err()); + let mut kvi = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi) .expect("Cannot get preferred target"); - assert!(vcpu.vcpu_init(&kvi).is_ok()); + vcpu.vcpu_init(&kvi).unwrap(); } #[test] - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] fn test_set_one_reg() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); + let mut kvi = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi) .expect("Cannot get preferred target"); vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu"); let data: u128 = 0; let reg_id: u64 = 0; - assert!(vcpu.set_one_reg(reg_id, &data.to_le_bytes()).is_err()); + vcpu.set_one_reg(reg_id, &data.to_le_bytes()).unwrap_err(); // Exercising KVM_SET_ONE_REG by trying to alter the data inside the PSTATE register (which is a // specific aarch64 register). // This regiseter is 64 bit wide (8 bytes). @@ -2479,17 +2956,17 @@ mod tests { .expect("Failed to set pstate register"); // Trying to set 8 byte register with 7 bytes must fail. - assert!(vcpu.set_one_reg(PSTATE_REG_ID, &[0_u8; 7]).is_err()); + vcpu.set_one_reg(PSTATE_REG_ID, &[0_u8; 7]).unwrap_err(); } #[test] - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] fn test_get_one_reg() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); + let mut kvi = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi) .expect("Cannot get preferred target"); vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu"); @@ -2515,11 +2992,11 @@ mod tests { assert_eq!(data, PSTATE_FAULT_BITS_64 as u128); // Trying to get 8 byte register with 7 bytes must fail. - assert!(vcpu.get_one_reg(PSTATE_REG_ID, &mut [0_u8; 7]).is_err()); + vcpu.get_one_reg(PSTATE_REG_ID, &mut [0_u8; 7]).unwrap_err(); } #[test] - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] fn test_get_reg_list() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); @@ -2530,7 +3007,7 @@ mod tests { let err = vcpu.get_reg_list(&mut reg_list).unwrap_err(); assert!(err.errno() == libc::ENOEXEC); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); + let mut kvi = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi) .expect("Cannot get preferred target"); vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu"); @@ -2539,12 +3016,88 @@ mod tests { // not allocated memory, so the first time it fails. let err = vcpu.get_reg_list(&mut reg_list).unwrap_err(); assert!(err.errno() == libc::E2BIG); - assert!(reg_list.as_mut_fam_struct().n > 0); + // SAFETY: This structure is a result from a specific vCPU ioctl + assert!(unsafe { reg_list.as_mut_fam_struct() }.n > 0); // We make use of the number of registers returned to allocate memory and // try one more time. - let mut reg_list = RegList::new(reg_list.as_mut_fam_struct().n as usize).unwrap(); - assert!(vcpu.get_reg_list(&mut reg_list).is_ok()); + // SAFETY: This structure is a result from a specific vCPU ioctl + let mut reg_list = + RegList::new(unsafe { reg_list.as_mut_fam_struct() }.n as usize).unwrap(); + vcpu.get_reg_list(&mut reg_list).unwrap() + } + + #[test] + #[cfg(target_arch = "riscv64")] + fn test_set_one_reg() { + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + let vcpu = vm.create_vcpu(0).unwrap(); + + let data: u128 = 0; + let reg_id: u64 = 0; + + vcpu.set_one_reg(reg_id, &data.to_le_bytes()).unwrap_err(); + // Exercising KVM_SET_ONE_REG by trying to alter the data inside the A0 + // register. + // This regiseter is 64 bit wide (8 bytes). + const A0_REG_ID: u64 = 0x8030_0000_0200_000a; + vcpu.set_one_reg(A0_REG_ID, &data.to_le_bytes()) + .expect("Failed to set a0 register"); + + // Trying to set 8 byte register with 7 bytes must fail. + vcpu.set_one_reg(A0_REG_ID, &[0_u8; 7]).unwrap_err(); + } + + #[test] + #[cfg(target_arch = "riscv64")] + fn test_get_one_reg() { + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + let vcpu = vm.create_vcpu(0).unwrap(); + + const PRESET: u64 = 0x7; + let data: u128 = PRESET as u128; + const A0_REG_ID: u64 = 0x8030_0000_0200_000a; + vcpu.set_one_reg(A0_REG_ID, &data.to_le_bytes()) + .expect("Failed to set a0 register"); + + let mut bytes = [0_u8; 16]; + vcpu.get_one_reg(A0_REG_ID, &mut bytes) + .expect("Failed to get a0 register"); + let data = u128::from_le_bytes(bytes); + assert_eq!(data, PRESET as u128); + + // Trying to get 8 byte register with 7 bytes must fail. + vcpu.get_one_reg(A0_REG_ID, &mut [0_u8; 7]).unwrap_err(); + } + + #[test] + #[cfg(target_arch = "riscv64")] + fn test_get_reg_list() { + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + let vcpu = vm.create_vcpu(0).unwrap(); + + let mut reg_list = RegList::new(1).unwrap(); + + // KVM_GET_REG_LIST offers us a number of registers for which we have + // not allocated memory, so the first time it fails. + let err = vcpu.get_reg_list(&mut reg_list).unwrap_err(); + assert!(err.errno() == libc::E2BIG); + // SAFETY: This structure is a result from a specific vCPU ioctl + assert!(unsafe { reg_list.as_mut_fam_struct() }.n > 0); + + // We make use of the number of registers returned to allocate memory and + // try one more time. + // SAFETY: This structure is a result from a specific vCPU ioctl + let mut reg_list = + RegList::new(unsafe { reg_list.as_mut_fam_struct() }.n as usize).unwrap(); + vcpu.get_reg_list(&mut reg_list).unwrap(); + + // Test get a register list contains 200 registers explicitly + let mut reg_list = RegList::new(200).unwrap(); + vcpu.get_reg_list(&mut reg_list).unwrap(); } #[test] @@ -2560,10 +3113,10 @@ mod tests { fn test_set_kvm_immediate_exit() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); - let vcpu = vm.create_vcpu(0).unwrap(); - assert_eq!(vcpu.kvm_run_ptr.as_mut_ref().immediate_exit, 0); + let mut vcpu = vm.create_vcpu(0).unwrap(); + assert_eq!(vcpu.kvm_run_ptr.as_ref().immediate_exit, 0); vcpu.set_kvm_immediate_exit(1); - assert_eq!(vcpu.kvm_run_ptr.as_mut_ref().immediate_exit, 1); + assert_eq!(vcpu.kvm_run_ptr.as_ref().immediate_exit, 1); } #[test] @@ -2596,7 +3149,7 @@ mod tests { let vcpu = vm.create_vcpu(0).unwrap(); if !kvm.check_extension(Cap::GetTscKhz) { - assert!(vcpu.get_tsc_khz().is_err()) + vcpu.get_tsc_khz().unwrap_err(); } else { assert!(vcpu.get_tsc_khz().unwrap() > 0); } @@ -2611,11 +3164,11 @@ mod tests { let freq = vcpu.get_tsc_khz().unwrap(); if !(kvm.check_extension(Cap::GetTscKhz) && kvm.check_extension(Cap::TscControl)) { - assert!(vcpu.set_tsc_khz(0).is_err()); + vcpu.set_tsc_khz(0).unwrap_err(); } else { - assert!(vcpu.set_tsc_khz(freq - 500000).is_ok()); + vcpu.set_tsc_khz(freq - 500000).unwrap(); assert_eq!(vcpu.get_tsc_khz().unwrap(), freq - 500000); - assert!(vcpu.set_tsc_khz(freq + 500000).is_ok()); + vcpu.set_tsc_khz(freq + 500000).unwrap(); assert_eq!(vcpu.get_tsc_khz().unwrap(), freq + 500000); } } @@ -2635,9 +3188,9 @@ mod tests { ]; for reg in &sync_regs { vcpu.set_sync_valid_reg(*reg); - assert_eq!(vcpu.kvm_run_ptr.as_mut_ref().kvm_valid_regs, *reg as u64); + assert_eq!(vcpu.kvm_run_ptr.as_ref().kvm_valid_regs, *reg as u64); vcpu.clear_sync_valid_reg(*reg); - assert_eq!(vcpu.kvm_run_ptr.as_mut_ref().kvm_valid_regs, 0); + assert_eq!(vcpu.kvm_run_ptr.as_ref().kvm_valid_regs, 0); } // Test that multiple valid SyncRegs can be set at the same time @@ -2645,7 +3198,7 @@ mod tests { vcpu.set_sync_valid_reg(SyncReg::SystemRegister); vcpu.set_sync_valid_reg(SyncReg::VcpuEvents); assert_eq!( - vcpu.kvm_run_ptr.as_mut_ref().kvm_valid_regs, + vcpu.kvm_run_ptr.as_ref().kvm_valid_regs, SyncReg::Register as u64 | SyncReg::SystemRegister as u64 | SyncReg::VcpuEvents as u64 ); @@ -2658,9 +3211,9 @@ mod tests { for reg in &sync_regs { vcpu.set_sync_dirty_reg(*reg); - assert_eq!(vcpu.kvm_run_ptr.as_mut_ref().kvm_dirty_regs, *reg as u64); + assert_eq!(vcpu.kvm_run_ptr.as_ref().kvm_dirty_regs, *reg as u64); vcpu.clear_sync_dirty_reg(*reg); - assert_eq!(vcpu.kvm_run_ptr.as_mut_ref().kvm_dirty_regs, 0); + assert_eq!(vcpu.kvm_run_ptr.as_ref().kvm_dirty_regs, 0); } // Test that multiple dirty SyncRegs can be set at the same time @@ -2668,7 +3221,7 @@ mod tests { vcpu.set_sync_dirty_reg(SyncReg::SystemRegister); vcpu.set_sync_dirty_reg(SyncReg::VcpuEvents); assert_eq!( - vcpu.kvm_run_ptr.as_mut_ref().kvm_dirty_regs, + vcpu.kvm_run_ptr.as_ref().kvm_dirty_regs, SyncReg::Register as u64 | SyncReg::SystemRegister as u64 | SyncReg::VcpuEvents as u64 ); } @@ -2689,7 +3242,7 @@ mod tests { ]; let mem_size = 0x4000; - let load_addr = mmap_anonymous(mem_size); + let load_addr = mmap_anonymous(mem_size).as_ptr(); let guest_addr: u64 = 0x1000; let slot: u32 = 0; let mem_region = kvm_userspace_memory_region { @@ -2714,7 +3267,7 @@ mod tests { let orig_sregs = vcpu.get_sregs().unwrap(); - let mut sync_regs = vcpu.sync_regs_mut(); + let sync_regs = vcpu.sync_regs_mut(); // Initialize the sregs in sync_regs to be the original sregs sync_regs.sregs = orig_sregs; @@ -2751,13 +3304,13 @@ mod tests { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); - assert!(vcpu.translate_gva(0x10000).is_ok()); + vcpu.translate_gva(0x10000).unwrap(); assert_eq!(vcpu.translate_gva(0x10000).unwrap().valid, 1); assert_eq!( vcpu.translate_gva(0x10000).unwrap().physical_address, 0x10000 ); - assert!(vcpu.translate_gva(u64::MAX).is_ok()); + vcpu.translate_gva(u64::MAX).unwrap(); assert_eq!(vcpu.translate_gva(u64::MAX).unwrap().valid, 0); } @@ -2768,22 +3321,22 @@ mod tests { let vm = kvm.create_vm().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); - let dist_attr = kvm_bindings::kvm_device_attr { + let dist_attr = kvm_device_attr { group: KVM_ARM_VCPU_PMU_V3_CTRL, attr: u64::from(KVM_ARM_VCPU_PMU_V3_INIT), addr: 0x0, flags: 0, }; - assert!(vcpu.has_device_attr(&dist_attr).is_err()); - assert!(vcpu.set_device_attr(&dist_attr).is_err()); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); + vcpu.has_device_attr(&dist_attr).unwrap_err(); + vcpu.set_device_attr(&dist_attr).unwrap_err(); + let mut kvi: kvm_vcpu_init = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi) .expect("Cannot get preferred target"); - kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2 | 1 << KVM_ARM_VCPU_PMU_V3; - assert!(vcpu.vcpu_init(&kvi).is_ok()); - assert!(vcpu.has_device_attr(&dist_attr).is_ok()); - assert!(vcpu.set_device_attr(&dist_attr).is_ok()); + kvi.features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2 | 1 << KVM_ARM_VCPU_PMU_V3; + vcpu.vcpu_init(&kvi).unwrap(); + vcpu.has_device_attr(&dist_attr).unwrap(); + vcpu.set_device_attr(&dist_attr).unwrap(); } #[test] @@ -2793,15 +3346,446 @@ mod tests { let vm = kvm.create_vm().unwrap(); let vcpu = vm.create_vcpu(0).unwrap(); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); + let mut kvi = kvm_vcpu_init::default(); vm.get_preferred_target(&mut kvi) .expect("Cannot get preferred target"); if kvm.check_extension(Cap::ArmPtrAuthAddress) { - kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PTRAUTH_ADDRESS; + kvi.features[0] |= 1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS; } if kvm.check_extension(Cap::ArmPtrAuthGeneric) { - kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PTRAUTH_GENERIC; + kvi.features[0] |= 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC; } - assert!(vcpu.vcpu_init(&kvi).is_ok()); + vcpu.vcpu_init(&kvi).unwrap(); + } + + #[cfg(target_arch = "x86_64")] + #[test] + fn test_userspace_rdmsr_exit() { + use std::io::Write; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + #[rustfmt::skip] + let code = [ + 0x0F, 0x32, /* rdmsr */ + 0xF4 /* hlt */ + ]; + + if !vm.check_extension(Cap::X86UserSpaceMsr) { + return; + } + let cap = kvm_enable_cap { + cap: Cap::X86UserSpaceMsr as u32, + args: [MsrExitReason::Unknown.bits() as u64, 0, 0, 0], + ..Default::default() + }; + vm.enable_cap(&cap).unwrap(); + + let mem_size = 0x4000; + let load_addr = mmap_anonymous(mem_size).as_ptr(); + let guest_addr: u64 = 0x1000; + let slot: u32 = 0; + let mem_region = kvm_userspace_memory_region { + slot, + guest_phys_addr: guest_addr, + memory_size: mem_size as u64, + userspace_addr: load_addr as u64, + flags: 0, + }; + unsafe { + vm.set_user_memory_region(mem_region).unwrap(); + + // Get a mutable slice of `mem_size` from `load_addr`. + // This is safe because we mapped it before. + let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size); + slice.write_all(&code).unwrap(); + } + + let mut vcpu = vm.create_vcpu(0).unwrap(); + + // Set up special registers + let mut vcpu_sregs = vcpu.get_sregs().unwrap(); + assert_ne!(vcpu_sregs.cs.base, 0); + assert_ne!(vcpu_sregs.cs.selector, 0); + vcpu_sregs.cs.base = 0; + vcpu_sregs.cs.selector = 0; + vcpu.set_sregs(&vcpu_sregs).unwrap(); + + // Set the Instruction Pointer to the guest address where we loaded + // the code, and RCX to the MSR to be read. + let mut vcpu_regs = vcpu.get_regs().unwrap(); + vcpu_regs.rip = guest_addr; + vcpu_regs.rcx = 0x474f4f00; + vcpu.set_regs(&vcpu_regs).unwrap(); + + match vcpu.run().unwrap() { + VcpuExit::X86Rdmsr(exit) => { + assert_eq!(exit.reason, MsrExitReason::Unknown); + assert_eq!(exit.index, 0x474f4f00); + } + e => panic!("Unexpected exit: {:?}", e), + } + } + + #[cfg(target_arch = "x86_64")] + #[test] + fn test_userspace_hypercall_exit() { + use std::io::Write; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + + // Use `vmcall` or `vmmcall` depending on what's supported. + let cpuid = kvm.get_supported_cpuid(KVM_MAX_CPUID_ENTRIES).unwrap(); + let supports_vmcall = cpuid + .as_slice() + .iter() + .find(|entry| entry.function == 1) + .map_or(false, |entry| entry.ecx & (1 << 5) != 0); + let supports_vmmcall = cpuid + .as_slice() + .iter() + .find(|entry| entry.function == 0x8000_0001) + .map_or(false, |entry| entry.ecx & (1 << 2) != 0); + #[rustfmt::skip] + let code = if supports_vmcall { + [ + 0x0F, 0x01, 0xC1, /* vmcall */ + 0xF4 /* hlt */ + ] + } else if supports_vmmcall { + [ + 0x0F, 0x01, 0xD9, /* vmmcall */ + 0xF4 /* hlt */ + ] + } else { + return; + }; + + if !vm.check_extension(Cap::ExitHypercall) { + return; + } + const KVM_HC_MAP_GPA_RANGE: u64 = 12; + let cap = kvm_enable_cap { + cap: Cap::ExitHypercall as u32, + args: [1 << KVM_HC_MAP_GPA_RANGE, 0, 0, 0], + ..Default::default() + }; + vm.enable_cap(&cap).unwrap(); + + let mem_size = 0x4000; + let load_addr = mmap_anonymous(mem_size).as_ptr(); + let guest_addr: u64 = 0x1000; + let slot: u32 = 0; + let mem_region = kvm_userspace_memory_region { + slot, + guest_phys_addr: guest_addr, + memory_size: mem_size as u64, + userspace_addr: load_addr as u64, + flags: 0, + }; + unsafe { + vm.set_user_memory_region(mem_region).unwrap(); + + // Get a mutable slice of `mem_size` from `load_addr`. + // This is safe because we mapped it before. + let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size); + slice.write_all(&code).unwrap(); + } + + let mut vcpu = vm.create_vcpu(0).unwrap(); + + // Set up special registers + let mut vcpu_sregs = vcpu.get_sregs().unwrap(); + assert_ne!(vcpu_sregs.cs.base, 0); + assert_ne!(vcpu_sregs.cs.selector, 0); + vcpu_sregs.cs.base = 0; + vcpu_sregs.cs.selector = 0; + vcpu.set_sregs(&vcpu_sregs).unwrap(); + + // Set the Instruction Pointer to the guest address where we loaded + // the code, and RCX to the MSR to be read. + let mut vcpu_regs = vcpu.get_regs().unwrap(); + vcpu_regs.rip = guest_addr; + vcpu_regs.rax = KVM_HC_MAP_GPA_RANGE; + vcpu_regs.rbx = 0x1234000; + vcpu_regs.rcx = 1; + vcpu_regs.rdx = 0; + vcpu.set_regs(&vcpu_regs).unwrap(); + + match vcpu.run().unwrap() { + VcpuExit::Hypercall(exit) => { + assert_eq!(exit.nr, KVM_HC_MAP_GPA_RANGE); + assert_eq!(exit.args[0], 0x1234000); + assert_eq!(exit.args[1], 1); + assert_eq!(exit.args[2], 0); + } + e => panic!("Unexpected exit: {:?}", e), + } + } + + #[cfg(target_arch = "x86_64")] + #[test] + fn test_userspace_wrmsr_exit() { + use std::io::Write; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + #[rustfmt::skip] + let code = [ + 0x0F, 0x30, /* wrmsr */ + 0xF4 /* hlt */ + ]; + + if !vm.check_extension(Cap::X86UserSpaceMsr) { + return; + } + let cap = kvm_enable_cap { + cap: Cap::X86UserSpaceMsr as u32, + args: [MsrExitReason::Unknown.bits() as u64, 0, 0, 0], + ..Default::default() + }; + vm.enable_cap(&cap).unwrap(); + + let mem_size = 0x4000; + let load_addr = mmap_anonymous(mem_size).as_ptr(); + let guest_addr: u64 = 0x1000; + let slot: u32 = 0; + let mem_region = kvm_userspace_memory_region { + slot, + guest_phys_addr: guest_addr, + memory_size: mem_size as u64, + userspace_addr: load_addr as u64, + flags: 0, + }; + unsafe { + vm.set_user_memory_region(mem_region).unwrap(); + + // Get a mutable slice of `mem_size` from `load_addr`. + // This is safe because we mapped it before. + let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size); + slice.write_all(&code).unwrap(); + } + + let mut vcpu = vm.create_vcpu(0).unwrap(); + + // Set up special registers + let mut vcpu_sregs = vcpu.get_sregs().unwrap(); + assert_ne!(vcpu_sregs.cs.base, 0); + assert_ne!(vcpu_sregs.cs.selector, 0); + vcpu_sregs.cs.base = 0; + vcpu_sregs.cs.selector = 0; + vcpu.set_sregs(&vcpu_sregs).unwrap(); + + // Set the Instruction Pointer to the guest address where we loaded + // the code, RCX to the MSR to be written, and EDX:EAX to the data to + // be written. + let mut vcpu_regs = vcpu.get_regs().unwrap(); + vcpu_regs.rip = guest_addr; + vcpu_regs.rcx = 0x474f4f00; + vcpu_regs.rax = 0xdeadbeef; + vcpu_regs.rdx = 0xd0c0ffee; + vcpu.set_regs(&vcpu_regs).unwrap(); + + match vcpu.run().unwrap() { + VcpuExit::X86Wrmsr(exit) => { + assert_eq!(exit.reason, MsrExitReason::Unknown); + assert_eq!(exit.index, 0x474f4f00); + assert_eq!(exit.data & 0xffffffff, 0xdeadbeef); + assert_eq!((exit.data >> 32) & 0xffffffff, 0xd0c0ffee); + } + e => panic!("Unexpected exit: {:?}", e), + } + } + + #[test] + #[cfg(target_arch = "x86_64")] + fn test_coalesced_pio() { + use crate::IoEventAddress; + use std::io::Write; + + const PORT: u64 = 0x2c; + const DATA: u64 = 0x39; + const SIZE: u32 = 1; + + #[rustfmt::skip] + let code = [ + 0xe6, 0x2c, // out 0x2c, al + 0xf4, // hlt + 0xe6, 0x2c, // out 0x2c, al + 0xf4, // hlt + ]; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + assert!(vm.check_extension(Cap::CoalescedPio)); + + // Prepare guest memory + let mem_size = 0x4000; + let load_addr = mmap_anonymous(mem_size).as_ptr(); + let guest_addr: u64 = 0x1000; + let slot = 0; + let mem_region = kvm_userspace_memory_region { + slot, + guest_phys_addr: guest_addr, + memory_size: mem_size as u64, + userspace_addr: load_addr as u64, + flags: 0, + }; + + unsafe { + vm.set_user_memory_region(mem_region).unwrap(); + + // Get a mutable slice of `mem_size` from `load_addr`. + // This is safe because we mapped it before. + let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size); + slice.write_all(&code).unwrap(); + } + + let addr = IoEventAddress::Pio(PORT); + vm.register_coalesced_mmio(addr, SIZE).unwrap(); + + let mut vcpu = vm.create_vcpu(0).unwrap(); + + // Map the MMIO ring + vcpu.map_coalesced_mmio_ring().unwrap(); + + // Set regs + let mut regs = vcpu.get_regs().unwrap(); + regs.rip = guest_addr; + regs.rax = DATA; + regs.rflags = 2; + vcpu.set_regs(®s).unwrap(); + + // Set sregs + let mut sregs = vcpu.get_sregs().unwrap(); + sregs.cs.base = 0; + sregs.cs.selector = 0; + vcpu.set_sregs(&sregs).unwrap(); + + // Run and check that the exit was caused by the hlt and not the port + // I/O + let exit = vcpu.run().unwrap(); + assert!(matches!(exit, VcpuExit::Hlt)); + + // Check that the ring buffer entry is what we expect + let entry = vcpu.coalesced_mmio_read().unwrap().unwrap(); + assert_eq!(entry.phys_addr, PORT); + assert_eq!(entry.len, 1); + assert_eq!(entry.data[0] as u64, DATA); + // SAFETY: this field is a u32 in all variants of the union, + // so access is always safe. + let pio = unsafe { entry.__bindgen_anon_1.pio }; + assert_eq!(pio, 1); + + // The ring buffer should be empty now + assert!(vcpu.coalesced_mmio_read().unwrap().is_none()); + + // Unregister and check that the next PIO write triggers an exit + vm.unregister_coalesced_mmio(addr, SIZE).unwrap(); + let exit = vcpu.run().unwrap(); + let VcpuExit::IoOut(port, data) = exit else { + panic!("Unexpected VM exit: {:?}", exit); + }; + assert_eq!(port, PORT as u16); + assert_eq!(data, (DATA as u8).to_le_bytes()); + } + + #[test] + #[cfg(target_arch = "x86_64")] + fn test_coalesced_mmio() { + use crate::IoEventAddress; + use std::io::Write; + + const ADDR: u64 = 0x124; + const DATA: u64 = 0x39; + const SIZE: u32 = 2; + + #[rustfmt::skip] + let code = [ + 0x66, 0x31, 0xFF, // xor di,di + 0x66, 0xBF, 0x24, 0x01, // mov di, 0x124 + 0x67, 0x66, 0x89, 0x05, // mov WORD PTR [di], ax + 0xF4, // hlt + 0x66, 0x31, 0xFF, // xor di,di + 0x66, 0xBF, 0x24, 0x01, // mov di, 0x124 + 0x67, 0x66, 0x89, 0x05, // mov WORD PTR [di], ax + 0xF4, // hlt + ]; + + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + assert!(vm.check_extension(Cap::CoalescedMmio)); + + // Prepare guest memory + let mem_size = 0x4000; + let load_addr = mmap_anonymous(mem_size).as_ptr(); + let guest_addr: u64 = 0x1000; + let slot: u32 = 0; + let mem_region = kvm_userspace_memory_region { + slot, + guest_phys_addr: guest_addr, + memory_size: mem_size as u64, + userspace_addr: load_addr as u64, + flags: 0, + }; + + unsafe { + vm.set_user_memory_region(mem_region).unwrap(); + + // Get a mutable slice of `mem_size` from `load_addr`. + // This is safe because we mapped it before. + let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size); + slice.write_all(&code).unwrap(); + } + + let addr = IoEventAddress::Mmio(ADDR); + vm.register_coalesced_mmio(addr, SIZE).unwrap(); + + let mut vcpu = vm.create_vcpu(0).unwrap(); + + // Map the MMIO ring + vcpu.map_coalesced_mmio_ring().unwrap(); + + // Set regs + let mut regs = vcpu.get_regs().unwrap(); + regs.rip = guest_addr; + regs.rax = DATA; + regs.rdx = ADDR; + regs.rflags = 2; + vcpu.set_regs(®s).unwrap(); + + // Set sregs + let mut sregs = vcpu.get_sregs().unwrap(); + sregs.cs.base = 0; + sregs.cs.selector = 0; + vcpu.set_sregs(&sregs).unwrap(); + + // Run and check that the exit was caused by the hlt and not the MMIO + // access + let exit = vcpu.run().unwrap(); + assert!(matches!(exit, VcpuExit::Hlt)); + + // Check that the ring buffer entry is what we expect + let entry = vcpu.coalesced_mmio_read().unwrap().unwrap(); + assert_eq!(entry.phys_addr, ADDR); + assert_eq!(entry.len, SIZE); + assert_eq!(entry.data[0] as u64, DATA); + // SAFETY: this field is a u32 in all variants of the union, + // so access is always safe. + let pio = unsafe { entry.__bindgen_anon_1.pio }; + assert_eq!(pio, 0); + + // The ring buffer should be empty now + assert!(vcpu.coalesced_mmio_read().unwrap().is_none()); + + // Unregister and check that the next MMIO write triggers an exit + vm.unregister_coalesced_mmio(addr, SIZE).unwrap(); + let exit = vcpu.run().unwrap(); + let VcpuExit::MmioWrite(addr, data) = exit else { + panic!("Unexpected VM exit: {:?}", exit); + }; + assert_eq!(addr, ADDR); + assert_eq!(data, (DATA as u16).to_le_bytes()); } } diff --git a/vendor/kvm-ioctls/src/ioctls/vm.rs b/vendor/kvm-ioctls/src/ioctls/vm.rs index 6b9dc9c..39938ae 100644 --- a/vendor/kvm-ioctls/src/ioctls/vm.rs +++ b/vendor/kvm-ioctls/src/ioctls/vm.rs @@ -1,3 +1,5 @@ +// Copyright © 2024 Institute of Software, CAS. All rights reserved. +// // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT // @@ -20,15 +22,17 @@ use crate::ioctls::{KvmRunWrapper, Result}; use crate::kvm_ioctls::*; use vmm_sys_util::errno; use vmm_sys_util::eventfd::EventFd; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +use vmm_sys_util::ioctl::ioctl; +#[cfg(target_arch = "x86_64")] use vmm_sys_util::ioctl::ioctl_with_mut_ptr; -use vmm_sys_util::ioctl::{ioctl, ioctl_with_mut_ref, ioctl_with_ref, ioctl_with_val}; +use vmm_sys_util::ioctl::{ioctl_with_mut_ref, ioctl_with_ref, ioctl_with_val}; /// An address either in programmable I/O space or in memory mapped I/O space. /// /// The `IoEventAddress` is used for specifying the type when registering an event /// in [register_ioevent](struct.VmFd.html#method.register_ioevent). -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub enum IoEventAddress { /// Representation of an programmable I/O address. Pio(u64), @@ -42,7 +46,7 @@ pub enum IoEventAddress { /// [`register_ioevent`](struct.VmFd.html#method.register_ioevent) /// to disable filtering of events based on the datamatch flag. For details check the /// [KVM API documentation](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt). -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct NoDatamatch; impl From for u64 { fn from(_: NoDatamatch) -> u64 { @@ -111,6 +115,98 @@ impl VmFd { } } + /// Creates/modifies a guest physical memory slot. + /// + /// See the documentation for `KVM_SET_USER_MEMORY_REGION2`. + /// + /// # Arguments + /// + /// * `user_memory_region2` - Guest physical memory slot. For details check the + /// `kvm_userspace_memory_region2` structure in the + /// [KVM API doc](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt). + /// + /// # Safety + /// + /// This function is unsafe because there is no guarantee `userspace_addr` points to a valid + /// memory region, nor the memory region lives as long as the kernel needs it to. + /// + /// The caller of this method must make sure that: + /// - the raw pointer (`userspace_addr`) points to valid memory + /// - the regions provided to KVM are not overlapping other memory regions. + /// - the guest_memfd points at a file created via KVM_CREATE_GUEST_MEMFD on + /// the current VM, and the target range must not be bound to any other memory region + /// + /// # Example + /// + /// ```rust + /// # extern crate kvm_ioctls; + /// extern crate kvm_bindings; + /// + /// use kvm_bindings::{ + /// kvm_create_guest_memfd, kvm_enable_cap, kvm_userspace_memory_region2, KVM_CAP_GUEST_MEMFD, + /// KVM_CAP_USER_MEMORY2, KVM_MEM_GUEST_MEMFD, + /// }; + /// use kvm_ioctls::Kvm; + /// use std::os::fd::RawFd; + /// + /// # #[cfg(target_arch = "x86_64")] + /// { + /// let kvm = Kvm::new().unwrap(); + /// let vm = kvm.create_vm().unwrap(); + /// + /// let address_space = unsafe { libc::mmap(0 as _, 10000, 3, 34, -1, 0) }; + /// let userspace_addr = address_space as *const u8 as u64; + /// + /// let mut config = kvm_enable_cap { + /// cap: KVM_CAP_GUEST_MEMFD, + /// ..Default::default() + /// }; + /// + /// if vm.enable_cap(&config).is_err() { + /// return; + /// } + /// let gmem = kvm_create_guest_memfd { + /// size: 0x10000, + /// flags: 0, + /// reserved: [0; 6], + /// }; + /// + /// let fd: RawFd = unsafe { vm.create_guest_memfd(gmem).unwrap() }; + /// + /// config.cap = KVM_CAP_USER_MEMORY2; + /// + /// if vm.enable_cap(&config).is_err() { + /// return; + /// } + /// + /// let mem_region = kvm_userspace_memory_region2 { + /// slot: 0, + /// flags: KVM_MEM_GUEST_MEMFD, + /// guest_phys_addr: 0x10000 as u64, + /// memory_size: 0x10000 as u64, + /// userspace_addr, + /// guest_memfd_offset: 0, + /// guest_memfd: fd as u32, + /// pad1: 0, + /// pad2: [0; 14], + /// }; + /// unsafe { + /// vm.set_user_memory_region2(mem_region).unwrap(); + /// }; + /// } + /// ``` + pub unsafe fn set_user_memory_region2( + &self, + user_memory_region2: kvm_userspace_memory_region2, + ) -> Result<()> { + let ret = ioctl_with_ref(self, KVM_SET_USER_MEMORY_REGION2(), &user_memory_region2); + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } + /// Sets the address of the three-page region in the VM's address space. /// /// See the documentation for `KVM_SET_TSS_ADDR`. @@ -128,7 +224,7 @@ impl VmFd { /// let vm = kvm.create_vm().unwrap(); /// vm.set_tss_address(0xfffb_d000).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_tss_address(&self, offset: usize) -> Result<()> { // SAFETY: Safe because we know that our file is a VM fd and we verify the return result. let ret = unsafe { ioctl_with_val(self, KVM_SET_TSS_ADDR(), offset as c_ulong) }; @@ -156,7 +252,7 @@ impl VmFd { /// let vm = kvm.create_vm().unwrap(); /// vm.set_identity_map_address(0xfffb_c000).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_identity_map_address(&self, address: u64) -> Result<()> { // SAFETY: Safe because we know that our file is a VM fd and we verify the return result. let ret = unsafe { ioctl_with_ref(self, KVM_SET_IDENTITY_MAP_ADDR(), &address) }; @@ -180,9 +276,9 @@ impl VmFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// vm.create_irq_chip().unwrap(); - /// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + /// #[cfg(target_arch = "aarch64")] /// { /// use kvm_bindings::{ /// kvm_create_device, kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2, KVM_CREATE_DEVICE_TEST, @@ -197,12 +293,7 @@ impl VmFd { /// } /// } /// ``` - #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" - ))] + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] pub fn create_irq_chip(&self) -> Result<()> { // SAFETY: Safe because we know that our file is a VM fd and we verify the return result. let ret = unsafe { ioctl(self, KVM_CREATE_IRQCHIP()) }; @@ -237,7 +328,7 @@ impl VmFd { /// irqchip.chip_id = KVM_IRQCHIP_PIC_MASTER; /// vm.get_irqchip(&mut irqchip).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_irqchip(&self, irqchip: &mut kvm_irqchip) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_irqchip struct. let ret = unsafe { ioctl_with_mut_ref(self, KVM_GET_IRQCHIP(), irqchip) }; @@ -273,7 +364,7 @@ impl VmFd { /// // Your `irqchip` manipulation here. /// vm.set_irqchip(&mut irqchip).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_irqchip(&self, irqchip: &kvm_irqchip) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_irqchip struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_IRQCHIP(), irqchip) }; @@ -300,10 +391,11 @@ impl VmFd { /// /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); + /// vm.create_irq_chip().unwrap(); /// let pit_config = kvm_pit_config::default(); /// vm.create_pit2(pit_config).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn create_pit2(&self, pit_config: kvm_pit_config) -> Result<()> { // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only read // the correct amount of memory from our pointer, and we verify the return result. @@ -333,12 +425,13 @@ impl VmFd { /// # use kvm_ioctls::Kvm; /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); + /// vm.create_irq_chip().unwrap(); /// /// let pit_config = kvm_pit_config::default(); /// vm.create_pit2(pit_config).unwrap(); /// let pitstate = vm.get_pit2().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_pit2(&self) -> Result { let mut pitstate = Default::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_pit_state2 struct. @@ -368,6 +461,7 @@ impl VmFd { /// # use kvm_ioctls::Kvm; /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); + /// vm.create_irq_chip().unwrap(); /// /// let pit_config = kvm_pit_config::default(); /// vm.create_pit2(pit_config).unwrap(); @@ -375,7 +469,7 @@ impl VmFd { /// // Your `pitstate` manipulation here. /// vm.set_pit2(&mut pitstate).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_pit2(&self, pitstate: &kvm_pit_state2) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_pit_state2 struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_PIT2(), pitstate) }; @@ -404,7 +498,7 @@ impl VmFd { /// let vm = kvm.create_vm().unwrap(); /// let clock = vm.get_clock().unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn get_clock(&self) -> Result { let mut clock = Default::default(); // SAFETY: Here we trust the kernel not to read past the end of the kvm_clock_data struct. @@ -437,7 +531,7 @@ impl VmFd { /// let mut clock = kvm_clock_data::default(); /// vm.set_clock(&mut clock).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn set_clock(&self, clock: &kvm_clock_data) -> Result<()> { // SAFETY: Here we trust the kernel not to read past the end of the kvm_clock_data struct. let ret = unsafe { ioctl_with_ref(self, KVM_SET_CLOCK(), clock) }; @@ -478,15 +572,14 @@ impl VmFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let msi = kvm_msi::default(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// vm.create_irq_chip().unwrap(); /// //vm.signal_msi(msi).unwrap(); /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] pub fn signal_msi(&self, msi: kvm_msi) -> Result { // SAFETY: Safe because we allocated the structure and we know the kernel @@ -523,17 +616,25 @@ impl VmFd { /// /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// + /// #[cfg(target_arch = "x86_64")] /// vm.create_irq_chip().unwrap(); /// + /// #[cfg(target_arch = "riscv64")] + /// vm.create_device(&mut kvm_bindings::kvm_create_device { + /// type_: kvm_bindings::kvm_device_type_KVM_DEV_TYPE_RISCV_AIA, + /// fd: 0, + /// flags: 0, + /// }) + /// .expect("Cannot create KVM vAIA device."); + /// /// let irq_routing = kvm_irq_routing::default(); /// vm.set_gsi_routing(&irq_routing).unwrap(); /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] pub fn set_gsi_routing(&self, irq_routing: &kvm_irq_routing) -> Result<()> { // SAFETY: Safe because we allocated the structure and we know the kernel @@ -738,7 +839,7 @@ impl VmFd { /// }; /// unsafe { vm.set_user_memory_region(mem_region).unwrap() }; /// - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// // ASM code that just forces a MMIO Write. /// let asm_code = [0xc6, 0x06, 0x00, 0x80, 0x00]; /// #[cfg(target_arch = "aarch64")] @@ -749,6 +850,13 @@ impl VmFd { /// 0x00, 0x00, 0x00, /// 0x14, /* b ; shouldn't get here, but if so loop forever */ /// ]; + /// #[cfg(target_arch = "riscv64")] + /// let asm_code = [ + /// 0x17, 0x03, 0x00, 0x00, // auipc t1, 0; -> t1 + /// 0xa3, 0x23, 0x73, 0x00, // sw t2, t1 + 7; dirty current page + /// 0x23, 0x20, 0x75, 0x00, // sw t2, a0; trigger MMIO exit + /// 0x6f, 0x00, 0x00, 0x00, // j .;shouldn't get here, but if so loop forever + /// ]; /// /// // Write the code in the guest memory. This will generate a dirty page. /// unsafe { @@ -756,9 +864,9 @@ impl VmFd { /// slice.write(&asm_code).unwrap(); /// } /// - /// let vcpu_fd = vm.create_vcpu(0).unwrap(); + /// let mut vcpu_fd = vm.create_vcpu(0).unwrap(); /// - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// { /// // x86_64 specific registry setup. /// let mut vcpu_sregs = vcpu_fd.get_sregs().unwrap(); @@ -788,6 +896,14 @@ impl VmFd { /// vcpu_fd.set_one_reg(core_reg_base + 2 * 0, &mmio_addr.to_le_bytes()); // set X0 /// } /// + /// #[cfg(target_arch = "riscv64")] + /// { + /// let core_reg_base: u64 = 0x8030_0000_0200_0000; + /// let mmio_addr: u64 = guest_addr + mem_size as u64; + /// vcpu_fd.set_one_reg(core_reg_base, &guest_addr.to_le_bytes()); // set PC + /// vcpu_fd.set_one_reg(core_reg_base + 10, &mmio_addr.to_le_bytes()); // set A0 + /// } + /// /// loop { /// match vcpu_fd.run().expect("run failed") { /// VcpuExit::MmioWrite(addr, data) => { @@ -818,8 +934,7 @@ impl VmFd { // For ease of access we are saving the bitmap in a u64 vector. We are using ceil to // make sure we count all dirty pages even when `memory_size` is not a multiple of // `page_size * 64`. - let div_ceil = |dividend, divisor| (dividend + divisor - 1) / divisor; - let bitmap_size = div_ceil(memory_size, page_size * 64); + let bitmap_size = memory_size.div_ceil(page_size * 64); let mut bitmap = vec![0u64; bitmap_size]; let dirtylog = kvm_dirty_log { slot, @@ -857,17 +972,16 @@ impl VmFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// let evtfd = EventFd::new(EFD_NONBLOCK).unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// { /// vm.create_irq_chip().unwrap(); /// vm.register_irqfd(&evtfd, 0).unwrap(); /// } /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] pub fn register_irqfd(&self, fd: &EventFd, gsi: u32) -> Result<()> { let irqfd = kvm_irqfd { @@ -908,7 +1022,7 @@ impl VmFd { /// let vm = kvm.create_vm().unwrap(); /// let evtfd = EventFd::new(EFD_NONBLOCK).unwrap(); /// let resamplefd = EventFd::new(EFD_NONBLOCK).unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// { /// vm.create_irq_chip().unwrap(); /// vm.register_irqfd_with_resample(&evtfd, &resamplefd, 0) @@ -916,10 +1030,9 @@ impl VmFd { /// } /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] pub fn register_irqfd_with_resample( &self, @@ -964,7 +1077,7 @@ impl VmFd { /// let vm = kvm.create_vm().unwrap(); /// let evtfd = EventFd::new(EFD_NONBLOCK).unwrap(); /// let resamplefd = EventFd::new(EFD_NONBLOCK).unwrap(); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// { /// vm.create_irq_chip().unwrap(); /// vm.register_irqfd(&evtfd, 0).unwrap(); @@ -975,10 +1088,9 @@ impl VmFd { /// } /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] pub fn unregister_irqfd(&self, fd: &EventFd, gsi: u32) -> Result<()> { let irqfd = kvm_irqfd { @@ -1020,12 +1132,12 @@ impl VmFd { /// fn arch_setup(vm_fd: &VmFd) { /// // Arch-specific setup: /// // For x86 architectures, it simply means calling vm.create_irq_chip().unwrap(). - /// # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// # #[cfg(target_arch = "x86_64")] /// # vm_fd.create_irq_chip().unwrap(); /// // For Arm architectures, the IRQ controllers need to be setup first. /// // Details please refer to the kernel documentation. /// // https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt - /// # #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + /// # #[cfg(target_arch = "aarch64")] { /// # vm_fd.create_vcpu(0).unwrap(); /// # // ... rest of setup for Arm goes here /// # } @@ -1034,22 +1146,21 @@ impl VmFd { /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); /// arch_setup(&vm); - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// { /// vm.set_irq_line(4, true); /// // ... /// } - /// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + /// #[cfg(target_arch = "aarch64")] /// { /// vm.set_irq_line(0x01_00_0020, true); /// // .... /// } /// ``` #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] pub fn set_irq_line(&self, irq: u32, active: bool) -> Result<()> { let mut irq_level = kvm_irq_level::default(); @@ -1159,7 +1270,8 @@ impl VmFd { /// # use kvm_ioctls::Kvm; /// use kvm_bindings::{ /// kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2, kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3, - /// kvm_device_type_KVM_DEV_TYPE_VFIO, KVM_CREATE_DEVICE_TEST, + /// kvm_device_type_KVM_DEV_TYPE_RISCV_AIA, kvm_device_type_KVM_DEV_TYPE_VFIO, + /// KVM_CREATE_DEVICE_TEST, /// }; /// let kvm = Kvm::new().unwrap(); /// let vm = kvm.create_vm().unwrap(); @@ -1168,29 +1280,33 @@ impl VmFd { /// // whether the device type is supported. This will not create the device. /// // To create the device the flag needs to be removed. /// let mut device = kvm_bindings::kvm_create_device { - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// type_: kvm_device_type_KVM_DEV_TYPE_VFIO, - /// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + /// #[cfg(target_arch = "aarch64")] /// type_: kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3, + /// #[cfg(target_arch = "riscv64")] + /// type_: kvm_device_type_KVM_DEV_TYPE_RISCV_AIA, /// fd: 0, /// flags: KVM_CREATE_DEVICE_TEST, /// }; /// // On ARM, creating VGICv3 may fail due to hardware dependency. /// // Retry to create VGICv2 in that case. /// let device_fd = vm.create_device(&mut device).unwrap_or_else(|_| { - /// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + /// #[cfg(target_arch = "x86_64")] /// panic!("Cannot create VFIO device."); - /// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + /// #[cfg(target_arch = "aarch64")] /// { /// device.type_ = kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2; /// vm.create_device(&mut device) /// .expect("Cannot create vGIC device") /// } + /// #[cfg(target_arch = "riscv64")] + /// panic!("Cannot create vAIA device."); /// }); /// ``` pub fn create_device(&self, device: &mut kvm_create_device) -> Result { // SAFETY: Safe because we are calling this with the VM fd and we trust the kernel. - let ret = unsafe { ioctl_with_ref(self, KVM_CREATE_DEVICE(), device) }; + let ret = unsafe { ioctl_with_mut_ref(self, KVM_CREATE_DEVICE(), device) }; if ret == 0 { // SAFETY: We validated the return of the function creating the fd and we trust the // kernel. @@ -1222,7 +1338,7 @@ impl VmFd { /// let mut kvi = kvm_vcpu_init::default(); /// vm.get_preferred_target(&mut kvi).unwrap(); /// ``` - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] pub fn get_preferred_target(&self, kvi: &mut kvm_vcpu_init) -> Result<()> { // SAFETY: The ioctl is safe because we allocated the struct and we know the // kernel will write exactly the size of the struct. @@ -1259,7 +1375,7 @@ impl VmFd { /// let mut cap: kvm_enable_cap = Default::default(); /// // This example cannot enable an arm/aarch64 capability since there /// // is no capability available for these architectures. - /// if cfg!(target_arch = "x86") || cfg!(target_arch = "x86_64") { + /// if cfg!(target_arch = "x86_64") { /// cap.cap = KVM_CAP_SPLIT_IRQCHIP; /// // As per the KVM documentation, KVM_CAP_SPLIT_IRQCHIP only emulates /// // the local APIC in kernel, expecting that a userspace IOAPIC will @@ -1276,7 +1392,7 @@ impl VmFd { /// vm.enable_cap(&cap).unwrap(); /// } /// ``` - #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] + #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] pub fn enable_cap(&self, cap: &kvm_enable_cap) -> Result<()> { // SAFETY: The ioctl is safe because we allocated the struct and we know the // kernel will write exactly the size of the struct. @@ -1326,6 +1442,156 @@ impl VmFd { self.check_extension_int(c) > 0 } + /// Creates an anonymous file and returns a file descriptor that refers to it. + /// + /// See the documentation for `KVM_CREATE_GUEST_MEMFD`. + /// + /// Returns an io::Error when the file could not be created. + /// + /// # Arguments + /// + /// * kvm_create_guest_memfd - KVM create guest memfd structure. For details check the + /// `kvm_create_guest_memfd` structure in the + /// [KVM API doc](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt). + /// + /// # Example + /// + /// ```rust + /// # extern crate kvm_ioctls; + /// extern crate kvm_bindings; + /// + /// # use kvm_ioctls::Kvm; + /// use kvm_bindings::{kvm_create_guest_memfd, kvm_enable_cap, KVM_CAP_GUEST_MEMFD}; + /// use std::os::fd::RawFd; + /// + /// # #[cfg(target_arch = "x86_64")] + /// { + /// let kvm = Kvm::new().unwrap(); + /// let vm = kvm.create_vm().unwrap(); + /// + /// let config = kvm_enable_cap { + /// cap: KVM_CAP_GUEST_MEMFD, + /// ..Default::default() + /// }; + /// + /// if vm.enable_cap(&config).is_err() { + /// return; + /// } + /// + /// let gmem = kvm_create_guest_memfd { + /// size: 0x1000, + /// flags: 0, + /// reserved: [0; 6], + /// }; + /// + /// let id: RawFd = vm.create_guest_memfd(gmem).unwrap(); + /// } + /// ``` + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + pub fn create_guest_memfd(&self, gmem: kvm_create_guest_memfd) -> Result { + // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only + // read the correct amount of memory from our pointer, and we verify the return result. + let ret = unsafe { ioctl_with_ref(self, KVM_CREATE_GUEST_MEMFD(), &gmem) }; + if ret < 0 { + return Err(errno::Error::last()); + } + Ok(ret) + } + + /// Allows userspace to set memory attributes for a range of guest physical memory. + /// + /// See the documentation for `KVM_SET_MEMORY_ATTRIBUTES`. + /// + /// Returns an io::Error when the attributes could not be set. + /// + /// # Arguments + /// + /// * kvm_memory_attributes - KVM set memory attributes structure. For details check the + /// `kvm_memory_attributes` structure in the + /// [KVM API doc](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt). + /// + /// # Example + /// + /// ```rust + /// # extern crate kvm_ioctls; + /// extern crate kvm_bindings; + /// + /// # use kvm_ioctls::Kvm; + /// use kvm_bindings::{ + /// kvm_create_guest_memfd, kvm_enable_cap, kvm_memory_attributes, + /// kvm_userspace_memory_region2, KVM_CAP_GUEST_MEMFD, KVM_CAP_MEMORY_ATTRIBUTES, + /// KVM_CAP_USER_MEMORY2, KVM_MEMORY_ATTRIBUTE_PRIVATE, KVM_MEM_GUEST_MEMFD, + /// }; + /// use std::os::fd::RawFd; + /// + /// # #[cfg(target_arch = "x86_64")] + /// { + /// let kvm = Kvm::new().unwrap(); + /// let vm = kvm.create_vm().unwrap(); + /// let gmem = kvm_create_guest_memfd { + /// size: 0x10000, + /// flags: 0, + /// reserved: [0; 6], + /// }; + /// + /// let address_space = unsafe { libc::mmap(0 as _, 10000, 3, 34, -1, 0) }; + /// let userspace_addr = address_space as *const u8 as u64; + /// let mut config = kvm_enable_cap { + /// cap: KVM_CAP_GUEST_MEMFD, + /// ..Default::default() + /// }; + /// + /// if vm.enable_cap(&config).is_err() { + /// return; + /// } + /// + /// config.cap = KVM_CAP_USER_MEMORY2; + /// + /// if vm.enable_cap(&config).is_err() { + /// return; + /// } + /// config.cap = KVM_CAP_MEMORY_ATTRIBUTES; + /// + /// if vm.enable_cap(&config).is_err() { + /// return; + /// } + /// let fd: RawFd = unsafe { vm.create_guest_memfd(gmem).unwrap() }; + /// let mem_region = kvm_userspace_memory_region2 { + /// slot: 0, + /// flags: KVM_MEM_GUEST_MEMFD, + /// guest_phys_addr: 0x10000 as u64, + /// memory_size: 0x10000 as u64, + /// userspace_addr, + /// guest_memfd_offset: 0, + /// guest_memfd: fd as u32, + /// pad1: 0, + /// pad2: [0; 14], + /// }; + /// unsafe { + /// vm.set_user_memory_region2(mem_region).unwrap(); + /// }; + /// + /// let attr = kvm_memory_attributes { + /// address: 0x10000, + /// size: 0x10000, + /// attributes: KVM_MEMORY_ATTRIBUTE_PRIVATE as u64, + /// flags: 0, + /// }; + /// vm.set_memory_attributes(attr).unwrap(); + /// } + /// ``` + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + pub fn set_memory_attributes(&self, attr: kvm_memory_attributes) -> Result<()> { + // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only read + // the correct amount of memory from our pointer, and we verify the return result. + let ret = unsafe { ioctl_with_ref(self, KVM_SET_MEMORY_ATTRIBUTES(), &attr) }; + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } + /// Issues platform-specific memory encryption commands to manage encrypted VMs if /// the platform supports creating those encrypted VMs. /// @@ -1362,7 +1628,7 @@ impl VmFd { /// let mut init: kvm_sev_cmd = Default::default(); /// unsafe { vm.encrypt_op(&mut init).unwrap() }; /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub unsafe fn encrypt_op(&self, op: *mut T) -> Result<()> { let ret = ioctl_with_mut_ptr(self, KVM_MEMORY_ENCRYPT_OP(), op); if ret == 0 { @@ -1398,13 +1664,13 @@ impl VmFd { /// let vm = kvm.create_vm().unwrap(); /// /// // Check whether SEV is enabled, optional. - /// assert!(unsafe { vm.encrypt_op(null_mut() as *mut c_void) }.is_ok()); + /// unsafe { vm.encrypt_op(null_mut() as *mut c_void) }.unwrap(); /// /// // Initialize the SEV platform context. /// let mut init: kvm_sev_cmd = Default::default(); /// vm.encrypt_op_sev(&mut init).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn encrypt_op_sev(&self, op: &mut kvm_sev_cmd) -> Result<()> { // SAFETY: Safe because we know that kernel will only read the correct amount of memory // from our pointer and we know where it will write it (op.error). @@ -1444,7 +1710,7 @@ impl VmFd { /// /// // Initialize the SEV platform context. /// let mut init: kvm_sev_cmd = Default::default(); - /// assert!(vm.encrypt_op_sev(&mut init).is_ok()); + /// vm.encrypt_op_sev(&mut init).unwrap(); /// /// // Create the memory encryption context. /// let start_data: kvm_sev_launch_start = Default::default(); @@ -1454,7 +1720,7 @@ impl VmFd { /// sev_fd: sev.as_raw_fd() as _, /// ..Default::default() /// }; - /// assert!(vm.encrypt_op_sev(&mut start).is_ok()); + /// vm.encrypt_op_sev(&mut start).unwrap(); /// /// let addr = unsafe { /// libc::mmap( @@ -1474,7 +1740,7 @@ impl VmFd { /// }; /// vm.register_enc_memory_region(&memory_region).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn register_enc_memory_region(&self, memory_region: &kvm_enc_region) -> Result<()> { // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only read // the correct amount of memory from our pointer, and we verify the return result. @@ -1520,7 +1786,7 @@ impl VmFd { /// /// // Initialize the SEV platform context. /// let mut init: kvm_sev_cmd = Default::default(); - /// assert!(vm.encrypt_op_sev(&mut init).is_ok()); + /// vm.encrypt_op_sev(&mut init).unwrap(); /// /// // Create the memory encryption context. /// let start_data: kvm_sev_launch_start = Default::default(); @@ -1530,7 +1796,7 @@ impl VmFd { /// sev_fd: sev.as_raw_fd() as _, /// ..Default::default() /// }; - /// assert!(vm.encrypt_op_sev(&mut start).is_ok()); + /// vm.encrypt_op_sev(&mut start).unwrap(); /// /// let addr = unsafe { /// libc::mmap( @@ -1551,7 +1817,7 @@ impl VmFd { /// vm.register_enc_memory_region(&memory_region).unwrap(); /// vm.unregister_enc_memory_region(&memory_region).unwrap(); /// ``` - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] pub fn unregister_enc_memory_region(&self, memory_region: &kvm_enc_region) -> Result<()> { // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only read // the correct amount of memory from our pointer, and we verify the return result. @@ -1562,6 +1828,68 @@ impl VmFd { Err(errno::Error::last()) } } + + /// Registers an address for coalesced MMIO. Write accesses to the address + /// will not cause a corresponding [`VcpuExit`](crate::VcpuExit), but + /// instead will be appended to the MMIO ring buffer. The [`VcpuFd`] can + /// read entries in the ring buffer via [`VcpuFd::coalesced_mmio_read()`]. + /// If entries are not read the buffer will eventually be full, + /// preventing further elements from being appended by the kernel. + /// + /// Needs `KVM_CAP_COALESCED_MMIO` ([`Cap::CoalescedMmio`](crate::Cap::CoalescedMmio)) + /// and/or `KVM_CAP_COALESCED_PIO` ([`Cap::CoalescedMmio`](crate::Cap::CoalescedPio)). + /// + /// See the documentation for `KVM_REGISTER_COALESCED_MMIO`. + /// + /// # Arguments + /// + /// * `addr` - Address being written to. + /// * `size` - The size of the write for the mechanism to trigger. + pub fn register_coalesced_mmio(&self, addr: IoEventAddress, size: u32) -> Result<()> { + let (addr, pio) = match addr { + IoEventAddress::Pio(addr) => (addr, 1), + IoEventAddress::Mmio(addr) => (addr, 0), + }; + let mut zone = kvm_coalesced_mmio_zone { + addr, + size, + ..Default::default() + }; + zone.__bindgen_anon_1.pio = pio; + + // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only read + // the correct amount of memory from our pointer, and we verify the return result. + let ret = unsafe { ioctl_with_ref(self, KVM_REGISTER_COALESCED_MMIO(), &zone) }; + if ret != 0 { + return Err(errno::Error::last()); + } + Ok(()) + } + + /// Unregister an address that was previously registered via + /// [`register_coalesced_mmio()`](VmFd::register_coalesced_mmio). + /// + /// See the documentation for `KVM_UNREGISTER_COALESCED_MMIO`. + pub fn unregister_coalesced_mmio(&self, addr: IoEventAddress, size: u32) -> Result<()> { + let (addr, pio) = match addr { + IoEventAddress::Pio(addr) => (addr, 1), + IoEventAddress::Mmio(addr) => (addr, 0), + }; + let mut zone = kvm_coalesced_mmio_zone { + addr, + size, + ..Default::default() + }; + zone.__bindgen_anon_1.pio = pio; + + // SAFETY: Safe because we know that our file is a VM fd, we know the kernel will only read + // the correct amount of memory from our pointer, and we verify the return result. + let ret = unsafe { ioctl_with_ref(self, KVM_UNREGISTER_COALESCED_MMIO(), &zone) }; + if ret != 0 { + return Err(errno::Error::last()); + } + Ok(()) + } } /// Helper function to create a new `VmFd`. @@ -1586,9 +1914,9 @@ impl AsRawFd for VmFd { /// * `vm` - The vm file descriptor. /// * `flags` - Flags to be passed to `KVM_CREATE_DEVICE`. #[cfg(test)] -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] pub(crate) fn create_gic_device(vm: &VmFd, flags: u32) -> DeviceFd { - let mut gic_device = kvm_bindings::kvm_create_device { + let mut gic_device = kvm_create_device { type_: kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3, fd: 0, flags, @@ -1610,15 +1938,16 @@ pub(crate) fn create_gic_device(vm: &VmFd, flags: u32) -> DeviceFd { /// * `vgic` - The vGIC file descriptor. /// * `nr_irqs` - Number of IRQs. #[cfg(test)] -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] pub(crate) fn set_supported_nr_irqs(vgic: &DeviceFd, nr_irqs: u32) { - let vgic_attr = kvm_bindings::kvm_device_attr { - group: kvm_bindings::KVM_DEV_ARM_VGIC_GRP_NR_IRQS, + let vgic_attr = kvm_device_attr { + group: KVM_DEV_ARM_VGIC_GRP_NR_IRQS, attr: 0, addr: &nr_irqs as *const u32 as u64, flags: 0, }; - assert!(vgic.set_device_attr(&vgic_attr).is_ok()); + vgic.has_device_attr(&vgic_attr).unwrap(); + vgic.set_device_attr(&vgic_attr).unwrap(); } /// Request the initialization of the vGIC. @@ -1627,15 +1956,71 @@ pub(crate) fn set_supported_nr_irqs(vgic: &DeviceFd, nr_irqs: u32) { /// /// * `vgic` - The vGIC file descriptor. #[cfg(test)] -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] pub(crate) fn request_gic_init(vgic: &DeviceFd) { - let vgic_attr = kvm_bindings::kvm_device_attr { - group: kvm_bindings::KVM_DEV_ARM_VGIC_GRP_CTRL, - attr: u64::from(kvm_bindings::KVM_DEV_ARM_VGIC_CTRL_INIT), + let vgic_attr = kvm_device_attr { + group: KVM_DEV_ARM_VGIC_GRP_CTRL, + attr: u64::from(KVM_DEV_ARM_VGIC_CTRL_INIT), addr: 0, flags: 0, }; - assert!(vgic.set_device_attr(&vgic_attr).is_ok()); + vgic.has_device_attr(&vgic_attr).unwrap(); + vgic.set_device_attr(&vgic_attr).unwrap(); +} + +/// Create a dummy AIA device. +/// +/// # Arguments +/// +/// * `vm` - The vm file descriptor. +/// * `flags` - Flags to be passed to `KVM_CREATE_DEVICE`. +#[cfg(test)] +#[cfg(target_arch = "riscv64")] +pub(crate) fn create_aia_device(vm: &VmFd, flags: u32) -> DeviceFd { + let mut aia_device = kvm_create_device { + type_: kvm_device_type_KVM_DEV_TYPE_RISCV_AIA, + fd: 0, + flags, + }; + vm.create_device(&mut aia_device) + .expect("Cannot create KVM vAIA device") +} + +/// Set supported number of IRQs for vAIA. +/// +/// # Arguments +/// +/// * `vaia` - The vAIA file descriptor. +/// * `nr_irqs` - Number of IRQs. +#[cfg(test)] +#[cfg(target_arch = "riscv64")] +pub(crate) fn set_supported_nr_irqs(vaia: &DeviceFd, nr_irqs: u32) { + let vaia_attr = kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_CONFIG, + attr: u64::from(KVM_DEV_RISCV_AIA_CONFIG_SRCS), + addr: &nr_irqs as *const u32 as u64, + flags: 0, + }; + vaia.has_device_attr(&vaia_attr).unwrap(); + vaia.set_device_attr(&vaia_attr).unwrap(); +} + +/// Request the initialization of the vAIA. +/// +/// # Arguments +/// +/// * `vaia` - The vAIA file descriptor. +#[cfg(test)] +#[cfg(target_arch = "riscv64")] +pub(crate) fn request_aia_init(vaia: &DeviceFd) { + let vaia_attr = kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_CTRL, + attr: u64::from(KVM_DEV_RISCV_AIA_CTRL_INIT), + addr: 0, + flags: 0, + }; + vaia.has_device_attr(&vaia_attr).unwrap(); + vaia.set_device_attr(&vaia_attr).unwrap(); } #[cfg(test)] @@ -1644,8 +2029,8 @@ mod tests { use super::*; use crate::Kvm; - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - use std::{fs::OpenOptions, ptr::null_mut}; + #[cfg(target_arch = "x86_64")] + use std::{fs::OpenOptions, os::fd::IntoRawFd, ptr::null_mut}; use libc::EFD_NONBLOCK; @@ -1660,39 +2045,57 @@ mod tests { userspace_addr: 0, flags: 0, }; - assert!(unsafe { vm.set_user_memory_region(invalid_mem_region) }.is_err()); + unsafe { vm.set_user_memory_region(invalid_mem_region) }.unwrap_err(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn test_set_invalid_memory2() { + let kvm = Kvm::new().unwrap(); + let vm = kvm.create_vm().unwrap(); + let invalid_mem_region = kvm_userspace_memory_region2 { + slot: 0, + flags: 0, + guest_phys_addr: 0, + memory_size: 0, + userspace_addr: 0, + guest_memfd_offset: 0, + guest_memfd: 0, + pad1: 0, + pad2: [0; 14], + }; + unsafe { vm.set_user_memory_region2(invalid_mem_region) }.unwrap_err(); + } + + #[test] + #[cfg(target_arch = "x86_64")] fn test_set_tss_address() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); - assert!(vm.set_tss_address(0xfffb_d000).is_ok()); + vm.set_tss_address(0xfffb_d000).unwrap(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_set_identity_map_address() { let kvm = Kvm::new().unwrap(); if kvm.check_extension(Cap::SetIdentityMapAddr) { let vm = kvm.create_vm().unwrap(); - assert!(vm.set_identity_map_address(0xfffb_c000).is_ok()); + vm.set_identity_map_address(0xfffb_c000).unwrap(); vm.create_vcpu(0).unwrap(); // Setting the identity map after creating a vCPU must fail. - assert!(vm.set_identity_map_address(0xfffb_c000).is_err()); + vm.set_identity_map_address(0xfffb_c000).unwrap_err(); } } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_irq_chip() { use Cap; let kvm = Kvm::new().unwrap(); assert!(kvm.check_extension(Cap::Irqchip)); let vm = kvm.create_vm().unwrap(); - assert!(vm.create_irq_chip().is_ok()); + vm.create_irq_chip().unwrap(); let mut irqchip = kvm_irqchip { chip_id: KVM_IRQCHIP_PIC_MASTER, @@ -1700,7 +2103,7 @@ mod tests { }; // Set the irq_base to a non-default value to check that set & get work. irqchip.chip.pic.irq_base = 10; - assert!(vm.set_irqchip(&irqchip).is_ok()); + vm.set_irqchip(&irqchip).unwrap(); // We initialize a dummy irq chip (`other_irqchip`) in which the // function `get_irqchip` returns its result. @@ -1708,14 +2111,14 @@ mod tests { chip_id: KVM_IRQCHIP_PIC_MASTER, ..Default::default() }; - assert!(vm.get_irqchip(&mut other_irqchip).is_ok()); + vm.get_irqchip(&mut other_irqchip).unwrap(); // Safe because we know that the irqchip type is PIC. unsafe { assert_eq!(irqchip.chip.pic, other_irqchip.chip.pic) }; } #[test] - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] fn test_irq_chip() { use Cap; @@ -1726,7 +2129,7 @@ mod tests { // On ARM/arm64, a GICv2 is created. It's better to check ahead whether GICv2 // can be emulated or not. - let mut gic_device = kvm_bindings::kvm_create_device { + let mut gic_device = kvm_create_device { type_: kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2, fd: 0, flags: KVM_CREATE_DEVICE_TEST, @@ -1737,11 +2140,14 @@ mod tests { } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_pit2() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); - assert!(vm.create_pit2(kvm_pit_config::default()).is_ok()); + assert!(kvm.check_extension(Cap::Irqchip)); + vm.create_irq_chip().unwrap(); + + vm.create_pit2(kvm_pit_config::default()).unwrap(); let pit2 = vm.get_pit2().unwrap(); vm.set_pit2(&pit2).unwrap(); @@ -1753,7 +2159,7 @@ mod tests { assert_eq!(pit2, other_pit2); } - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[test] fn test_clock() { let kvm = Kvm::new().unwrap(); @@ -1784,24 +2190,24 @@ mod tests { let kvm = Kvm::new().unwrap(); let vm_fd = kvm.create_vm().unwrap(); let evtfd = EventFd::new(EFD_NONBLOCK).unwrap(); - assert!(vm_fd + vm_fd .register_ioevent(&evtfd, &IoEventAddress::Pio(0xf4), NoDatamatch) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .register_ioevent(&evtfd, &IoEventAddress::Mmio(0x1000), NoDatamatch) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .register_ioevent(&evtfd, &IoEventAddress::Pio(0xc1), 0x7fu8) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .register_ioevent(&evtfd, &IoEventAddress::Pio(0xc2), 0x1337u16) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .register_ioevent(&evtfd, &IoEventAddress::Pio(0xc4), 0xdead_beefu32) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .register_ioevent(&evtfd, &IoEventAddress::Pio(0xc8), 0xdead_beef_dead_beefu64) - .is_ok()); + .unwrap() } #[test] @@ -1815,33 +2221,33 @@ mod tests { let mmio_addr = IoEventAddress::Mmio(0x1000); // First try to unregister addresses which have not been registered. - assert!(vm_fd + vm_fd .unregister_ioevent(&evtfd, &pio_addr, NoDatamatch) - .is_err()); - assert!(vm_fd + .unwrap_err(); + vm_fd .unregister_ioevent(&evtfd, &mmio_addr, NoDatamatch) - .is_err()); + .unwrap_err(); // Now register the addresses - assert!(vm_fd + vm_fd .register_ioevent(&evtfd, &pio_addr, NoDatamatch) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .register_ioevent(&evtfd, &mmio_addr, 0x1337u16) - .is_ok()); + .unwrap(); // Try again unregistering the addresses. This time it should work // since they have been previously registered. - assert!(vm_fd + vm_fd .unregister_ioevent(&evtfd, &pio_addr, NoDatamatch) - .is_ok()); - assert!(vm_fd + .unwrap(); + vm_fd .unregister_ioevent(&evtfd, &mmio_addr, 0x1337u16) - .is_ok()); + .unwrap(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_register_unregister_irqfd() { let kvm = Kvm::new().unwrap(); let vm_fd = kvm.create_vm().unwrap(); @@ -1851,31 +2257,31 @@ mod tests { let evtfd4 = EventFd::new(EFD_NONBLOCK).unwrap(); let resamplefd = EventFd::new(EFD_NONBLOCK).unwrap(); - assert!(vm_fd.create_irq_chip().is_ok()); + vm_fd.create_irq_chip().unwrap(); - assert!(vm_fd.register_irqfd(&evtfd1, 4).is_ok()); - assert!(vm_fd.register_irqfd(&evtfd2, 8).is_ok()); - assert!(vm_fd.register_irqfd(&evtfd3, 4).is_ok()); - assert!(vm_fd.unregister_irqfd(&evtfd2, 8).is_ok()); + vm_fd.register_irqfd(&evtfd1, 4).unwrap(); + vm_fd.register_irqfd(&evtfd2, 8).unwrap(); + vm_fd.register_irqfd(&evtfd3, 4).unwrap(); + vm_fd.unregister_irqfd(&evtfd2, 8).unwrap(); // KVM irqfd doesn't report failure on this case:( - assert!(vm_fd.unregister_irqfd(&evtfd2, 8).is_ok()); + vm_fd.unregister_irqfd(&evtfd2, 8).unwrap(); // Duplicated eventfd registration. // On x86_64 this fails as the event fd was already matched with a GSI. - assert!(vm_fd.register_irqfd(&evtfd3, 4).is_err()); - assert!(vm_fd.register_irqfd(&evtfd3, 5).is_err()); + vm_fd.register_irqfd(&evtfd3, 4).unwrap_err(); + vm_fd.register_irqfd(&evtfd3, 5).unwrap_err(); // KVM irqfd doesn't report failure on this case:( - assert!(vm_fd.unregister_irqfd(&evtfd3, 5).is_ok()); + vm_fd.unregister_irqfd(&evtfd3, 5).unwrap(); if vm_fd.check_extension(Cap::IrqfdResample) { - assert!(vm_fd + vm_fd .register_irqfd_with_resample(&evtfd4, &resamplefd, 6) - .is_ok()); - assert!(vm_fd.unregister_irqfd(&evtfd4, 6).is_ok()); + .unwrap(); + vm_fd.unregister_irqfd(&evtfd4, 6).unwrap(); } else { - assert!(vm_fd + vm_fd .register_irqfd_with_resample(&evtfd4, &resamplefd, 6) - .is_err()); + .unwrap_err(); } } @@ -1902,44 +2308,102 @@ mod tests { // Request the initialization of the vGIC. request_gic_init(&vgic_fd); - assert!(vm_fd.register_irqfd(&evtfd1, 4).is_ok()); - assert!(vm_fd.register_irqfd(&evtfd2, 8).is_ok()); - assert!(vm_fd.register_irqfd(&evtfd3, 4).is_ok()); - assert!(vm_fd.unregister_irqfd(&evtfd2, 8).is_ok()); + vm_fd.register_irqfd(&evtfd1, 4).unwrap(); + vm_fd.register_irqfd(&evtfd2, 8).unwrap(); + vm_fd.register_irqfd(&evtfd3, 4).unwrap(); + vm_fd.unregister_irqfd(&evtfd2, 8).unwrap(); // KVM irqfd doesn't report failure on this case:( - assert!(vm_fd.unregister_irqfd(&evtfd2, 8).is_ok()); + vm_fd.unregister_irqfd(&evtfd2, 8).unwrap(); // Duplicated eventfd registration. // On aarch64, this fails because setting up the interrupt controller is mandatory before // registering any IRQ. - assert!(vm_fd.register_irqfd(&evtfd3, 4).is_err()); - assert!(vm_fd.register_irqfd(&evtfd3, 5).is_err()); + vm_fd.register_irqfd(&evtfd3, 4).unwrap_err(); + vm_fd.register_irqfd(&evtfd3, 5).unwrap_err(); // KVM irqfd doesn't report failure on this case:( - assert!(vm_fd.unregister_irqfd(&evtfd3, 5).is_ok()); + vm_fd.unregister_irqfd(&evtfd3, 5).unwrap(); if vm_fd.check_extension(Cap::IrqfdResample) { - assert!(vm_fd + vm_fd .register_irqfd_with_resample(&evtfd4, &resamplefd, 6) - .is_ok()); - assert!(vm_fd.unregister_irqfd(&evtfd4, 6).is_ok()); + .unwrap(); + vm_fd.unregister_irqfd(&evtfd4, 6).unwrap(); } else { - assert!(vm_fd + vm_fd .register_irqfd_with_resample(&evtfd4, &resamplefd, 6) - .is_err()); + .unwrap_err(); } } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "riscv64")] + fn test_register_unregister_irqfd() { + let kvm = Kvm::new().unwrap(); + let vm_fd = kvm.create_vm().unwrap(); + let evtfd1 = EventFd::new(EFD_NONBLOCK).unwrap(); + let evtfd2 = EventFd::new(EFD_NONBLOCK).unwrap(); + let evtfd3 = EventFd::new(EFD_NONBLOCK).unwrap(); + + // Create the vAIA device. + let vaia_fd = create_aia_device(&vm_fd, 0); + + // AIA on riscv64 requires at least one online vCPU prior to setting + // device attributes. Otherwise it would fail when trying ot set address + // of IMSIC. + vm_fd.create_vcpu(0).unwrap(); + + // Set maximum supported number of IRQs of the vAIA device to 128. + set_supported_nr_irqs(&vaia_fd, 128); + + // Before request vAIA device to initialize, APLIC and IMSIC must be set + let aplic_addr: u64 = 0x4000; + vaia_fd + .set_device_attr(&kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_ADDR, + attr: u64::from(KVM_DEV_RISCV_AIA_ADDR_APLIC), + addr: &aplic_addr as *const u64 as u64, + flags: 0, + }) + .unwrap(); + let imsic_addr: u64 = 0x8000; + vaia_fd + .set_device_attr(&kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_ADDR, + attr: 1u64, + addr: &imsic_addr as *const u64 as u64, + flags: 0, + }) + .unwrap(); + + // Initialize valid vAIA device. + request_aia_init(&vaia_fd); + + vm_fd.register_irqfd(&evtfd1, 4).unwrap(); + vm_fd.register_irqfd(&evtfd2, 8).unwrap(); + vm_fd.register_irqfd(&evtfd3, 4).unwrap(); + vm_fd.unregister_irqfd(&evtfd2, 8).unwrap(); + // KVM irqfd doesn't report failure on this case:( + vm_fd.unregister_irqfd(&evtfd2, 8).unwrap(); + + // Duplicated eventfd registration. + // On riscv64 this fails as the event fd was already matched with a GSI. + vm_fd.register_irqfd(&evtfd3, 4).unwrap_err(); + vm_fd.register_irqfd(&evtfd3, 5).unwrap_err(); + // KVM irqfd doesn't report failure on this case:( + vm_fd.unregister_irqfd(&evtfd3, 5).unwrap(); + } + + #[test] + #[cfg(target_arch = "x86_64")] fn test_set_irq_line() { let kvm = Kvm::new().unwrap(); let vm_fd = kvm.create_vm().unwrap(); - assert!(vm_fd.create_irq_chip().is_ok()); + vm_fd.create_irq_chip().unwrap(); - assert!(vm_fd.set_irq_line(4, true).is_ok()); - assert!(vm_fd.set_irq_line(4, false).is_ok()); - assert!(vm_fd.set_irq_line(4, true).is_ok()); + vm_fd.set_irq_line(4, true).unwrap(); + vm_fd.set_irq_line(4, false).unwrap(); + vm_fd.set_irq_line(4, true).unwrap(); } #[test] @@ -1966,18 +2430,58 @@ mod tests { // - irq_type[1]: in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.) (the vcpu_index field is ignored) // - irq_type[2]: in-kernel GIC: PPI, irq_id between 16 and 31 (incl.) // Hence, using irq_type = 1, irq_id = 32 (decimal), the irq field in hex is: 0x01_00_0020 - assert!(vm_fd.set_irq_line(0x01_00_0020, true).is_ok()); - assert!(vm_fd.set_irq_line(0x01_00_0020, false).is_ok()); - assert!(vm_fd.set_irq_line(0x01_00_0020, true).is_ok()); + vm_fd.set_irq_line(0x01_00_0020, true).unwrap(); + vm_fd.set_irq_line(0x01_00_0020, false).unwrap(); + vm_fd.set_irq_line(0x01_00_0020, true).unwrap(); // Case 2: using irq_type = 2, vcpu_index = 0, irq_id = 16 (decimal), the irq field in hex is: 0x02_00_0010 - assert!(vm_fd.set_irq_line(0x02_00_0010, true).is_ok()); - assert!(vm_fd.set_irq_line(0x02_00_0010, false).is_ok()); - assert!(vm_fd.set_irq_line(0x02_00_0010, true).is_ok()); + vm_fd.set_irq_line(0x02_00_0010, true).unwrap(); + vm_fd.set_irq_line(0x02_00_0010, false).unwrap(); + vm_fd.set_irq_line(0x02_00_0010, true).unwrap(); + } + + #[test] + #[cfg(target_arch = "riscv64")] + fn test_set_irq_line() { + let kvm = Kvm::new().unwrap(); + let vm_fd = kvm.create_vm().unwrap(); + vm_fd.create_vcpu(0).unwrap(); + + // Create the vAIA device. + let vaia_fd = create_aia_device(&vm_fd, 0); + // Set maximum supported number of IRQs of the vAIA device to 128. + set_supported_nr_irqs(&vaia_fd, 128); + + // Before request vAIA device to initialize, APLIC and IMSIC must be set + let aplic_addr: u64 = 0x4000; + vaia_fd + .set_device_attr(&kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_ADDR, + attr: u64::from(KVM_DEV_RISCV_AIA_ADDR_APLIC), + addr: &aplic_addr as *const u64 as u64, + flags: 0, + }) + .unwrap(); + let imsic_addr: u64 = 0x8000; + vaia_fd + .set_device_attr(&kvm_device_attr { + group: KVM_DEV_RISCV_AIA_GRP_ADDR, + attr: 1u64, + addr: &imsic_addr as *const u64 as u64, + flags: 0, + }) + .unwrap(); + + // Initialize valid vAIA device. + request_aia_init(&vaia_fd); + + vm_fd.set_irq_line(7, true).unwrap(); + vm_fd.set_irq_line(7, false).unwrap(); + vm_fd.set_irq_line(7, true).unwrap(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_faulty_vm_fd() { let badf_errno = libc::EBADF; @@ -2073,15 +2577,19 @@ mod tests { faulty_vm_fd.get_dirty_log(0, 0).unwrap_err().errno(), badf_errno ); + + // Don't drop the File object, or it'll notice the file it's trying to close is + // invalid and abort the process. + let _ = faulty_vm_fd.vm.into_raw_fd(); } #[test] - #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + #[cfg(target_arch = "aarch64")] fn test_get_preferred_target() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); - let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default(); - assert!(vm.get_preferred_target(&mut kvi).is_ok()); + let mut kvi = kvm_vcpu_init::default(); + vm.get_preferred_target(&mut kvi).unwrap(); } /// As explained in the example code related to signal_msi(), sending @@ -2089,31 +2597,30 @@ mod tests { /// previously allocated from the guest itself. #[test] #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] fn test_signal_msi_failure() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let msi = kvm_msi::default(); - assert!(vm.signal_msi(msi).is_err()); + vm.signal_msi(msi).unwrap_err(); } #[test] - #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] + #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] fn test_enable_cap_failure() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let cap: kvm_enable_cap = Default::default(); // Providing the `kvm_enable_cap` structure filled with default() should // always result in a failure as it is not a valid capability. - assert!(vm.enable_cap(&cap).is_err()); + vm.enable_cap(&cap).unwrap_err(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] fn test_enable_split_irqchip_cap() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); @@ -2133,21 +2640,32 @@ mod tests { // Because an IOAPIC supports 24 pins, that's the reason why this test // picked this number as reference. cap.args[0] = 24; - assert!(vm.enable_cap(&cap).is_ok()); + vm.enable_cap(&cap).unwrap(); } #[test] + #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64" + ))] fn test_set_gsi_routing() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); - if cfg!(target_arch = "x86") || cfg!(target_arch = "x86_64") { - let irq_routing = kvm_irq_routing::default(); - // Expect failure for x86 since the irqchip is not created yet. - assert!(vm.set_gsi_routing(&irq_routing).is_err()); - vm.create_irq_chip().unwrap(); - } let irq_routing = kvm_irq_routing::default(); - assert!(vm.set_gsi_routing(&irq_routing).is_ok()); + + // Expect failure for x86 since the irqchip is not created yet. + #[cfg(target_arch = "x86_64")] + vm.set_gsi_routing(&irq_routing).unwrap_err(); + #[cfg(target_arch = "x86_64")] + vm.create_irq_chip().unwrap(); + + // RISC-V 64-bit expect an AIA device to be created in advance of + // committing irq_routing table. + #[cfg(target_arch = "riscv64")] + create_aia_device(&vm, 0); + + vm.set_gsi_routing(&irq_routing).unwrap(); } #[test] @@ -2161,8 +2679,8 @@ mod tests { // Fails when input `id` = `max_vcpu_id` let max_vcpu_id = kvm.get_max_vcpu_id(); - let vcpu = vm.create_vcpu((max_vcpu_id - 1) as u64); - assert!(vcpu.is_ok()); + vm.create_vcpu((max_vcpu_id - 1) as u64).unwrap(); + let vcpu_err = vm.create_vcpu(max_vcpu_id as u64).err(); assert_eq!(vcpu_err.unwrap().errno(), libc::EINVAL); } @@ -2175,18 +2693,18 @@ mod tests { } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[cfg_attr(not(has_sev), ignore)] fn test_encrypt_op_sev() { let kvm = Kvm::new().unwrap(); let vm = kvm.create_vm().unwrap(); let mut init: kvm_sev_cmd = Default::default(); - assert!(vm.encrypt_op_sev(&mut init).is_ok()); + vm.encrypt_op_sev(&mut init).unwrap(); } #[test] - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] #[cfg_attr(not(has_sev), ignore)] fn test_register_unregister_enc_memory_region() { let sev = OpenOptions::new() @@ -2202,7 +2720,7 @@ mod tests { // https://www.kernel.org/doc/Documentation/virtual/kvm/amd-memory-encryption.rst let mut init: kvm_sev_cmd = Default::default(); - assert!(vm.encrypt_op_sev(&mut init).is_ok()); + vm.encrypt_op_sev(&mut init).unwrap(); let start_data: kvm_sev_launch_start = Default::default(); let mut start = kvm_sev_cmd { @@ -2211,7 +2729,7 @@ mod tests { sev_fd: sev.as_raw_fd() as _, ..Default::default() }; - assert!(vm.encrypt_op_sev(&mut start).is_ok()); + vm.encrypt_op_sev(&mut start).unwrap(); let addr = unsafe { libc::mmap( @@ -2248,7 +2766,7 @@ mod tests { .errno(), libc::EINVAL ); - assert!(vm.register_enc_memory_region(&memory_region).is_ok()); - assert!(vm.unregister_enc_memory_region(&memory_region).is_ok()); + vm.register_enc_memory_region(&memory_region).unwrap(); + vm.unregister_enc_memory_region(&memory_region).unwrap(); } } diff --git a/vendor/kvm-ioctls/src/kvm_ioctls.rs b/vendor/kvm-ioctls/src/kvm_ioctls.rs index 5b9360c..192b602 100644 --- a/vendor/kvm-ioctls/src/kvm_ioctls.rs +++ b/vendor/kvm-ioctls/src/kvm_ioctls.rs @@ -13,18 +13,18 @@ use kvm_bindings::*; ioctl_io_nr!(KVM_GET_API_VERSION, KVMIO, 0x00); ioctl_io_nr!(KVM_CREATE_VM, KVMIO, 0x01); -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_MSR_INDEX_LIST, KVMIO, 0x02, kvm_msr_list); ioctl_io_nr!(KVM_CHECK_EXTENSION, KVMIO, 0x03); ioctl_io_nr!(KVM_GET_VCPU_MMAP_SIZE, KVMIO, 0x04); /* Available with KVM_CAP_EXT_CPUID */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_SUPPORTED_CPUID, KVMIO, 0x05, kvm_cpuid2); /* Available with KVM_CAP_EXT_EMUL_CPUID */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_EMULATED_CPUID, KVMIO, 0x09, kvm_cpuid2); /* Available with KVM_CAP_GET_MSR_FEATURES */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_MSR_FEATURE_INDEX_LIST, KVMIO, 0x0a, kvm_msr_list); // Ioctls for VM fds. @@ -38,208 +38,213 @@ ioctl_iow_nr!( 0x46, kvm_userspace_memory_region ); +ioctl_iow_nr!( + KVM_SET_USER_MEMORY_REGION2, + KVMIO, + 0x49, + kvm_userspace_memory_region2 +); /* Available with KVM_CAP_SET_TSS_ADDR */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_io_nr!(KVM_SET_TSS_ADDR, KVMIO, 0x47); /* Available with KVM_CAP_SET_IDENTITY_MAP_ADDR */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_IDENTITY_MAP_ADDR, KVMIO, 0x48, u64); +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +ioctl_iowr_nr!(KVM_CREATE_GUEST_MEMFD, KVMIO, 0xd4, kvm_create_guest_memfd); /* Available with KVM_CAP_IRQCHIP */ -#[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "s390" -))] +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "s390x"))] ioctl_io_nr!(KVM_CREATE_IRQCHIP, KVMIO, 0x60); /* Available with KVM_CAP_IRQCHIP */ #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] ioctl_iow_nr!(KVM_IRQ_LINE, KVMIO, 0x61, kvm_irq_level); +/* Available with KVM_CAP_COALESCED_MMIO / KVM_CAP_COALESCED_PIO */ +ioctl_iow_nr!( + KVM_REGISTER_COALESCED_MMIO, + KVMIO, + 0x67, + kvm_coalesced_mmio_zone +); +/* Available with KVM_CAP_COALESCED_MMIO / KVM_CAP_COALESCED_PIO */ +ioctl_iow_nr!( + KVM_UNREGISTER_COALESCED_MMIO, + KVMIO, + 0x68, + kvm_coalesced_mmio_zone +); /* Available with KVM_CAP_IRQ_ROUTING */ #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] ioctl_iow_nr!(KVM_SET_GSI_ROUTING, KVMIO, 0x6a, kvm_irq_routing); /* Available with KVM_CAP_IRQFD */ #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", target_arch = "aarch64", - target_arch = "s390" + target_arch = "riscv64", + target_arch = "s390x" ))] ioctl_iow_nr!(KVM_IRQFD, KVMIO, 0x76, kvm_irqfd); /* Available with KVM_CAP_PIT2 */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_CREATE_PIT2, KVMIO, 0x77, kvm_pit_config); /* Available with KVM_CAP_IOEVENTFD */ ioctl_iow_nr!(KVM_IOEVENTFD, KVMIO, 0x79, kvm_ioeventfd); /* Available with KVM_CAP_IRQCHIP */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_IRQCHIP, KVMIO, 0x62, kvm_irqchip); /* Available with KVM_CAP_IRQCHIP */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_SET_IRQCHIP, KVMIO, 0x63, kvm_irqchip); /* Available with KVM_CAP_ADJUST_CLOCK */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_CLOCK, KVMIO, 0x7b, kvm_clock_data); /* Available with KVM_CAP_ADJUST_CLOCK */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_CLOCK, KVMIO, 0x7c, kvm_clock_data); /* Available with KVM_CAP_PIT_STATE2 */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_PIT2, KVMIO, 0x9f, kvm_pit_state2); /* Available with KVM_CAP_PIT_STATE2 */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_PIT2, KVMIO, 0xa0, kvm_pit_state2); /* KVM_MEMORY_ENCRYPT_OP. Takes opaque platform dependent type: i.e. TDX or SEV */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_MEMORY_ENCRYPT_OP, KVMIO, 0xba, std::os::raw::c_ulong); /* Available on SEV-enabled guests. */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_MEMORY_ENCRYPT_REG_REGION, KVMIO, 0xbb, kvm_enc_region); /* Available on SEV-enabled guests. */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_MEMORY_ENCRYPT_UNREG_REGION, KVMIO, 0xbc, kvm_enc_region); // Ioctls for VCPU fds. ioctl_io_nr!(KVM_RUN, KVMIO, 0x80); -#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] +#[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] ioctl_ior_nr!(KVM_GET_REGS, KVMIO, 0x81, kvm_regs); -#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] +#[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] ioctl_iow_nr!(KVM_SET_REGS, KVMIO, 0x82, kvm_regs); #[cfg(any( - target_arch = "x86", target_arch = "x86_64", target_arch = "powerpc", target_arch = "powerpc64" ))] ioctl_ior_nr!(KVM_GET_SREGS, KVMIO, 0x83, kvm_sregs); #[cfg(any( - target_arch = "x86", target_arch = "x86_64", target_arch = "powerpc", target_arch = "powerpc64" ))] ioctl_iow_nr!(KVM_SET_SREGS, KVMIO, 0x84, kvm_sregs); -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_TRANSLATE, KVMIO, 0x85, kvm_translation); -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_MSRS, KVMIO, 0x88, kvm_msrs); -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_MSRS, KVMIO, 0x89, kvm_msrs); -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_FPU, KVMIO, 0x8c, kvm_fpu); -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_FPU, KVMIO, 0x8d, kvm_fpu); /* Available with KVM_CAP_IRQCHIP */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_LAPIC, KVMIO, 0x8e, kvm_lapic_state); /* Available with KVM_CAP_IRQCHIP */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_LAPIC, KVMIO, 0x8f, kvm_lapic_state); /* Available with KVM_CAP_EXT_CPUID */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_CPUID2, KVMIO, 0x90, kvm_cpuid2); /* Available with KVM_CAP_EXT_CPUID */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iowr_nr!(KVM_GET_CPUID2, KVMIO, 0x91, kvm_cpuid2); /* Available with KVM_CAP_MP_STATE */ #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", target_arch = "aarch64", - target_arch = "s390" + target_arch = "riscv64", + target_arch = "s390x" ))] ioctl_ior_nr!(KVM_GET_MP_STATE, KVMIO, 0x98, kvm_mp_state); /* Available with KVM_CAP_MP_STATE */ #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", target_arch = "aarch64", - target_arch = "s390" + target_arch = "riscv64", + target_arch = "s390x" ))] ioctl_iow_nr!(KVM_SET_MP_STATE, KVMIO, 0x99, kvm_mp_state); +/* Available with KVM_CAP_USER_NMI */ +#[cfg(target_arch = "x86_64")] +ioctl_io_nr!(KVM_NMI, KVMIO, 0x9a); /* Available with KVM_CAP_VCPU_EVENTS */ -#[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" -))] +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] ioctl_ior_nr!(KVM_GET_VCPU_EVENTS, KVMIO, 0x9f, kvm_vcpu_events); /* Available with KVM_CAP_VCPU_EVENTS */ -#[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" -))] +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] ioctl_iow_nr!(KVM_SET_VCPU_EVENTS, KVMIO, 0xa0, kvm_vcpu_events); /* Available with KVM_CAP_DEBUGREGS */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_DEBUGREGS, KVMIO, 0xa1, kvm_debugregs); /* Available with KVM_CAP_DEBUGREGS */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_DEBUGREGS, KVMIO, 0xa2, kvm_debugregs); /* Available with KVM_CAP_XSAVE */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_XSAVE, KVMIO, 0xa4, kvm_xsave); /* Available with KVM_CAP_XSAVE */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_XSAVE, KVMIO, 0xa5, kvm_xsave); /* Available with KVM_CAP_XCRS */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_ior_nr!(KVM_GET_XCRS, KVMIO, 0xa6, kvm_xcrs); /* Available with KVM_CAP_XCRS */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_iow_nr!(KVM_SET_XCRS, KVMIO, 0xa7, kvm_xcrs); /* Available with KVM_CAP_KVMCLOCK_CTRL */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_io_nr!(KVM_KVMCLOCK_CTRL, KVMIO, 0xad); /* Available with KVM_CAP_TSC_CONTROL */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_io_nr!(KVM_SET_TSC_KHZ, KVMIO, 0xa2); /* Available with KVM_CAP_GET_TSC_KHZ */ -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] ioctl_io_nr!(KVM_GET_TSC_KHZ, KVMIO, 0xa3); /* Available with KVM_CAP_ENABLE_CAP */ -#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] +#[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))] ioctl_iow_nr!(KVM_ENABLE_CAP, KVMIO, 0xa3, kvm_enable_cap); /* Available with KVM_CAP_SIGNAL_MSI */ #[cfg(any( - target_arch = "x86", target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64" + target_arch = "aarch64", + target_arch = "riscv64" ))] ioctl_iow_nr!(KVM_SIGNAL_MSI, KVMIO, 0xa5, kvm_msi); /* Available with KVM_CAP_ONE_REG */ -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] ioctl_iow_nr!(KVM_GET_ONE_REG, KVMIO, 0xab, kvm_one_reg); -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] ioctl_iow_nr!(KVM_SET_ONE_REG, KVMIO, 0xac, kvm_one_reg); -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] ioctl_iow_nr!(KVM_ARM_VCPU_INIT, KVMIO, 0xae, kvm_vcpu_init); -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] ioctl_ior_nr!(KVM_ARM_PREFERRED_TARGET, KVMIO, 0xaf, kvm_vcpu_init); -#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] ioctl_iowr_nr!(KVM_GET_REG_LIST, KVMIO, 0xb0, kvm_reg_list); +/* Available with KVM_CAP_X86_SMM */ +#[cfg(target_arch = "x86_64")] +ioctl_io_nr!(KVM_SMI, KVMIO, 0xb7); + /* Available with KVM_CAP_ARM_SVE */ #[cfg(target_arch = "aarch64")] ioctl_iow_nr!(KVM_ARM_VCPU_FINALIZE, KVMIO, 0xc2, std::os::raw::c_int); @@ -247,6 +252,14 @@ ioctl_iow_nr!(KVM_ARM_VCPU_FINALIZE, KVMIO, 0xc2, std::os::raw::c_int); /* Available with KVM_CAP_SET_GUEST_DEBUG */ ioctl_iow_nr!(KVM_SET_GUEST_DEBUG, KVMIO, 0x9b, kvm_guest_debug); +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +ioctl_iow_nr!( + KVM_SET_MEMORY_ATTRIBUTES, + KVMIO, + 0xd2, + kvm_memory_attributes +); + // Device ioctls. /* Available with KVM_CAP_DEVICE_CTRL */ diff --git a/vendor/kvm-ioctls/src/lib.rs b/vendor/kvm-ioctls/src/lib.rs index a00f203..278e21b 100644 --- a/vendor/kvm-ioctls/src/lib.rs +++ b/vendor/kvm-ioctls/src/lib.rs @@ -1,3 +1,5 @@ +// Copyright © 2024 Institute of Software, CAS. All rights reserved. +// // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT // @@ -5,6 +7,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. #![deny(missing_docs)] +#![deny(missing_copy_implementations)] +#![deny(missing_debug_implementations)] +#![warn(clippy::assertions_on_result_states)] //! A safe wrapper around the kernel's KVM interface. //! @@ -18,6 +23,7 @@ //! //! - x86_64 //! - arm64 (experimental) +//! - riscv64 (experimental) //! //! **NOTE:** The list of available ioctls is not extensive. //! @@ -27,6 +33,7 @@ //! On the vCPU we are running machine specific code. This example is based on //! the [LWN article](https://lwn.net/Articles/658511/) on using the KVM API. //! The aarch64 example was modified accordingly. +//! The riscv64 example was modified accordingly. //! //! To get code running on the vCPU we are going through the following steps: //! @@ -66,7 +73,7 @@ //! let asm_code: &[u8]; //! //! // Setting up architectural dependent values. -//! #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +//! #[cfg(target_arch = "x86_64")] //! { //! asm_code = &[ //! 0xba, 0xf8, 0x03, /* mov $0x3f8, %dx */ @@ -90,6 +97,15 @@ //! 0x14, /* b ; shouldn't get here, but if so loop forever */ //! ]; //! } +//! #[cfg(target_arch = "riscv64")] +//! { +//! asm_code = &[ +//! 0x17, 0x03, 0x00, 0x00, // auipc t1, 0; -> t1 +//! 0xa3, 0x23, 0x73, 0x00, // sw t2, t1 + 7; dirty current page +//! 0x23, 0x20, 0x75, 0x00, // sw t2, a0; trigger MMIO exit +//! 0x6f, 0x00, 0x00, 0x00, // j .;shouldn't get here, but if so loop forever +//! ]; +//! } //! //! // 1. Instantiate KVM. //! let kvm = Kvm::new().unwrap(); @@ -128,10 +144,10 @@ //! } //! //! // 4. Create one vCPU. -//! let vcpu_fd = vm.create_vcpu(0).unwrap(); +//! let mut vcpu_fd = vm.create_vcpu(0).unwrap(); //! //! // 5. Initialize general purpose and special registers. -//! #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +//! #[cfg(target_arch = "x86_64")] //! { //! // x86_64 specific registry setup. //! let mut vcpu_sregs = vcpu_fd.get_sregs().unwrap(); @@ -162,6 +178,17 @@ //! vcpu_fd.set_one_reg(core_reg_base + 2 * 0, &mmio_addr.to_le_bytes()); //! } //! +//! #[cfg(target_arch = "riscv64")] +//! { +//! // riscv64 specific register setup. +//! let core_reg_base: u64 = 0x8030_0000_0200_0000; +//! let mmio_addr: u64 = guest_addr + mem_size as u64; +//! // set PC +//! vcpu_fd.set_one_reg(core_reg_base, &guest_addr.to_le_bytes()); +//! // set A0 +//! vcpu_fd.set_one_reg(core_reg_base + 10, &mmio_addr.to_le_bytes()); +//! } +//! //! // 6. Run code on the vCPU. //! loop { //! match vcpu_fd.run().expect("run failed") { @@ -192,7 +219,7 @@ //! // Since on aarch64 there is not halt instruction, //! // we break immediately after the last known instruction //! // of the asm code example so that we avoid an infinite loop. -//! #[cfg(target_arch = "aarch64")] +//! #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] //! break; //! } //! VcpuExit::Hlt => { @@ -217,10 +244,12 @@ mod ioctls; pub use cap::Cap; pub use ioctls::device::DeviceFd; pub use ioctls::system::Kvm; -pub use ioctls::vcpu::{VcpuExit, VcpuFd}; +#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] +pub use ioctls::vcpu::reg_size; +pub use ioctls::vcpu::{HypercallExit, VcpuExit, VcpuFd}; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub use ioctls::vcpu::SyncReg; +#[cfg(target_arch = "x86_64")] +pub use ioctls::vcpu::{MsrExitReason, ReadMsrExit, SyncReg, WriteMsrExit}; pub use ioctls::vm::{IoEventAddress, NoDatamatch, VmFd}; // The following example is used to verify that our public @@ -228,7 +257,7 @@ pub use ioctls::vm::{IoEventAddress, NoDatamatch, VmFd}; /// # Example /// /// ``` -/// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +/// #[cfg(target_arch = "x86_64")] /// use kvm_ioctls::{Error, KvmRunWrapper}; /// ``` pub use ioctls::KvmRunWrapper; diff --git a/vendor/vmm-sys-util/.cargo-checksum.json b/vendor/vmm-sys-util/.cargo-checksum.json index a90b668..de34117 100644 --- a/vendor/vmm-sys-util/.cargo-checksum.json +++ b/vendor/vmm-sys-util/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"835b7864bab328acbc7d62af2f9cea5f8b7193713cda499d49162c643b6af733","CODEOWNERS":"6da80e22d851aaf8a3531a1fa9d6dc2418cc6de26c1759db6bfdfc5dda32c703","Cargo.toml":"4f81b61c76c31646845df5829e6a2d3d0929fa2fa031d2d49e73725797b5ba7d","LICENSE-BSD-3-Clause":"a6d3ebd1c2f37d4fd83d0676621f695fc0cc2d8c6e646cdbb831b46e0650c208","README.md":"49c4867574bcd896b33a9aba45e9cb02fa5b44899430343401305fa17fb5f3a5","coverage_config_aarch64.json":"3a91df4ec88e8b73823f20217332b076ead5e3cd352cb4b1ba083f73b825fa62","coverage_config_x86_64.json":"e5159dc03ada035e0dc27a977115eca0039fe595f426ccd3a8a59257484d2ecd","src/errno.rs":"e6c5699346bfed7fdfe061e30bfac96d4cc56e17d94aea369e28f98126e1903e","src/fam.rs":"91cc4f58dd99bacc828e707d9ae8d8b3771e9b3c491cfe238bf7e7a367b23420","src/lib.rs":"4521a8eeeeb3304fe36a0fa7881bdb420aaf4af9c469a1adfad535e1b47cf6ed","src/linux/aio.rs":"9f0f1bfc2489c09c1f723070910299171528e24ec99a82a4dfd55b3a6a44493c","src/linux/epoll.rs":"eb19e3a47479b934ebd6a5f8da291db3f600efc208ce464a0062baed5cf53fc7","src/linux/eventfd.rs":"a6da50e5ea00f57cca54bd6a5900a3fb479e707e70ff8a78d0ab5e1c593499bf","src/linux/fallocate.rs":"cc913a67892584d7125522ab2fde363c3d6e746e639b4bc4ff62640fbb206903","src/linux/ioctl.rs":"18453260ff88389347e23ff549eb1ecd334ecf0e2da34fcedf33128a98a547d1","src/linux/mod.rs":"6c8c3a7a8e49ba778e9c308ddeaef38e445dadfeb17e1362d476d0892e9b8ebd","src/linux/poll.rs":"0df06696596b6dc22884d19258848bcdbac026be7763d70c12059aeb075337e3","src/linux/seek_hole.rs":"7fe9a94452c40e7dc75690fa3230f803641ff8cb6651648724fbb07a93e44b50","src/linux/signal.rs":"9b6d50cf46d6334d2a5f1ce484f9af47a7eca48bd9edaa8704105c30dbc4bfc4","src/linux/sock_ctrl_msg.rs":"d102a0355061c92da7b87d10bc7c4386454d59a153d8e0787ce09ffa4e424352","src/linux/timerfd.rs":"68088850b33489e84b8a9fc04d0aa68d01ed5916f6cb3f58451e3e1d7de5fc5c","src/linux/write_zeroes.rs":"960c0e40c6333f83a737c37609362dcd91e12f407898a3c06b1b12d594daad34","src/metric.rs":"f48ac6edf2a84cdb67d9388d81116ccd876198027ea7026c94d112620e3e5fe4","src/rand.rs":"7f8e0a7e2a15342d449383c461c72af0c0ced3f2016f755165173098a42e5da1","src/syscall.rs":"55fba6cc4f7aa622cc7398a29d79e3d98102e089d30e9a1c79a6e105a052ea9b","src/tempfile.rs":"9446711c0e7864541f69bbeb20a86c19a3786477ac57e7ee7d6c3fa5bbf01f17","src/unix/file_traits.rs":"cc0df75e2efb9a314daafe96799b301c77da8bd8195100311e936d625c936493","src/unix/mod.rs":"7686c7c8f72f22a9a2ee80bb9a083f73b97bc6e76a277b87b7497c68e630a092","src/unix/tempdir.rs":"8c0efa43beade5586c7474319e2c2cd2bb261d913f0c47a72b6593c577715ba8","src/unix/terminal.rs":"74d4881db109e7698b68b99f3376a11708ecfed8efac7ec39c5d2a62c13274d7"},"package":"dd64fe09d8e880e600c324e7d664760a17f56e9672b7495a86381b49e4f72f46"} \ No newline at end of file +{"files":{"CHANGELOG.md":"e32224290f2ccd3df026a4d007e3a05e6c445bbcc06f290a65056a8c42679f8c","CODEOWNERS":"b61fcc4bd34427668424c0d6764eeb26fd224466b4d5dbd2da969b2c23240c1a","Cargo.toml":"7df53c5526d1aaee6b065e9461e13e13d9275b1adf737c2be8a36954496c0040","LICENSE-BSD-3-Clause":"a6d3ebd1c2f37d4fd83d0676621f695fc0cc2d8c6e646cdbb831b46e0650c208","README.md":"49c4867574bcd896b33a9aba45e9cb02fa5b44899430343401305fa17fb5f3a5","coverage_config_aarch64.json":"3a91df4ec88e8b73823f20217332b076ead5e3cd352cb4b1ba083f73b825fa62","coverage_config_x86_64.json":"df83df24b4e373a921b86ff5978a4cd24b8e6a87ce8db66190bbcd91947cccb6","src/errno.rs":"e6c5699346bfed7fdfe061e30bfac96d4cc56e17d94aea369e28f98126e1903e","src/fam.rs":"496e3d91131d0d2e2fb64a75ff09bfa335c1e4a481c8d8b0aaecf24bab42e068","src/lib.rs":"6197742faa4dc2eb256de637ccbeac7a2f653a10cd820404b3a1bb324dbc6f68","src/linux/aio.rs":"1eebe7138f8e9f6367a87439c92e50601105e0326ef448612d4929a9bed0834c","src/linux/epoll.rs":"628824874a371637ed62df4ce56f73df1dde2f4dbfd981794398886a89796cdf","src/linux/eventfd.rs":"a6da50e5ea00f57cca54bd6a5900a3fb479e707e70ff8a78d0ab5e1c593499bf","src/linux/fallocate.rs":"5a7c02569e433cd29a2058975647781a07ce42288979732ae34cb7b71d468518","src/linux/ioctl.rs":"18453260ff88389347e23ff549eb1ecd334ecf0e2da34fcedf33128a98a547d1","src/linux/mod.rs":"6c8c3a7a8e49ba778e9c308ddeaef38e445dadfeb17e1362d476d0892e9b8ebd","src/linux/poll.rs":"52a6609117190489d2677d53737958e3f9d7222216e1ea204b1e19fa86aee173","src/linux/seek_hole.rs":"33111a5c94a6d2e6a5f03fc82092d6300680552d25ffec098f30093edc442bc5","src/linux/signal.rs":"9b6d50cf46d6334d2a5f1ce484f9af47a7eca48bd9edaa8704105c30dbc4bfc4","src/linux/sock_ctrl_msg.rs":"a54d4d321cedf3ce8856cfd2af029a692e676e754bdc5c252e2a4440c1904c6c","src/linux/timerfd.rs":"501f5373b3b733afe9e0606ac2b5b419b63433aa086fcfe434c493f7f4952d38","src/linux/write_zeroes.rs":"0a105f2b12d2c6722c3813c7bcf69df2d2d2884c24fa1f8bda3e3656b8ef03a2","src/metric.rs":"f48ac6edf2a84cdb67d9388d81116ccd876198027ea7026c94d112620e3e5fe4","src/rand.rs":"2531c160515c8e6e8506d2b7e9ae7329854831f700eb94da3329b00218a843ee","src/syscall.rs":"1b90fb6b941d1de8bc149205bafdff4826821311e5295b598b7440603bdabe6e","src/tempfile.rs":"74e985b6a90ce259b4619bca8c01e74dd5442a1efe587b9f7ed24ee36d2a2dc2","src/unix/file_traits.rs":"cc0df75e2efb9a314daafe96799b301c77da8bd8195100311e936d625c936493","src/unix/mod.rs":"7686c7c8f72f22a9a2ee80bb9a083f73b97bc6e76a277b87b7497c68e630a092","src/unix/tempdir.rs":"206cb8c87178da011fa77e2948029dfdac9ebf58fd408dcd6562672f35f020a5","src/unix/terminal.rs":"74d4881db109e7698b68b99f3376a11708ecfed8efac7ec39c5d2a62c13274d7"},"package":"1d1435039746e20da4f8d507a72ee1b916f7b4b05af7a91c093d2c6561934ede"} \ No newline at end of file diff --git a/vendor/vmm-sys-util/CHANGELOG.md b/vendor/vmm-sys-util/CHANGELOG.md index 2a08682..dd5145d 100644 --- a/vendor/vmm-sys-util/CHANGELOG.md +++ b/vendor/vmm-sys-util/CHANGELOG.md @@ -1,4 +1,27 @@ # Changelog + +## v0.12.1 + +### Changed +- [[#215](https://github.com/rust-vmm/vmm-sys-util/pull/215)]: Make + `as_mut_fam_struct()` public and unsafe to let users modify fields of the + header other than the length. + +## v0.12.0 + +### Changed +- Added all features to the generated docs.rs documentation. +- Fixed a bug in `serde` implementation of `FamStructWrapper` which allowed out of + bounds memory access from Rust-safe code. See the related GHSA here: + https://github.com/rust-vmm/vmm-sys-util/security/advisories/GHSA-875g-mfp6-g7f9 + for more information. + +## v0.11.2 + +### Changed +- [[#201](https://github.com/rust-vmm/vmm-sys-util/pull/201)] Updated `SyscallReturnCode` + to accept any signed integer type. + ## v0.11.1 ### Changed diff --git a/vendor/vmm-sys-util/CODEOWNERS b/vendor/vmm-sys-util/CODEOWNERS index b0440e9..c650fc4 100644 --- a/vendor/vmm-sys-util/CODEOWNERS +++ b/vendor/vmm-sys-util/CODEOWNERS @@ -1 +1 @@ -* @liujing2 @sameo @andreeaflorescu @jiangliu +* @liujing2 @sameo @andreeaflorescu @jiangliu @roypat @JonathanWoollett-Light diff --git a/vendor/vmm-sys-util/Cargo.toml b/vendor/vmm-sys-util/Cargo.toml index f1da15c..2719169 100644 --- a/vendor/vmm-sys-util/Cargo.toml +++ b/vendor/vmm-sys-util/Cargo.toml @@ -12,14 +12,21 @@ [package] edition = "2021" name = "vmm-sys-util" -version = "0.11.1" +version = "0.12.1" authors = ["Intel Virtualization Team "] description = "A system utility set" readme = "README.md" keywords = ["utils"] license = "BSD-3-Clause" repository = "https://github.com/rust-vmm/vmm-sys-util" -resolver = "2" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "docsrs", +] + [dependencies.libc] version = "0.2.39" @@ -30,10 +37,18 @@ optional = true [dependencies.serde_derive] version = "1.0.27" optional = true + +[dev-dependencies.bincode] +version = "1.3.3" + [dev-dependencies.serde_json] version = "1.0.9" [features] -with-serde = ["serde", "serde_derive"] +with-serde = [ + "serde", + "serde_derive", +] + [target."cfg(any(target_os = \"linux\", target_os = \"android\"))".dependencies.bitflags] version = "1.0" diff --git a/vendor/vmm-sys-util/coverage_config_x86_64.json b/vendor/vmm-sys-util/coverage_config_x86_64.json index 4277fc0..2c55cb3 100644 --- a/vendor/vmm-sys-util/coverage_config_x86_64.json +++ b/vendor/vmm-sys-util/coverage_config_x86_64.json @@ -1,5 +1,5 @@ { - "coverage_score": 87.1, + "coverage_score": 84.39, "exclude_path": "", "crate_features": "" } diff --git a/vendor/vmm-sys-util/src/fam.rs b/vendor/vmm-sys-util/src/fam.rs index 0d62b0f..13ba4c2 100644 --- a/vendor/vmm-sys-util/src/fam.rs +++ b/vendor/vmm-sys-util/src/fam.rs @@ -50,6 +50,8 @@ impl fmt::Display for Error { /// * the implementer should be a POD /// * the implementor should contain a flexible array member of elements of type `Entry` /// * `Entry` should be a POD +/// * the implementor should ensures that the FAM length as returned by [`FamStruct::len()`] +/// always describes correctly the length of the flexible array member. /// /// Violating these may cause problems. /// @@ -99,7 +101,7 @@ impl fmt::Display for Error { /// self.len as usize /// } /// -/// fn set_len(&mut self, len: usize) { +/// unsafe fn set_len(&mut self, len: usize) { /// self.len = len as u32 /// } /// @@ -135,7 +137,12 @@ pub unsafe trait FamStruct { /// /// These type of structures contain a member that holds the FAM length. /// This method will set the value of that member. - fn set_len(&mut self, len: usize); + /// + /// # Safety + /// + /// The caller needs to ensure that `len` here reflects the correct number of entries of the + /// flexible array part of the struct. + unsafe fn set_len(&mut self, len: usize); /// Get max allowed FAM length /// @@ -169,9 +176,14 @@ impl FamStructWrapper { /// /// Get the capacity required by mem_allocator in order to hold /// the provided number of [`FamStruct::Entry`](trait.FamStruct.html#associatedtype.Entry). - fn mem_allocator_len(fam_len: usize) -> usize { - let wrapper_size_in_bytes = size_of::() + fam_len * size_of::(); - (wrapper_size_in_bytes + size_of::() - 1) / size_of::() + /// Returns `None` if the required length would overflow usize. + fn mem_allocator_len(fam_len: usize) -> Option { + let wrapper_size_in_bytes = + size_of::().checked_add(fam_len.checked_mul(size_of::())?)?; + + wrapper_size_in_bytes + .checked_add(size_of::().checked_sub(1)?)? + .checked_div(size_of::()) } /// Convert `mem_allocator` len to FAM len. @@ -206,7 +218,8 @@ impl FamStructWrapper { return Err(Error::SizeLimitExceeded); } let required_mem_allocator_capacity = - FamStructWrapper::::mem_allocator_len(num_elements); + FamStructWrapper::::mem_allocator_len(num_elements) + .ok_or(Error::SizeLimitExceeded)?; let mut mem_allocator = Vec::with_capacity(required_mem_allocator_capacity); mem_allocator.push(T::default()); @@ -214,7 +227,11 @@ impl FamStructWrapper { // SAFETY: Safe as long T follows the requirements of being POD. mem_allocator.push(unsafe { mem::zeroed() }) } - mem_allocator[0].set_len(num_elements); + // SAFETY: The flexible array part of the struct has `num_elements` capacity. We just + // initialized this in `mem_allocator`. + unsafe { + mem_allocator[0].set_len(num_elements); + } Ok(FamStructWrapper { mem_allocator }) } @@ -234,7 +251,8 @@ impl FamStructWrapper { let mut adapter = FamStructWrapper::::new(entries.len())?; { - let wrapper_entries = adapter.as_mut_fam_struct().as_mut_slice(); + // SAFETY: We are not modifying the length of the FamStruct + let wrapper_entries = unsafe { adapter.as_mut_fam_struct().as_mut_slice() }; wrapper_entries.copy_from_slice(entries); } @@ -271,7 +289,12 @@ impl FamStructWrapper { } /// Get a mut reference to the actual [`FamStruct`](trait.FamStruct.html) instance. - pub fn as_mut_fam_struct(&mut self) -> &mut T { + /// + /// # Safety + /// + /// Callers must not use the reference returned to modify the `len` filed of the underlying + /// `FamStruct`. See also the top-level documentation of [`FamStruct`]. + pub unsafe fn as_mut_fam_struct(&mut self) -> &mut T { &mut self.mem_allocator[0] } @@ -294,7 +317,8 @@ impl FamStructWrapper { /// Modifying the container referenced by this pointer may cause its buffer /// to be reallocated, which would also make any pointers to it invalid. pub fn as_mut_fam_struct_ptr(&mut self) -> *mut T { - self.as_mut_fam_struct() + // SAFETY: We do not change the length of the underlying FamStruct. + unsafe { self.as_mut_fam_struct() } } /// Get the elements slice. @@ -304,7 +328,8 @@ impl FamStructWrapper { /// Get the mutable elements slice. pub fn as_mut_slice(&mut self) -> &mut [T::Entry] { - self.as_mut_fam_struct().as_mut_slice() + // SAFETY: We do not change the length of the underlying FamStruct. + unsafe { self.as_mut_fam_struct() }.as_mut_slice() } /// Get the number of elements of type `FamStruct::Entry` currently in the vec. @@ -326,17 +351,20 @@ impl FamStructWrapper { /// /// If the capacity is already reserved, this method doesn't do anything. /// If not this will trigger a reallocation of the underlying buffer. - fn reserve(&mut self, additional: usize) { + fn reserve(&mut self, additional: usize) -> Result<(), Error> { let desired_capacity = self.len() + additional; if desired_capacity <= self.capacity() { - return; + return Ok(()); } let current_mem_allocator_len = self.mem_allocator.len(); - let required_mem_allocator_len = FamStructWrapper::::mem_allocator_len(desired_capacity); + let required_mem_allocator_len = FamStructWrapper::::mem_allocator_len(desired_capacity) + .ok_or(Error::SizeLimitExceeded)?; let additional_mem_allocator_len = required_mem_allocator_len - current_mem_allocator_len; self.mem_allocator.reserve(additional_mem_allocator_len); + + Ok(()) } /// Update the length of the FamStructWrapper. @@ -352,7 +380,10 @@ impl FamStructWrapper { /// /// When len is greater than the max possible len it returns Error::SizeLimitExceeded. fn set_len(&mut self, len: usize) -> Result<(), Error> { - let additional_elements: isize = len as isize - self.len() as isize; + let additional_elements = isize::try_from(len) + .and_then(|len| isize::try_from(self.len()).map(|self_len| len - self_len)) + .map_err(|_| Error::SizeLimitExceeded)?; + // If len == self.len there's nothing to do. if additional_elements == 0 { return Ok(()); @@ -365,11 +396,12 @@ impl FamStructWrapper { return Err(Error::SizeLimitExceeded); } // Reserve additional capacity. - self.reserve(additional_elements as usize); + self.reserve(additional_elements as usize)?; } let current_mem_allocator_len = self.mem_allocator.len(); - let required_mem_allocator_len = FamStructWrapper::::mem_allocator_len(len); + let required_mem_allocator_len = + FamStructWrapper::::mem_allocator_len(len).ok_or(Error::SizeLimitExceeded)?; // Update the len of the `mem_allocator`. // SAFETY: This is safe since enough capacity has been reserved. unsafe { @@ -382,7 +414,11 @@ impl FamStructWrapper { self.mem_allocator[i] = unsafe { mem::zeroed() } } // Update the len of the underlying `FamStruct`. - self.as_mut_fam_struct().set_len(len); + // SAFETY: We just adjusted the memory for the underlying `mem_allocator` to hold `len` + // entries. + unsafe { + self.as_mut_fam_struct().set_len(len); + } // If the len needs to be decreased, deallocate unnecessary memory if additional_elements < 0 { @@ -445,9 +481,9 @@ impl PartialEq for FamStructWrapper { impl Clone for FamStructWrapper { fn clone(&self) -> Self { // The number of entries (self.as_slice().len()) can't be > T::max_len() since `self` is a - // valid `FamStructWrapper`. + // valid `FamStructWrapper`. This makes the .unwrap() safe. let required_mem_allocator_capacity = - FamStructWrapper::::mem_allocator_len(self.as_slice().len()); + FamStructWrapper::::mem_allocator_len(self.as_slice().len()).unwrap(); let mut mem_allocator = Vec::with_capacity(required_mem_allocator_capacity); @@ -469,7 +505,7 @@ impl Clone for FamStructWrapper { let mut adapter = FamStructWrapper { mem_allocator }; { - let wrapper_entries = adapter.as_mut_fam_struct().as_mut_slice(); + let wrapper_entries = adapter.as_mut_slice(); wrapper_entries.copy_from_slice(self.as_slice()); } adapter @@ -527,13 +563,23 @@ where { use serde::de::Error; - let header = seq + let header: X = seq .next_element()? .ok_or_else(|| de::Error::invalid_length(0, &self))?; let entries: Vec = seq .next_element()? .ok_or_else(|| de::Error::invalid_length(1, &self))?; + if header.len() != entries.len() { + let msg = format!( + "Mismatch between length of FAM specified in FamStruct header ({}) \ + and actual size of FAM ({})", + header.len(), + entries.len() + ); + return Err(V::Error::custom(msg)); + } + let mut result: Self::Value = FamStructWrapper::from_entries(entries.as_slice()) .map_err(|e| V::Error::custom(format!("{:?}", e)))?; result.mem_allocator[0] = header; @@ -557,7 +603,7 @@ macro_rules! generate_fam_struct_impl { self.$field_name as usize } - fn set_len(&mut self, len: usize) { + unsafe fn set_len(&mut self, len: usize) { self.$field_name = len as $field_type; } @@ -581,6 +627,7 @@ macro_rules! generate_fam_struct_impl { #[cfg(test)] mod tests { #![allow(clippy::undocumented_unsafe_blocks)] + #[cfg(feature = "with-serde")] use serde_derive::{Deserialize, Serialize}; @@ -589,7 +636,7 @@ mod tests { const MAX_LEN: usize = 100; #[repr(C)] - #[derive(Default, PartialEq, Eq)] + #[derive(Default, Debug, PartialEq, Eq)] pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); impl __IncompleteArrayField { #[inline] @@ -678,12 +725,30 @@ mod tests { let fam_len = pair.0; let mem_allocator_len = pair.1; assert_eq!( - mem_allocator_len, + Some(mem_allocator_len), MockFamStructWrapper::mem_allocator_len(fam_len) ); } } + #[repr(C)] + #[derive(Default, PartialEq)] + struct MockFamStructU8 { + pub len: u32, + pub padding: u32, + pub entries: __IncompleteArrayField, + } + generate_fam_struct_impl!(MockFamStructU8, u8, entries, u32, len, 100); + type MockFamStructWrapperU8 = FamStructWrapper; + #[test] + fn test_invalid_type_conversion() { + let mut adapter = MockFamStructWrapperU8::new(10).unwrap(); + assert!(matches!( + adapter.set_len(0xffff_ffff_ffff_ff00), + Err(Error::SizeLimitExceeded) + )); + } + #[test] fn test_wrapper_len() { for pair in MEM_ALLOCATOR_LEN_TO_FAM_LEN { @@ -785,7 +850,7 @@ mod tests { let num_elements = pair.0; let required_mem_allocator_len = pair.1; - adapter.reserve(num_elements); + adapter.reserve(num_elements).unwrap(); assert!(adapter.mem_allocator.capacity() >= required_mem_allocator_len); assert_eq!(0, adapter.len()); @@ -794,7 +859,7 @@ mod tests { // test that when the capacity is already reserved, the method doesn't do anything let current_capacity = adapter.capacity(); - adapter.reserve(current_capacity - 1); + adapter.reserve(current_capacity - 1).unwrap(); assert_eq!(current_capacity, adapter.capacity()); } @@ -831,7 +896,8 @@ mod tests { assert_eq!(adapter.as_slice()[i], i as u32); assert_eq!(adapter.len(), i + 1); assert!( - adapter.mem_allocator.capacity() >= MockFamStructWrapper::mem_allocator_len(i + 1) + adapter.mem_allocator.capacity() + >= MockFamStructWrapper::mem_allocator_len(i + 1).unwrap() ); } @@ -858,7 +924,7 @@ mod tests { assert_eq!(adapter.len(), num_retained_entries); assert!( adapter.mem_allocator.capacity() - >= MockFamStructWrapper::mem_allocator_len(num_retained_entries) + >= MockFamStructWrapper::mem_allocator_len(num_retained_entries).unwrap() ); } @@ -910,7 +976,7 @@ mod tests { assert_eq!(payload[0], 0xA5); assert_eq!(payload[1], 0x1e); } - assert_eq!(wrapper.as_mut_fam_struct().padding, 5); + assert_eq!(unsafe { wrapper.as_mut_fam_struct() }.padding, 5); let data = wrapper.into_raw(); assert_eq!(data[0].len, 2); assert_eq!(data[0].padding, 5); @@ -996,53 +1062,81 @@ mod tests { type FooFamStructWrapper = FamStructWrapper; let mut wrapper = FooFamStructWrapper::new(0).unwrap(); - wrapper.as_mut_fam_struct().index = 1; - wrapper.as_mut_fam_struct().flags = 2; - wrapper.as_mut_fam_struct().length = 3; - wrapper.push(3).unwrap(); - wrapper.push(14).unwrap(); - assert_eq!(wrapper.as_slice().len(), 3 + 2); - assert_eq!(wrapper.as_slice()[3], 3); - assert_eq!(wrapper.as_slice()[3 + 1], 14); - - let mut wrapper2 = wrapper.clone(); - assert_eq!( - wrapper.as_mut_fam_struct().index, - wrapper2.as_mut_fam_struct().index - ); - assert_eq!( - wrapper.as_mut_fam_struct().length, - wrapper2.as_mut_fam_struct().length - ); - assert_eq!( - wrapper.as_mut_fam_struct().flags, - wrapper2.as_mut_fam_struct().flags - ); - assert_eq!(wrapper.as_slice(), wrapper2.as_slice()); - assert_eq!( - wrapper2.as_slice().len(), - wrapper2.as_mut_fam_struct().length as usize - ); - assert!(wrapper == wrapper2); + // SAFETY: We do play with length here, but that's just for testing purposes :) + unsafe { + wrapper.as_mut_fam_struct().index = 1; + wrapper.as_mut_fam_struct().flags = 2; + wrapper.as_mut_fam_struct().length = 3; + wrapper.push(3).unwrap(); + wrapper.push(14).unwrap(); + assert_eq!(wrapper.as_slice().len(), 3 + 2); + assert_eq!(wrapper.as_slice()[3], 3); + assert_eq!(wrapper.as_slice()[3 + 1], 14); + + let mut wrapper2 = wrapper.clone(); + assert_eq!( + wrapper.as_mut_fam_struct().index, + wrapper2.as_mut_fam_struct().index + ); + assert_eq!( + wrapper.as_mut_fam_struct().length, + wrapper2.as_mut_fam_struct().length + ); + assert_eq!( + wrapper.as_mut_fam_struct().flags, + wrapper2.as_mut_fam_struct().flags + ); + assert_eq!(wrapper.as_slice(), wrapper2.as_slice()); + assert_eq!( + wrapper2.as_slice().len(), + wrapper2.as_mut_fam_struct().length as usize + ); + assert!(wrapper == wrapper2); - wrapper.as_mut_fam_struct().index = 3; - assert!(wrapper != wrapper2); + wrapper.as_mut_fam_struct().index = 3; + assert!(wrapper != wrapper2); - wrapper.as_mut_fam_struct().length = 7; - assert!(wrapper != wrapper2); + wrapper.as_mut_fam_struct().length = 7; + assert!(wrapper != wrapper2); - wrapper.push(1).unwrap(); - assert_eq!(wrapper.as_mut_fam_struct().length, 8); - assert!(wrapper != wrapper2); + wrapper.push(1).unwrap(); + assert_eq!(wrapper.as_mut_fam_struct().length, 8); + assert!(wrapper != wrapper2); - let mut wrapper2 = wrapper.clone(); - assert!(wrapper == wrapper2); + let mut wrapper2 = wrapper.clone(); + assert!(wrapper == wrapper2); - // Dropping the original variable should not affect its clone. - drop(wrapper); - assert_eq!(wrapper2.as_mut_fam_struct().index, 3); - assert_eq!(wrapper2.as_mut_fam_struct().length, 8); - assert_eq!(wrapper2.as_mut_fam_struct().flags, 2); - assert_eq!(wrapper2.as_slice(), [0, 0, 0, 3, 14, 0, 0, 1]); + // Dropping the original variable should not affect its clone. + drop(wrapper); + assert_eq!(wrapper2.as_mut_fam_struct().index, 3); + assert_eq!(wrapper2.as_mut_fam_struct().length, 8); + assert_eq!(wrapper2.as_mut_fam_struct().flags, 2); + assert_eq!(wrapper2.as_slice(), [0, 0, 0, 3, 14, 0, 0, 1]); + } + } + + #[cfg(feature = "with-serde")] + #[test] + fn test_bad_deserialize() { + #[repr(C)] + #[derive(Default, Debug, PartialEq, Serialize, Deserialize)] + struct Foo { + pub len: u32, + pub padding: u32, + pub entries: __IncompleteArrayField, + } + + generate_fam_struct_impl!(Foo, u32, entries, u32, len, 100); + + let state = FamStructWrapper::::new(0).unwrap(); + let mut bytes = bincode::serialize(&state).unwrap(); + + // The `len` field of the header is the first to be serialized. + // Writing at position 0 of the serialized data should change its value. + bytes[0] = 255; + + assert!( + matches!(bincode::deserialize::>(&bytes).map_err(|boxed| *boxed), Err(bincode::ErrorKind::Custom(s)) if s == *"Mismatch between length of FAM specified in FamStruct header (255) and actual size of FAM (0)") + ); } } diff --git a/vendor/vmm-sys-util/src/lib.rs b/vendor/vmm-sys-util/src/lib.rs index 1929816..0467825 100644 --- a/vendor/vmm-sys-util/src/lib.rs +++ b/vendor/vmm-sys-util/src/lib.rs @@ -4,7 +4,8 @@ //! Collection of modules that provides helpers and utilities used by multiple //! [rust-vmm](https://github.com/rust-vmm/community) components. -#![deny(missing_docs)] +#![deny(missing_docs, missing_debug_implementations)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #[cfg(any(target_os = "linux", target_os = "android"))] mod linux; diff --git a/vendor/vmm-sys-util/src/linux/aio.rs b/vendor/vmm-sys-util/src/linux/aio.rs index 1e14ea0..98bc2cf 100644 --- a/vendor/vmm-sys-util/src/linux/aio.rs +++ b/vendor/vmm-sys-util/src/linux/aio.rs @@ -223,7 +223,7 @@ impl IoContext { ) -> Result { let to = match timeout { Some(val) => val as *mut libc::timespec, - None => null_mut() as *mut libc::timespec, + None => null_mut(), }; // SAFETY: It's safe because parameters are valid and we have checked the result. diff --git a/vendor/vmm-sys-util/src/linux/epoll.rs b/vendor/vmm-sys-util/src/linux/epoll.rs index b8e9b7b..c68d1f9 100644 --- a/vendor/vmm-sys-util/src/linux/epoll.rs +++ b/vendor/vmm-sys-util/src/linux/epoll.rs @@ -19,6 +19,7 @@ use libc::{ use crate::syscall::SyscallReturnCode; /// Wrapper over `EPOLL_CTL_*` operations that can be performed on a file descriptor. +#[derive(Debug)] #[repr(i32)] pub enum ControlOperation { /// Add a file descriptor to the interest list. @@ -385,20 +386,12 @@ mod tests { // For EPOLL_CTL_ADD behavior we will try to add some fds with different event masks into // the interest list of epoll instance. assert!(epoll - .ctl( - ControlOperation::Add, - event_fd_1.as_raw_fd() as i32, - event_1 - ) + .ctl(ControlOperation::Add, event_fd_1.as_raw_fd(), event_1) .is_ok()); // We can't add twice the same fd to epoll interest list. assert!(epoll - .ctl( - ControlOperation::Add, - event_fd_1.as_raw_fd() as i32, - event_1 - ) + .ctl(ControlOperation::Add, event_fd_1.as_raw_fd(), event_1) .is_err()); let event_fd_2 = EventFd::new(libc::EFD_NONBLOCK).unwrap(); @@ -406,7 +399,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Add, - event_fd_2.as_raw_fd() as i32, + event_fd_2.as_raw_fd(), // For this fd, we want an Event instance that has `data` field set to other // value than the value of the fd and `events` without EPOLLIN type set. EpollEvent::new(EventSet::OUT, 10) @@ -419,11 +412,7 @@ mod tests { let event_fd_3 = EventFd::new(libc::EFD_NONBLOCK).unwrap(); let event_3 = EpollEvent::new(EventSet::OUT | EventSet::IN, event_fd_3.as_raw_fd() as u64); assert!(epoll - .ctl( - ControlOperation::Add, - event_fd_3.as_raw_fd() as i32, - event_3 - ) + .ctl(ControlOperation::Add, event_fd_3.as_raw_fd(), event_3) .is_ok()); // Let's check `epoll_wait()` behavior for our epoll instance. @@ -457,11 +446,7 @@ mod tests { // that we want to monitor this time on event_fd_1. event_1 = EpollEvent::new(EventSet::OUT, 20); assert!(epoll - .ctl( - ControlOperation::Modify, - event_fd_1.as_raw_fd() as i32, - event_1 - ) + .ctl(ControlOperation::Modify, event_fd_1.as_raw_fd(), event_1) .is_ok()); let event_fd_4 = EventFd::new(libc::EFD_NONBLOCK).unwrap(); @@ -469,7 +454,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Modify, - event_fd_4.as_raw_fd() as i32, + event_fd_4.as_raw_fd(), EpollEvent::default() ) .is_err()); @@ -485,7 +470,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Modify, - event_fd_1.as_raw_fd() as i32, + event_fd_1.as_raw_fd(), EpollEvent::default() ) .is_ok()); @@ -498,7 +483,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Delete, - event_fd_2.as_raw_fd() as i32, + event_fd_2.as_raw_fd(), EpollEvent::default() ) .is_ok()); @@ -514,7 +499,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Delete, - event_fd_4.as_raw_fd() as i32, + event_fd_4.as_raw_fd(), EpollEvent::default() ) .is_err()); diff --git a/vendor/vmm-sys-util/src/linux/fallocate.rs b/vendor/vmm-sys-util/src/linux/fallocate.rs index e3a7fed..904bff2 100644 --- a/vendor/vmm-sys-util/src/linux/fallocate.rs +++ b/vendor/vmm-sys-util/src/linux/fallocate.rs @@ -14,6 +14,7 @@ use crate::errno::{errno_result, Error, Result}; /// Operation to be performed on a given range when calling [`fallocate`] /// /// [`fallocate`]: fn.fallocate.html +#[derive(Debug)] pub enum FallocateMode { /// Deallocating file space. PunchHole, diff --git a/vendor/vmm-sys-util/src/linux/poll.rs b/vendor/vmm-sys-util/src/linux/poll.rs index 12809f0..54dd4b9 100644 --- a/vendor/vmm-sys-util/src/linux/poll.rs +++ b/vendor/vmm-sys-util/src/linux/poll.rs @@ -47,6 +47,12 @@ const POLL_CONTEXT_MAX_EVENTS: usize = 16; /// This should only be used with [`EpollContext`](struct.EpollContext.html). pub struct EpollEvents(RefCell<[epoll_event; POLL_CONTEXT_MAX_EVENTS]>); +impl std::fmt::Debug for EpollEvents { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "EpollEvents {{ ... }}") + } +} + impl EpollEvents { /// Creates a new EpollEvents. pub fn new() -> EpollEvents { @@ -90,7 +96,7 @@ impl PollToken for usize { impl PollToken for u64 { fn as_raw_token(&self) -> u64 { - *self as u64 + *self } fn from_raw_token(data: u64) -> Self { @@ -142,6 +148,15 @@ pub struct PollEvent<'a, T> { token: PhantomData, // Needed to satisfy usage of T } +impl std::fmt::Debug for PollEvent<'_, T> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("PollEvent") + .field("event", &"?") + .field("token", &self.token) + .finish() + } +} + impl<'a, T: PollToken> PollEvent<'a, T> { /// Gets the token associated in /// [`PollContext::add`](struct.PollContext.html#method.add) with this event. @@ -189,6 +204,7 @@ impl<'a, T: PollToken> PollEvent<'a, T> { /// An iterator over a subset of events returned by /// [`PollContext::wait`](struct.PollContext.html#method.wait). +#[derive(Debug)] pub struct PollEventIter<'a, I, T> where I: Iterator, @@ -222,6 +238,16 @@ pub struct PollEvents<'a, T> { tokens: PhantomData<[T]>, // Needed to satisfy usage of T } +impl std::fmt::Debug for PollEvents<'_, T> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("PollEventsOwned") + .field("count", &self.count) + .field("events", &"?") + .field("tokens", &self.tokens) + .finish() + } +} + impl<'a, T: PollToken> PollEvents<'a, T> { /// Creates owned structure from borrowed [`PollEvents`](struct.PollEvents.html). /// @@ -270,6 +296,16 @@ pub struct PollEventsOwned { tokens: PhantomData, // Needed to satisfy usage of T } +impl std::fmt::Debug for PollEventsOwned { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("PollEventsOwned") + .field("count", &self.count) + .field("events", &"?") + .field("tokens", &self.tokens) + .finish() + } +} + impl PollEventsOwned { /// Creates borrowed structure from owned structure /// [`PollEventsOwned`](struct.PollEventsOwned.html). @@ -286,7 +322,7 @@ impl PollEventsOwned { } /// Watching events taken by [`PollContext`](struct.PollContext.html). -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct WatchingEvents(u32); impl WatchingEvents { @@ -355,6 +391,7 @@ impl WatchingEvents { /// assert_eq!(event.token(), 1); /// } /// ``` +#[derive(Debug)] pub struct EpollContext { epoll_ctx: File, // Needed to satisfy usage of T @@ -699,6 +736,7 @@ impl IntoRawFd for EpollContext { /// let tokens: Vec = pollevents.iter_readable().map(|e| e.token()).collect(); /// assert_eq!(&tokens[..], &[2]); /// ``` +#[derive(Debug)] pub struct PollContext { epoll_ctx: EpollContext, @@ -834,6 +872,8 @@ impl PollContext { let mut buf = [0u8; 512]; let (res, len) = { let mut buf_cursor = Cursor::new(&mut buf[..]); + // Oops, clippy bug. See https://github.com/rust-lang/rust-clippy/issues/9810 + #[allow(clippy::write_literal)] ( writeln!( &mut buf_cursor, diff --git a/vendor/vmm-sys-util/src/linux/seek_hole.rs b/vendor/vmm-sys-util/src/linux/seek_hole.rs index 1392993..6c35455 100644 --- a/vendor/vmm-sys-util/src/linux/seek_hole.rs +++ b/vendor/vmm-sys-util/src/linux/seek_hole.rs @@ -84,7 +84,7 @@ mod tests { use std::path::PathBuf; fn seek_cur(file: &mut File) -> u64 { - file.seek(SeekFrom::Current(0)).unwrap() + file.stream_position().unwrap() } #[test] @@ -154,7 +154,7 @@ mod tests { assert_eq!(seek_cur(&mut file), 0xFFFF); // seek_hole at or after the end of the file should return None - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x10000).unwrap(), None); assert_eq!(seek_cur(&mut file), 0); assert_eq!(file.seek_hole(0x10001).unwrap(), None); @@ -172,18 +172,18 @@ mod tests { assert_eq!(seek_cur(&mut file), 0xFFFF); // seek_hole within data should return the next hole (EOF) - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x10000).unwrap(), Some(0x20000)); assert_eq!(seek_cur(&mut file), 0x20000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x10001).unwrap(), Some(0x20000)); assert_eq!(seek_cur(&mut file), 0x20000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x1FFFF).unwrap(), Some(0x20000)); assert_eq!(seek_cur(&mut file), 0x20000); // seek_hole at EOF after data should return None - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x20000).unwrap(), None); assert_eq!(seek_cur(&mut file), 0); @@ -193,21 +193,21 @@ mod tests { assert_eq!(seek_cur(&mut file), 0); assert_eq!(file.seek_hole(0xFFFF).unwrap(), Some(0xFFFF)); assert_eq!(seek_cur(&mut file), 0xFFFF); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x10000).unwrap(), Some(0x20000)); assert_eq!(seek_cur(&mut file), 0x20000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x1FFFF).unwrap(), Some(0x20000)); assert_eq!(seek_cur(&mut file), 0x20000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x20000).unwrap(), Some(0x20000)); assert_eq!(seek_cur(&mut file), 0x20000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x20001).unwrap(), Some(0x20001)); assert_eq!(seek_cur(&mut file), 0x20001); // seek_hole at EOF after a hole should return None - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x30000).unwrap(), None); assert_eq!(seek_cur(&mut file), 0); @@ -218,10 +218,10 @@ mod tests { // seek_hole within [0x20000, 0x30000) should now find the hole at EOF assert_eq!(file.seek_hole(0x20000).unwrap(), Some(0x30000)); assert_eq!(seek_cur(&mut file), 0x30000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x20001).unwrap(), Some(0x30000)); assert_eq!(seek_cur(&mut file), 0x30000); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); assert_eq!(file.seek_hole(0x30000).unwrap(), None); assert_eq!(seek_cur(&mut file), 0); } diff --git a/vendor/vmm-sys-util/src/linux/sock_ctrl_msg.rs b/vendor/vmm-sys-util/src/linux/sock_ctrl_msg.rs index 0c19a11..9e69e2b 100644 --- a/vendor/vmm-sys-util/src/linux/sock_ctrl_msg.rs +++ b/vendor/vmm-sys-util/src/linux/sock_ctrl_msg.rs @@ -98,7 +98,10 @@ fn set_msg_controllen(msg: &mut msghdr, cmsg_capacity: usize) { // This function is like CMSG_NEXT, but safer because it reads only from references, although it // does some pointer arithmetic on cmsg_ptr. -#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] +#[cfg_attr( + feature = "cargo-clippy", + allow(clippy::cast_ptr_alignment, clippy::unnecessary_cast) +)] fn get_next_cmsg(msghdr: &msghdr, cmsg: &cmsghdr, cmsg_ptr: *mut cmsghdr) -> *mut cmsghdr { let next_cmsg = (cmsg_ptr as *mut u8).wrapping_add(CMSG_ALIGN!(cmsg.cmsg_len)) as *mut cmsghdr; if next_cmsg @@ -151,7 +154,7 @@ impl CmsgBuffer { } fn raw_sendmsg(fd: RawFd, out_data: &[D], out_fds: &[RawFd]) -> Result { - let cmsg_capacity = CMSG_SPACE!(size_of::() * out_fds.len()); + let cmsg_capacity = CMSG_SPACE!(std::mem::size_of_val(out_fds)); let mut cmsg_buffer = CmsgBuffer::with_capacity(cmsg_capacity); let mut iovecs = Vec::with_capacity(out_data.len()); @@ -166,7 +169,7 @@ fn raw_sendmsg(fd: RawFd, out_data: &[D], out_fds: &[RawFd]) -> Re if !out_fds.is_empty() { let cmsg = cmsghdr { - cmsg_len: CMSG_LEN!(size_of::() * out_fds.len()), + cmsg_len: CMSG_LEN!(std::mem::size_of_val(out_fds)), cmsg_level: SOL_SOCKET, cmsg_type: SCM_RIGHTS, #[cfg(all(target_env = "musl", target_pointer_width = "64"))] @@ -175,7 +178,7 @@ fn raw_sendmsg(fd: RawFd, out_data: &[D], out_fds: &[RawFd]) -> Re // SAFETY: Check comments below for each call. unsafe { // Safe because cmsg_buffer was allocated to be large enough to contain cmsghdr. - write_unaligned(cmsg_buffer.as_mut_ptr() as *mut cmsghdr, cmsg); + write_unaligned(cmsg_buffer.as_mut_ptr(), cmsg); // Safe because the cmsg_buffer was allocated to be large enough to hold out_fds.len() // file descriptors. copy_nonoverlapping( @@ -200,12 +203,13 @@ fn raw_sendmsg(fd: RawFd, out_data: &[D], out_fds: &[RawFd]) -> Re } } +#[cfg_attr(feature = "cargo-clippy", allow(clippy::unnecessary_cast))] unsafe fn raw_recvmsg( fd: RawFd, iovecs: &mut [iovec], in_fds: &mut [RawFd], ) -> Result<(usize, usize)> { - let cmsg_capacity = CMSG_SPACE!(size_of::() * in_fds.len()); + let cmsg_capacity = CMSG_SPACE!(std::mem::size_of_val(in_fds)); let mut cmsg_buffer = CmsgBuffer::with_capacity(cmsg_capacity); let mut msg = new_msghdr(iovecs); @@ -241,7 +245,7 @@ unsafe fn raw_recvmsg( // read. let cmsg = (cmsg_ptr as *mut cmsghdr).read_unaligned(); if cmsg.cmsg_level == SOL_SOCKET && cmsg.cmsg_type == SCM_RIGHTS { - let fds_count = ((cmsg.cmsg_len - CMSG_LEN!(0)) as usize) / size_of::(); + let fds_count: usize = ((cmsg.cmsg_len - CMSG_LEN!(0)) as usize) / size_of::(); // The sender can transmit more data than we can buffer. If a message is too long to // fit in the supplied buffer, excess bytes may be discarded depending on the type of // socket the message is received from. diff --git a/vendor/vmm-sys-util/src/linux/timerfd.rs b/vendor/vmm-sys-util/src/linux/timerfd.rs index 80f0789..a67198b 100644 --- a/vendor/vmm-sys-util/src/linux/timerfd.rs +++ b/vendor/vmm-sys-util/src/linux/timerfd.rs @@ -19,6 +19,7 @@ use crate::errno::{errno_result, Result}; /// A safe wrapper around a Linux /// [`timerfd`](http://man7.org/linux/man-pages/man2/timerfd_create.2.html). +#[derive(Debug)] pub struct TimerFd(File); impl TimerFd { diff --git a/vendor/vmm-sys-util/src/linux/write_zeroes.rs b/vendor/vmm-sys-util/src/linux/write_zeroes.rs index e6084da..4c9e77b 100644 --- a/vendor/vmm-sys-util/src/linux/write_zeroes.rs +++ b/vendor/vmm-sys-util/src/linux/write_zeroes.rs @@ -28,7 +28,7 @@ pub trait PunchHole { impl PunchHole for File { fn punch_hole(&mut self, offset: u64, length: u64) -> Result<()> { - fallocate(self, FallocateMode::PunchHole, true, offset, length as u64) + fallocate(self, FallocateMode::PunchHole, true, offset, length) .map_err(|e| Error::from_raw_os_error(e.errno())) } } @@ -140,7 +140,7 @@ impl WriteZeroesAt for File { impl WriteZeroes for T { fn write_zeroes(&mut self, length: usize) -> Result { - let offset = self.seek(SeekFrom::Current(0))?; + let offset = self.stream_position()?; let num_written = self.write_zeroes_at(offset, length)?; // Advance the seek cursor as if we had done a real write(). self.seek(SeekFrom::Current(num_written as i64))?; @@ -171,7 +171,7 @@ mod tests { // Read back the data plus some overlap on each side. let mut readback = [0u8; 16384]; - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.read_exact(&mut readback).unwrap(); // Bytes before the write should still be 0. for read in &readback[0..1234] { @@ -190,10 +190,10 @@ mod tests { f.seek(SeekFrom::Start(2345)).unwrap(); f.write_all_zeroes(4321).unwrap(); // Verify seek position after `write_all_zeroes()`. - assert_eq!(f.seek(SeekFrom::Current(0)).unwrap(), 2345 + 4321); + assert_eq!(f.stream_position().unwrap(), 2345 + 4321); // Read back the data and verify that it is now zero. - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.read_exact(&mut readback).unwrap(); // Bytes before the write should still be 0. for read in &readback[0..1234] { @@ -228,19 +228,19 @@ mod tests { // Write buffer of non-zero bytes. The size of the buffer will be the new // size of the file. let orig_data = [NON_ZERO_VALUE; SIZE]; - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.write_all(&orig_data).unwrap(); assert_eq!(f.metadata().unwrap().len(), SIZE as u64); // Overwrite some of the data with zeroes. - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.write_all_zeroes(0x1_0001).unwrap(); // Verify seek position after `write_all_zeroes()`. - assert_eq!(f.seek(SeekFrom::Current(0)).unwrap(), 0x1_0001); + assert_eq!(f.stream_position().unwrap(), 0x1_0001); // Read back the data and verify that it is now zero. let mut readback = [0u8; SIZE]; - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.read_exact(&mut readback).unwrap(); // Verify that `write_all_zeroes()` zeroed the intended region. for read in &readback[0..0x1_0001] { @@ -253,7 +253,7 @@ mod tests { // Now let's zero a certain region by using `write_all_zeroes_at()`. f.write_all_zeroes_at(0x1_8001, 0x200).unwrap(); - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.read_exact(&mut readback).unwrap(); // Original data should still exist before the zeroed region. @@ -281,7 +281,7 @@ mod tests { // Write buffer of non-zero bytes. The size of the buffer will be the new // size of the file. let orig_data = [NON_ZERO_VALUE; SIZE]; - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.write_all(&orig_data).unwrap(); assert_eq!(f.metadata().unwrap().len(), SIZE as u64); @@ -291,7 +291,7 @@ mod tests { // Read back the data. let mut readback = [0u8; SIZE]; - f.seek(SeekFrom::Start(0)).unwrap(); + f.rewind().unwrap(); f.read_exact(&mut readback).unwrap(); // Original data should still exist before the hole. for read in &readback[0..0x1_0001] { diff --git a/vendor/vmm-sys-util/src/rand.rs b/vendor/vmm-sys-util/src/rand.rs index 097341f..8a88dd3 100644 --- a/vendor/vmm-sys-util/src/rand.rs +++ b/vendor/vmm-sys-util/src/rand.rs @@ -19,7 +19,7 @@ pub fn timestamp_cycles() -> u64 { #[cfg(target_arch = "x86_64")] // SAFETY: Safe because there's nothing that can go wrong with this call. unsafe { - std::arch::x86_64::_rdtsc() as u64 + std::arch::x86_64::_rdtsc() } #[cfg(not(target_arch = "x86_64"))] @@ -124,13 +124,21 @@ mod tests { // The 33 will be discarded as it is not a valid letter // (upper or lower) or number. let s = xor_pseudo_rng_u8_alphanumerics(&|| i); - assert_eq!(vec![54, 55], s); + if cfg!(target_endian = "big") { + assert_eq!(vec![55, 54], s); + } else { + assert_eq!(vec![54, 55], s); + } } #[test] fn test_rand_alphanumerics_impl() { let s = rand_alphanumerics_impl(&|| 14134, 5); - assert_eq!("67676", s); + if cfg!(target_endian = "big") { + assert_eq!("76767", s); + } else { + assert_eq!("67676", s); + } } #[test] @@ -145,13 +153,21 @@ mod tests { // The 33 will be discarded as it is not a valid letter // (upper or lower) or number. let s = xor_pseudo_rng_u8_bytes(&|| i); - assert_eq!(vec![54, 33, 55, 0], s); + if cfg!(target_endian = "big") { + assert_eq!(vec![0, 55, 33, 54], s); + } else { + assert_eq!(vec![54, 33, 55, 0], s); + } } #[test] fn test_rand_bytes_impl() { let s = rand_bytes_impl(&|| 1234567, 4); - assert_eq!(vec![135, 214, 18, 0], s); + if cfg!(target_endian = "big") { + assert_eq!(vec![0, 18, 214, 135], s); + } else { + assert_eq!(vec![135, 214, 18, 0], s); + } } #[test] diff --git a/vendor/vmm-sys-util/src/syscall.rs b/vendor/vmm-sys-util/src/syscall.rs index 6fb4d64..a89209a 100644 --- a/vendor/vmm-sys-util/src/syscall.rs +++ b/vendor/vmm-sys-util/src/syscall.rs @@ -6,12 +6,13 @@ use std::os::raw::c_int; /// Wrapper to interpret syscall exit codes and provide a rustacean `io::Result`. -pub struct SyscallReturnCode(pub c_int); +#[derive(Debug)] +pub struct SyscallReturnCode + Eq = c_int>(pub T); -impl SyscallReturnCode { +impl + Eq> SyscallReturnCode { /// Returns the last OS error if value is -1 or Ok(value) otherwise. - pub fn into_result(self) -> std::io::Result { - if self.0 == -1 { + pub fn into_result(self) -> std::io::Result { + if self.0 == T::from(-1) { Err(std::io::Error::last_os_error()) } else { Ok(self.0) @@ -46,5 +47,14 @@ mod tests { syscall_code = SyscallReturnCode(-1); assert!(syscall_code.into_empty_result().is_err()); + + let mut syscall_code_long = SyscallReturnCode(1i64); + match syscall_code_long.into_result() { + Ok(_value) => (), + _ => unreachable!(), + } + + syscall_code_long = SyscallReturnCode(-1i64); + assert!(syscall_code_long.into_result().is_err()); } } diff --git a/vendor/vmm-sys-util/src/tempfile.rs b/vendor/vmm-sys-util/src/tempfile.rs index 7d70f66..de663c9 100644 --- a/vendor/vmm-sys-util/src/tempfile.rs +++ b/vendor/vmm-sys-util/src/tempfile.rs @@ -39,6 +39,7 @@ use crate::errno::{errno_result, Error, Result}; /// Wrapper for working with temporary files. /// /// The file will be maintained for the lifetime of the `TempFile` object. +#[derive(Debug)] pub struct TempFile { path: PathBuf, file: Option, @@ -60,22 +61,21 @@ impl TempFile { let mut os_fname = prefix.as_ref().to_os_string(); os_fname.push("XXXXXX"); - let raw_fname = match CString::new(os_fname.as_bytes()) { - Ok(c_string) => c_string.into_raw(), - Err(_) => return Err(Error::new(libc::EINVAL)), - }; + let c_tempname = CString::new(os_fname.as_bytes()).map_err(|_| Error::new(libc::EINVAL))?; + let raw_tempname = c_tempname.into_raw(); - // SAFETY: Safe because `raw_fname` originates from CString::into_raw, meaning - // it is a pointer to a nul-terminated sequence of characters. - let fd = unsafe { libc::mkstemp(raw_fname) }; - if fd == -1 { - return errno_result(); - } + // SAFETY: Safe because `c_tempname` is a null-terminated string, as it originates from + // `CString::into_raw`. + let ret = unsafe { libc::mkstemp(raw_tempname) }; + + // SAFETY: `raw_tempname` originates from `CString::into_raw`. + let c_tempname = unsafe { CString::from_raw(raw_tempname) }; + + let fd = match ret { + -1 => return errno_result(), + _ => ret, + }; - // SAFETY: raw_fname originates from a call to CString::into_raw. The length - // of the string has not changed, as mkstemp returns a valid file name, and - // '\0' cannot be part of a valid filename. - let c_tempname = unsafe { CString::from_raw(raw_fname) }; let os_tempname = OsStr::from_bytes(c_tempname.as_bytes()); // SAFETY: Safe because we checked `fd != -1` above and we uniquely own the file diff --git a/vendor/vmm-sys-util/src/unix/tempdir.rs b/vendor/vmm-sys-util/src/unix/tempdir.rs index 101d35a..980fc88 100644 --- a/vendor/vmm-sys-util/src/unix/tempdir.rs +++ b/vendor/vmm-sys-util/src/unix/tempdir.rs @@ -16,6 +16,7 @@ use crate::errno::{errno_result, Error, Result}; /// Wrapper over a temporary directory. /// /// The directory will be maintained for the lifetime of the `TempDir` object. +#[derive(Debug)] pub struct TempDir { path: PathBuf, } diff --git a/vfio/Cargo.toml b/vfio/Cargo.toml index ca4a130..bede7fa 100644 --- a/vfio/Cargo.toml +++ b/vfio/Cargo.toml @@ -10,11 +10,11 @@ description = "Virtual function I/O" byteorder = "1.4.3" thiserror = "1.0" anyhow = "1.0" -kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] } -kvm-ioctls = "0.15.0" +kvm-bindings = { version = "0.10.0", features = ["fam-wrappers"] } +kvm-ioctls = "0.19.1" libc = "0.2" log = "0.4" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" vfio-bindings = "0.3" once_cell = "1.18.0" address_space = { path = "../address_space" } diff --git a/virtio/Cargo.toml b/virtio/Cargo.toml index d2890ed..91c89cd 100644 --- a/virtio/Cargo.toml +++ b/virtio/Cargo.toml @@ -13,7 +13,7 @@ anyhow = "1.0" libc = "0.2" log = "0.4" serde_json = "1.0" -vmm-sys-util = "0.11.1" +vmm-sys-util = "0.12.1" once_cell = "1.18.0" address_space = { path = "../address_space" } machine_manager = { path = "../machine_manager" } -- 2.43.0