What the review read and ran
An appendix to the milestone.
The crate
partsfoundry/device_tree_blob at 9ed5c2a970f2c4d81ee75d49cb0e94c1df4ad985, version 0.1.0,
the head of its main. Read: Cargo.toml, README.md, CHANGELOG.md, all of src/lib.rs
(1,429 lines, with the nine Kani harnesses read for what they prove) and the three test files,
tests/hostile.rs, tests/qemu_aarch64_virt.rs and tests/qemu_riscv64_virt.rs. The review
left the clone as it found it; every build wrote to a target directory outside it.
The commands
cargo buildpasses.cargo testpasses: 1 unit test, 46 inhostile.rs, 17 inqemu_aarch64_virt.rs, 10 inqemu_riscv64_virt.rsand 4 doctests.cargo +1.88 test, the declared minimum Rust version, passes the same tests.RUSTDOCFLAGS="-D warnings" cargo doc --no-depspasses.cargo clippy --all-targets -- -D warningspasses.cargo build --lib --targetwithx86_64-unknown-none,aarch64-unknown-none-softfloatandriscv64imac-unknown-none-elfpasses on each.- The crate declares no features, so there is no combination to build.
cargo package --list --allow-dirtylists the repository's hooks, workflows, templates,_typos.toml,deny.toml,rustfmt.toml,falsifications/anddocs/stranger-test.mdbeside the sources and fixtures, and leaves outfuzz/(P2-2).- A scratch binary took
tests/fixtures/qemu-riscv64-virt.dtband replaced the finalFDT_ENDtoken of its structure block with the value 10. On that blob,from_bytesreturned the tree,node_property(b"serial@10000000", b"compatible")returned the 9-byte value,boot_argumentsreturnedOk(None)andmemory_regionsreturnedErr(BadToken(10))(P0-1).fdt0.1.5'sFdt::newaccepted the same blob.
The benchmark
A scratch crate depending on the crate by path and on fdt = "=0.1.5" and
fdt-rs = { version = "=0.4.5", default-features = false }, built with cargo build --release
and run on a Linux x86_64 host, Intel Xeon Platinum 8160 at 2.10 GHz, 80 threads, rustc 1.100.0.
- Inputs: the crate's fixtures
qemu-riscv64-virt.dtb(5,235 bytes, 34 nodes) andqemu-aarch64-virt.dtb(7,566 bytes, 57 nodes), copied into au32-aligned buffer becausefdt-rsrequires one. All three crates read the same slice, and the program first checked that all three return the samecompatiblevalue and thatfdtandfdt-rscount the same nodes. - Parse:
DeviceTreeBlob::from_bytes,fdt::Fdt::newandfdt_rs::base::DevTree::new, each returning whether it succeeded. - Walk all nodes:
fdt'sall_nodes().count()andfdt-rs'snodes().count()over a parsed tree. The crate has no public walk, so its column isnode_property(b"no-such-node", b"x"), which visits every token and returnsOk(None). - Node by name and read
compatible: the node is/soc/serial@10000000on riscv64 and/pl011@9000000on aarch64. The crate callsnode_propertywith the last path component;fdtcallsfind_nodewith the whole path, thenproperty("compatible");fdt-rshas no path lookup, so it scansnodes()for the last component's name and then the node'sprops(). - The loop: start at 64 calls per pass and double until one pass lasts at least 50 ms, then run
seven passes at that count and report the lowest pass divided by the count. Each input and each
result passes through
std::hint::black_box.
The comparators read
Each .crate from crates.io at the version in the prior-art table, unpacked into its own empty
directory and read.
fdt0.1.5 (src/lib.rs,src/node.rs,src/standard_nodes.rs,src/parsing.rs):Fdt::newchecks the magic andtotalsizeonly.FdtErrorhasBadMagic,BadPtrandBufferTooSmall, withDisplayand nocore::error::Error. The walks areall_nodes,find_nodewith an alias fallback,find_compatible,find_phandle(reads onlyphandle),childrenandproperties.reg()returnsNoneabove two cells. The source holds 49unwrap,expectorpanic!sites outsidetests.rs. One feature,pretty-printing. MPL-2.0.dtoolkit0.5.0 (src/lib.rs,src/error.rs,src/fdt.rs,src/fdt/node.rs,src/standard/*.rs,src/validate.rs,Cargo.toml).Fdt::newandFdt::with_optionsrunvalidate, which walks the header, the reservation block and the structure block. It requirestotalsizeto equal the slice's length.FdtOptionshasstrict_name_lengthandmax_size.FdtParseErrorcarries an offset and a#[non_exhaustive]FdtErrorKind. ANodetrait haschildren,propertiesandchild(with the unit-address rule), besideFdt::find_node. Every public constructor has# Errorsand# Examples. Dependencieszerocopy,zerocopy-deriveandthiserror; featuresalloc,write,overlay,arrayvec07andheapless09.fdt-rs0.4.5 (src/lib.rs,src/error.rs,src/base/tree.rs,src/base/iters.rs,src/base/node.rs,src/index/tree.rs):unsafe fn newandunsafe fn from_raw_pointerwhose callers guarantee alignment and length;DevTreeErrorexhaustive withDisplay; fallible iteratorsnodes,props,compatible_nodes; an optional index built into a caller's buffer. Seven dependencies;stdon by default.device_tree1.1.0 (src/lib.rs): an owned tree ofVecandString,find(path).dtb-walker0.2.0-alpha.3 (src/lib.rs,src/walker.rs): a callback walk,walk(f)with aWalkOperationreturn.fdt-parser0.5.1 (src/lib.rs,src/base/fdt.rs,src/base/node/mod.rs,src/cache/fdt.rs):extern crate alloc,all_nodes,find_nodes,get_node_by_pathin its cache;FdtErrorthroughthiserrorwithBufferTooSmall { pos }.fdt-raw0.3.0 (src/fdt.rs):all_nodes,find_by_path.flat_device_tree3.1.1 (src/lib.rs,src/node.rs): thefdtinterface withfind_node,all_nodesandchildren.vm-fdt0.3.0: a writer, read for the neighbor role only.
The systems outside Rust
- libfdt from dtc v1.7.2,
libfdt/fdt_ro.c,libfdt/fdt.candlibfdt/libfdt.h.fdt_path_offset,fdt_subnode_offset_namelen,fdt_next_node,fdt_first_property_offsetandfdt_next_property_offsetuse an offset as the node handle;libfdt.hdeclaresfdt_check_full. libfdt is GPL-2.0-or-later or BSD-2-Clause; the review read it for its interface shape only.
What was not run
- Kani and mutation testing were not run; the harness count is from source.
- The review ran no comparator's tests; the benchmark built and called
fdtandfdt-rsonly. - The host has no
dtcand exposes no device tree, so the review built no blob from source and measured no board's blob.