diff --git a/Cargo.lock b/Cargo.lock index 5a575fc5e..208dc5fd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -88,11 +88,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] @@ -135,9 +136,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97" dependencies = [ "proc-macro2", "quote", @@ -282,9 +283,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.11.0" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" dependencies = [ "memchr", "serde", @@ -311,9 +312,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byteorder" @@ -323,9 +324,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cast" @@ -341,7 +342,7 @@ checksum = "eadd868a2ce9ca38de7eeafdcec9c7065ef89b42b32f0839278d55f35c54d1ff" dependencies = [ "clap", "heck 0.4.1", - "indexmap 2.6.0", + "indexmap 2.8.0", "log", "proc-macro2", "quote", @@ -386,16 +387,16 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -438,18 +439,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" dependencies = [ "anstream", "anstyle", @@ -459,9 +460,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" @@ -477,9 +478,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -544,9 +545,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -572,15 +573,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" [[package]] name = "crypto-common" @@ -647,15 +648,15 @@ dependencies = [ [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -663,14 +664,14 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" +checksum = "c3716d7a920fb4fac5d84e9d4bce8ceb321e9414b4409da61b07b75c1e3d0697" dependencies = [ "anstream", "anstyle", "env_filter", - "humantime", + "jiff", "log", ] @@ -685,25 +686,25 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flatbuffers" @@ -903,9 +904,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "globset" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5" dependencies = [ "aho-corasick", "bstr", @@ -927,9 +928,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "5017294ff4bb30944501348f6f8e42e6ad28f42c8bbef7a74029aff064a4e3c2" dependencies = [ "atomic-waker", "bytes", @@ -937,7 +938,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.6.0", + "indexmap 2.8.0", "slab", "tokio", "tokio-util", @@ -962,9 +963,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -980,15 +981,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "hermit-abi" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" [[package]] name = "hex" @@ -998,9 +993,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "1.1.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -1019,12 +1014,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", - "futures-util", + "futures-core", "http", "http-body", "pin-project-lite", @@ -1032,9 +1027,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "httpdate" @@ -1042,17 +1037,11 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -1190,7 +1179,7 @@ dependencies = [ "strum", "tempfile", "termcolor", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tracing", "tracing-chrome", @@ -1203,7 +1192,7 @@ dependencies = [ "uuid", "vmm-sys-util", "windows", - "windows-result 0.3.1", + "windows-result", "windows-sys 0.59.0", "windows-version", ] @@ -1231,6 +1220,7 @@ dependencies = [ "hyperlight-common", "hyperlight-guest", "log", + "spin", ] [[package]] @@ -1407,12 +1397,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -1423,13 +1413,13 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is-terminal" -version = "0.4.13" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ - "hermit-abi 0.4.0", + "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1456,11 +1446,44 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jiff" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d16e75759ee0aa64c57a56acbf43916987b20c77373cb7e808979e02b93c9f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "jobserver" @@ -1473,18 +1496,19 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "kvm-bindings" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501bc0717c6a9fc409f29047ebeb6040a4d304344698abb268c4c6a440e6a09a" +checksum = "3b13baf7bdfda2e10bcb109fcb099ef40cff82374eb6b7cdcf4695bdec4e522c" dependencies = [ "vmm-sys-util", ] @@ -1509,9 +1533,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libfuzzer-sys" @@ -1537,9 +1561,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -1568,9 +1592,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.20" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" dependencies = [ "cc", "libc", @@ -1580,15 +1604,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "lock_api" @@ -1656,20 +1680,19 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", @@ -1696,7 +1719,7 @@ dependencies = [ "libc", "num_enum", "vmm-sys-util", - "zerocopy 0.8.14", + "zerocopy 0.8.23", ] [[package]] @@ -1719,7 +1742,7 @@ checksum = "89abe853221fa6f14ad4066affb9abda241a03d65622887d5794e1422d0bd75a" dependencies = [ "libc", "mshv-bindings 0.3.2", - "thiserror 2.0.11", + "thiserror 2.0.12", "vmm-sys-util", ] @@ -1774,24 +1797,24 @@ dependencies = [ [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad" [[package]] name = "oorandom" -version = "11.1.4" +version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] name = "opentelemetry" @@ -1803,7 +1826,7 @@ dependencies = [ "futures-sink", "js-sys", "pin-project-lite", - "thiserror 2.0.11", + "thiserror 2.0.12", "tracing", ] @@ -1836,7 +1859,7 @@ dependencies = [ "opentelemetry_sdk", "prost", "reqwest", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tonic", "tracing", @@ -1875,7 +1898,7 @@ dependencies = [ "percent-encoding", "rand 0.8.5", "serde_json", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tokio-stream", "tracing", @@ -1940,18 +1963,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", @@ -1960,9 +1983,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1972,9 +1995,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plain" @@ -2010,20 +2033,35 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "portable-atomic" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.7.35", + "zerocopy 0.8.23", ] [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "f1ccf34da56fc294e7d4ccf69a85992b7dfb826b7cf57bac6a70bba3494cc08a" dependencies = [ "proc-macro2", "syn", @@ -2031,9 +2069,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -2089,9 +2127,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.3" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", "prost-derive", @@ -2099,12 +2137,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.3" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.14.0", "proc-macro2", "quote", "syn", @@ -2124,9 +2162,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -2149,8 +2187,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.0", - "zerocopy 0.8.14", + "rand_core 0.9.3", + "zerocopy 0.8.23", ] [[package]] @@ -2170,7 +2208,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -2184,12 +2222,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.14", ] [[package]] @@ -2223,9 +2260,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ "bitflags 2.9.0", ] @@ -2287,9 +2324,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.12" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" +checksum = "989e327e510263980e231de548a33e63d34962d29ae61b467389a1a09627a254" dependencies = [ "base64", "bytes", @@ -2381,22 +2418,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.41" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" dependencies = [ "bitflags 2.9.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "rusty-fork" @@ -2412,9 +2449,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -2427,9 +2464,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.5" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" +checksum = "ea091f6cac2595aa38993f04f4ee692ed43757035c36e67c180b6828356385b1" dependencies = [ "sdd", ] @@ -2462,9 +2499,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.4" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" +checksum = "584e070911c7017da6cb2eb0788d09f43d789029b5877d3e5ecc8acf86ceee21" [[package]] name = "seccompiler" @@ -2477,24 +2514,24 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -2503,9 +2540,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -2540,7 +2577,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.8.0", "itoa", "ryu", "serde", @@ -2640,15 +2677,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2699,9 +2736,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -2710,9 +2747,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -2730,9 +2767,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.17.1" +version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" +checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567" dependencies = [ "cfg-if", "fastrand", @@ -2762,11 +2799,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -2782,9 +2819,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -2823,9 +2860,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a" dependencies = [ "backtrace", "bytes", @@ -2852,9 +2889,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -2876,9 +2913,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -2897,11 +2934,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.8.0", "serde", "serde_spanned", "toml_datetime", @@ -3109,9 +3146,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unarray" @@ -3121,9 +3158,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unsafe-libyaml" @@ -3133,9 +3170,9 @@ checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -3172,9 +3209,9 @@ dependencies = [ [[package]] name = "valuable" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "vcpkg" @@ -3200,9 +3237,9 @@ dependencies = [ [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] @@ -3243,24 +3280,24 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -3269,21 +3306,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3291,9 +3329,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -3304,15 +3342,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -3386,8 +3427,8 @@ checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce" dependencies = [ "windows-implement", "windows-interface", - "windows-result 0.3.1", - "windows-strings 0.3.0", + "windows-result", + "windows-strings", "windows-targets 0.53.0", ] @@ -3421,22 +3462,13 @@ checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3" [[package]] name = "windows-registry" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" -dependencies = [ - "windows-result 0.2.0", - "windows-strings 0.1.0", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-result" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ - "windows-targets 0.52.6", + "windows-result", + "windows-strings", + "windows-targets 0.53.0", ] [[package]] @@ -3450,21 +3482,11 @@ dependencies = [ [[package]] name = "windows-strings" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" -dependencies = [ - "windows-result 0.2.0", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-strings" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b888f919960b42ea4e11c2f408fadb55f78a9f236d5eef084103c8ce52893491" +checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" dependencies = [ - "windows-targets 0.53.0", + "windows-link", ] [[package]] @@ -3690,9 +3712,9 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" dependencies = [ "memchr", ] @@ -3720,9 +3742,9 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -3732,9 +3754,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", @@ -3754,11 +3776,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.14" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" dependencies = [ - "zerocopy-derive 0.8.14", + "zerocopy-derive 0.8.23", ] [[package]] @@ -3774,9 +3796,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.14" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" dependencies = [ "proc-macro2", "quote", @@ -3785,18 +3807,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 3fa824ad8..a2c28b670 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,8 +25,8 @@ exclude = [ [workspace.package] version = "0.2.0" -edition = "2021" -rust-version = "1.80.0" +edition = "2024" +rust-version = "1.85.0" license = "Apache-2.0" homepage = "https://github.com/hyperlight-dev/hyperlight" repository = "https://github.com/hyperlight-dev/hyperlight" diff --git a/fuzz/fuzz_targets/host_call.rs b/fuzz/fuzz_targets/host_call.rs index 83696cb5e..db2240c37 100644 --- a/fuzz/fuzz_targets/host_call.rs +++ b/fuzz/fuzz_targets/host_call.rs @@ -19,8 +19,8 @@ limitations under the License. use std::sync::{Mutex, OnceLock}; use hyperlight_host::func::{ParameterValue, ReturnType}; -use hyperlight_host::sandbox::uninitialized::GuestBinary; use hyperlight_host::sandbox::SandboxConfiguration; +use hyperlight_host::sandbox::uninitialized::GuestBinary; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; use hyperlight_host::{HyperlightError, MultiUseSandbox, UninitializedSandbox}; diff --git a/fuzz/fuzz_targets/host_print.rs b/fuzz/fuzz_targets/host_print.rs index 576f56eec..11bd1d368 100644 --- a/fuzz/fuzz_targets/host_print.rs +++ b/fuzz/fuzz_targets/host_print.rs @@ -8,7 +8,7 @@ use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; use hyperlight_host::{MultiUseSandbox, UninitializedSandbox}; use hyperlight_testing::simple_guest_for_fuzzing_as_string; -use libfuzzer_sys::{fuzz_target, Corpus}; +use libfuzzer_sys::{Corpus, fuzz_target}; static SANDBOX: OnceLock> = OnceLock::new(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 3cf2110e7..552d6d698 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.81.0" \ No newline at end of file +channel = "1.85.0" \ No newline at end of file diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs index 987fb369a..9ce71187f 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs @@ -17,18 +17,18 @@ limitations under the License. use alloc::string::{String, ToString}; use alloc::vec::Vec; -use anyhow::{bail, Error, Result}; -use flatbuffers::{size_prefixed_root, WIPOffset}; +use anyhow::{Error, Result, bail}; +use flatbuffers::{WIPOffset, size_prefixed_root}; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::function_types::{ParameterValue, ReturnType}; use crate::flatbuffers::hyperlight::generated::{ - hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, hlfloatArgs, hlint, hlintArgs, hllong, - hllongArgs, hlstring, hlstringArgs, hluint, hluintArgs, hlulong, hlulongArgs, hlvecbytes, - hlvecbytesArgs, FunctionCall as FbFunctionCall, FunctionCallArgs as FbFunctionCallArgs, + FunctionCall as FbFunctionCall, FunctionCallArgs as FbFunctionCallArgs, FunctionCallType as FbFunctionCallType, Parameter, ParameterArgs, - ParameterValue as FbParameterValue, + ParameterValue as FbParameterValue, hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, + hlfloatArgs, hlint, hlintArgs, hllong, hllongArgs, hlstring, hlstringArgs, hluint, hluintArgs, + hlulong, hlulongArgs, hlvecbytes, hlvecbytesArgs, }; /// The type of function call. diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs index 42a26c81c..8ea05b49e 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs @@ -17,18 +17,18 @@ limitations under the License. use alloc::string::{String, ToString}; use alloc::vec::Vec; -use anyhow::{anyhow, bail, Error, Result}; +use anyhow::{Error, Result, anyhow, bail}; use flatbuffers::size_prefixed_root; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::flatbuffers::hyperlight::generated::{ - hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, hlfloatArgs, hlint, hlintArgs, hllong, - hllongArgs, hlsizeprefixedbuffer, hlsizeprefixedbufferArgs, hlstring, hlstringArgs, hluint, - hluintArgs, hlulong, hlulongArgs, hlvoid, hlvoidArgs, FunctionCallResult as FbFunctionCallResult, FunctionCallResultArgs as FbFunctionCallResultArgs, Parameter, ParameterType as FbParameterType, ParameterValue as FbParameterValue, - ReturnType as FbReturnType, ReturnValue as FbReturnValue, + ReturnType as FbReturnType, ReturnValue as FbReturnValue, hlbool, hlboolArgs, hldouble, + hldoubleArgs, hlfloat, hlfloatArgs, hlint, hlintArgs, hllong, hllongArgs, hlsizeprefixedbuffer, + hlsizeprefixedbufferArgs, hlstring, hlstringArgs, hluint, hluintArgs, hlulong, hlulongArgs, + hlvoid, hlvoidArgs, }; /// Supported parameter types with values for function calling. diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs index 00857af21..c5a73f8a0 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs @@ -22,7 +22,7 @@ use alloc::vec::Vec; use anyhow::{Error, Result}; use flatbuffers::size_prefixed_root; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::flatbuffers::hyperlight::generated::{ ErrorCode as FbErrorCode, GuestError as FbGuestError, GuestErrorArgs, diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs index 36092805c..c7c63d9aa 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs @@ -17,10 +17,10 @@ limitations under the License. use alloc::string::{String, ToString}; use alloc::vec::Vec; -use anyhow::{anyhow, Error, Result}; +use anyhow::{Error, Result, anyhow}; use flatbuffers::size_prefixed_root; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::guest_log_level::LogLevel; use crate::flatbuffers::hyperlight::generated::{ diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs index 14fa02b93..b6b44d260 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs @@ -14,11 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ -use anyhow::{bail, Error, Result}; +use anyhow::{Error, Result, bail}; use log::Level; use strum::EnumIter; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::flatbuffers::hyperlight::generated::LogLevel as FbLogLevel; diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs index 23c6976da..7893105dd 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs @@ -17,10 +17,10 @@ limitations under the License. use alloc::string::{String, ToString}; use alloc::vec::Vec; -use anyhow::{anyhow, Error, Result}; +use anyhow::{Error, Result, anyhow}; use flatbuffers::{FlatBufferBuilder, WIPOffset}; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::function_types::{ParameterType, ReturnType}; use crate::flatbuffers::hyperlight::generated::{ diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs index 33bd7d7c7..97d6bcec7 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs @@ -17,9 +17,9 @@ limitations under the License. use alloc::vec::Vec; use anyhow::{Error, Result}; -use flatbuffers::{size_prefixed_root, WIPOffset}; +use flatbuffers::{WIPOffset, size_prefixed_root}; #[cfg(feature = "tracing")] -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::host_function_definition::HostFunctionDefinition; use crate::flatbuffers::hyperlight::generated::{ @@ -57,11 +57,8 @@ impl HostFunctionDetails { /// Sort the host functions by name. #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] pub fn sort_host_functions_by_name(&mut self) { - match &mut self.host_functions { - Some(host_functions) => { - host_functions.sort_by(|a, b| a.function_name.cmp(&b.function_name)) - } - None => {} + if let Some(host_functions) = &mut self.host_functions { + host_functions.sort_by(|a, b| a.function_name.cmp(&b.function_name)) } } diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/util.rs b/src/hyperlight_common/src/flatbuffer_wrappers/util.rs index 184da6afe..3e4c65738 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/util.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/util.rs @@ -19,15 +19,15 @@ use alloc::vec::Vec; use flatbuffers::FlatBufferBuilder; use crate::flatbuffers::hyperlight::generated::{ - hlbool as Fbhlbool, hlboolArgs as FbhlboolArgs, hldouble as Fbhldouble, - hldoubleArgs as FbhldoubleArgs, hlfloat as Fbhlfloat, hlfloatArgs as FbhlfloatArgs, - hlint as Fbhlint, hlintArgs as FbhlintArgs, hllong as Fbhllong, hllongArgs as FbhllongArgs, - hlsizeprefixedbuffer as Fbhlsizeprefixedbuffer, + FunctionCallResult as FbFunctionCallResult, FunctionCallResultArgs as FbFunctionCallResultArgs, + ReturnValue as FbReturnValue, hlbool as Fbhlbool, hlboolArgs as FbhlboolArgs, + hldouble as Fbhldouble, hldoubleArgs as FbhldoubleArgs, hlfloat as Fbhlfloat, + hlfloatArgs as FbhlfloatArgs, hlint as Fbhlint, hlintArgs as FbhlintArgs, hllong as Fbhllong, + hllongArgs as FbhllongArgs, hlsizeprefixedbuffer as Fbhlsizeprefixedbuffer, hlsizeprefixedbufferArgs as FbhlsizeprefixedbufferArgs, hlstring as Fbhlstring, hlstringArgs as FbhlstringArgs, hluint as Fbhluint, hluintArgs as FbhluintArgs, hlulong as Fbhlulong, hlulongArgs as FbhlulongArgs, hlvoid as Fbhlvoid, - hlvoidArgs as FbhlvoidArgs, FunctionCallResult as FbFunctionCallResult, - FunctionCallResultArgs as FbFunctionCallResultArgs, ReturnValue as FbReturnValue, + hlvoidArgs as FbhlvoidArgs, }; /// Flatbuffer-encodes the given value @@ -46,7 +46,6 @@ pub trait FlatbufferSerializable { } /// Implementations for basic types below - impl FlatbufferSerializable for () { fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs { FbFunctionCallResultArgs { diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs index dba1ed055..7190bf56e 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/error_code_generated.rs @@ -124,8 +124,10 @@ impl<'a> flatbuffers::Follow<'a> for ErrorCode { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -133,7 +135,9 @@ impl flatbuffers::Push for ErrorCode { type Output = ErrorCode; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs index 17d31fa9f..b02b0cc3e 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for FunctionCall<'a> { type Inner = FunctionCall<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } @@ -290,14 +292,14 @@ pub fn size_prefixed_root_as_function_call_with_opts<'b, 'o>( /// # Safety /// Callers must trust the given bytes do indeed contain a valid `FunctionCall`. pub unsafe fn root_as_function_call_unchecked(buf: &[u8]) -> FunctionCall { - flatbuffers::root_unchecked::(buf) + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed FunctionCall and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `FunctionCall`. pub unsafe fn size_prefixed_root_as_function_call_unchecked(buf: &[u8]) -> FunctionCall { - flatbuffers::size_prefixed_root_unchecked::(buf) + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] pub fn finish_function_call_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs index 8ff674e6c..42393b377 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_result_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for FunctionCallResult<'a> { type Inner = FunctionCallResult<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } @@ -513,7 +515,7 @@ pub fn size_prefixed_root_as_function_call_result_with_opts<'b, 'o>( /// # Safety /// Callers must trust the given bytes do indeed contain a valid `FunctionCallResult`. pub unsafe fn root_as_function_call_result_unchecked(buf: &[u8]) -> FunctionCallResult { - flatbuffers::root_unchecked::(buf) + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed FunctionCallResult and returns it. @@ -522,7 +524,7 @@ pub unsafe fn root_as_function_call_result_unchecked(buf: &[u8]) -> FunctionCall pub unsafe fn size_prefixed_root_as_function_call_result_unchecked( buf: &[u8], ) -> FunctionCallResult { - flatbuffers::size_prefixed_root_unchecked::(buf) + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] pub fn finish_function_call_result_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs index 67edacdf9..abd07b6b8 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/function_call_type_generated.rs @@ -66,8 +66,10 @@ impl<'a> flatbuffers::Follow<'a> for FunctionCallType { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -75,7 +77,9 @@ impl flatbuffers::Push for FunctionCallType { type Output = FunctionCallType; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs index 57887a31b..7189b13c6 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_error_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for GuestError<'a> { type Inner = GuestError<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } @@ -192,14 +194,14 @@ pub fn size_prefixed_root_as_guest_error_with_opts<'b, 'o>( /// # Safety /// Callers must trust the given bytes do indeed contain a valid `GuestError`. pub unsafe fn root_as_guest_error_unchecked(buf: &[u8]) -> GuestError { - flatbuffers::root_unchecked::(buf) + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed GuestError and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `GuestError`. pub unsafe fn size_prefixed_root_as_guest_error_unchecked(buf: &[u8]) -> GuestError { - flatbuffers::size_prefixed_root_unchecked::(buf) + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] pub fn finish_guest_error_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs index 8deec7cad..b7938f11a 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/guest_log_data_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for GuestLogData<'a> { type Inner = GuestLogData<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } @@ -288,14 +290,14 @@ pub fn size_prefixed_root_as_guest_log_data_with_opts<'b, 'o>( /// # Safety /// Callers must trust the given bytes do indeed contain a valid `GuestLogData`. pub unsafe fn root_as_guest_log_data_unchecked(buf: &[u8]) -> GuestLogData { - flatbuffers::root_unchecked::(buf) + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed GuestLogData and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `GuestLogData`. pub unsafe fn size_prefixed_root_as_guest_log_data_unchecked(buf: &[u8]) -> GuestLogData { - flatbuffers::size_prefixed_root_unchecked::(buf) + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] pub fn finish_guest_log_data_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs index d2005e5a5..5c3b30536 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlbool_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlbool<'a> { type Inner = hlbool<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs index 5c71c2c9e..3527275a6 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hldouble_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hldouble<'a> { type Inner = hldouble<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs index 93673efe1..aa03ee930 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlfloat_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlfloat<'a> { type Inner = hlfloat<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs index a162f6eec..7ebb3c462 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlint_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlint<'a> { type Inner = hlint<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs index 690afaa26..a3815898a 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hllong_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hllong<'a> { type Inner = hllong<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs index e4aa6455c..c7e7006fd 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlsizeprefixedbuffer_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlsizeprefixedbuffer<'a> { type Inner = hlsizeprefixedbuffer<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs index ba8c2eb7f..827498527 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlstring_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlstring<'a> { type Inner = hlstring<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs index e10699658..d6388bc02 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hluint_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hluint<'a> { type Inner = hluint<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs index db83b936d..18a22f7ed 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlulong_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlulong<'a> { type Inner = hlulong<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs index e673cd425..18437cecb 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvecbytes_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlvecbytes<'a> { type Inner = hlvecbytes<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs index 76e0e9f97..6f169ffcc 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/hlvoid_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlvoid<'a> { type Inner = hlvoid<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs index 099ca44f2..0d71cc30b 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_definition_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for HostFunctionDefinition<'a> { type Inner = HostFunctionDefinition<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } @@ -257,7 +259,7 @@ pub fn size_prefixed_root_as_host_function_definition_with_opts<'b, 'o>( /// # Safety /// Callers must trust the given bytes do indeed contain a valid `HostFunctionDefinition`. pub unsafe fn root_as_host_function_definition_unchecked(buf: &[u8]) -> HostFunctionDefinition { - flatbuffers::root_unchecked::(buf) + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed HostFunctionDefinition and returns it. @@ -266,7 +268,7 @@ pub unsafe fn root_as_host_function_definition_unchecked(buf: &[u8]) -> HostFunc pub unsafe fn size_prefixed_root_as_host_function_definition_unchecked( buf: &[u8], ) -> HostFunctionDefinition { - flatbuffers::size_prefixed_root_unchecked::(buf) + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] pub fn finish_host_function_definition_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs index 71edd22b3..e457eb2ea 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/host_function_details_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for HostFunctionDetails<'a> { type Inner = HostFunctionDetails<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } @@ -187,7 +189,7 @@ pub fn size_prefixed_root_as_host_function_details_with_opts<'b, 'o>( /// # Safety /// Callers must trust the given bytes do indeed contain a valid `HostFunctionDetails`. pub unsafe fn root_as_host_function_details_unchecked(buf: &[u8]) -> HostFunctionDetails { - flatbuffers::root_unchecked::(buf) + unsafe { flatbuffers::root_unchecked::(buf) } } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed HostFunctionDetails and returns it. @@ -196,7 +198,7 @@ pub unsafe fn root_as_host_function_details_unchecked(buf: &[u8]) -> HostFunctio pub unsafe fn size_prefixed_root_as_host_function_details_unchecked( buf: &[u8], ) -> HostFunctionDetails { - flatbuffers::size_prefixed_root_unchecked::(buf) + unsafe { flatbuffers::size_prefixed_root_unchecked::(buf) } } #[inline] pub fn finish_host_function_details_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs index a47458489..0b8076f8a 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/log_level_generated.rs @@ -86,8 +86,10 @@ impl<'a> flatbuffers::Follow<'a> for LogLevel { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -95,7 +97,9 @@ impl flatbuffers::Push for LogLevel { type Output = LogLevel; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs index 41e80c4ac..44ee4df58 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_generated.rs @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for Parameter<'a> { type Inner = Parameter<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), + unsafe { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs index 5ef4b56e1..404a4fa5a 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_type_generated.rs @@ -94,8 +94,10 @@ impl<'a> flatbuffers::Follow<'a> for ParameterType { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -103,7 +105,9 @@ impl flatbuffers::Push for ParameterType { type Output = ParameterType; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs index 91d51b456..ea701a73d 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/parameter_value_generated.rs @@ -98,8 +98,10 @@ impl<'a> flatbuffers::Follow<'a> for ParameterValue { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -107,7 +109,9 @@ impl flatbuffers::Push for ParameterValue { type Output = ParameterValue; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs index 0610cdd55..a11af8c07 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_type_generated.rs @@ -98,8 +98,10 @@ impl<'a> flatbuffers::Follow<'a> for ReturnType { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -107,7 +109,9 @@ impl flatbuffers::Push for ReturnType { type Output = ReturnType; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs index 2c9f94872..f86a941bc 100644 --- a/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs +++ b/src/hyperlight_common/src/flatbuffers/hyperlight/generated/return_value_generated.rs @@ -102,8 +102,10 @@ impl<'a> flatbuffers::Follow<'a> for ReturnValue { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) + unsafe { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } } } @@ -111,7 +113,9 @@ impl flatbuffers::Push for ReturnValue { type Output = ReturnValue; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + unsafe { + flatbuffers::emplace_scalar::(dst, self.0); + } } } diff --git a/src/hyperlight_guest/build.rs b/src/hyperlight_guest/build.rs index 571cf70d8..fa36b4f43 100644 --- a/src/hyperlight_guest/build.rs +++ b/src/hyperlight_guest/build.rs @@ -104,10 +104,13 @@ fn cargo_main() { cfg.compiler("clang"); } - if cfg!(windows) { - env::set_var("AR_x86_64_unknown_none", "llvm-ar"); - } else { - env::set_var("AR_x86_64_pc_windows_msvc", "llvm-lib"); + // SAFETY: this build script is are single threaded + unsafe { + if cfg!(windows) { + env::set_var("AR_x86_64_unknown_none", "llvm-ar"); + } else { + env::set_var("AR_x86_64_pc_windows_msvc", "llvm-lib"); + } } cfg.compile("hyperlight_guest"); diff --git a/src/hyperlight_guest/src/chkstk.rs b/src/hyperlight_guest/src/chkstk.rs index e3e0dc4fc..706d5433e 100644 --- a/src/hyperlight_guest/src/chkstk.rs +++ b/src/hyperlight_guest/src/chkstk.rs @@ -22,7 +22,7 @@ use hyperlight_common::mem::RunMode; use crate::guest_error::{set_invalid_runmode_error, set_stack_allocate_error}; use crate::{MIN_STACK_ADDRESS, RUNNING_MODE}; -extern "win64" { +unsafe extern "win64" { fn __chkstk(); fn __chkstk_in_proc(); } diff --git a/src/hyperlight_guest/src/entrypoint.rs b/src/hyperlight_guest/src/entrypoint.rs index 2a6f6c562..15a8cc2bf 100644 --- a/src/hyperlight_guest/src/entrypoint.rs +++ b/src/hyperlight_guest/src/entrypoint.rs @@ -42,7 +42,7 @@ pub fn halt() { } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn abort() -> ! { abort_with_code(0) } @@ -57,17 +57,19 @@ pub fn abort_with_code(code: i32) -> ! { /// # Safety /// This function is unsafe because it dereferences a raw pointer. pub unsafe fn abort_with_code_and_message(code: i32, message_ptr: *const c_char) -> ! { - let peb_ptr = P_PEB.unwrap(); - copy_nonoverlapping( - message_ptr, - (*peb_ptr).guestPanicContextData.guestPanicContextDataBuffer as *mut c_char, - CStr::from_ptr(message_ptr).count_bytes() + 1, // +1 for null terminator - ); - outb(OutBAction::Abort as u16, code as u8); - unreachable!() + unsafe { + let peb_ptr = P_PEB.unwrap(); + copy_nonoverlapping( + message_ptr, + (*peb_ptr).guestPanicContextData.guestPanicContextDataBuffer as *mut c_char, + CStr::from_ptr(message_ptr).count_bytes() + 1, // +1 for null terminator + ); + outb(OutBAction::Abort as u16, code as u8); + unreachable!() + } } -extern "C" { +unsafe extern "C" { fn hyperlight_main(); fn srand(seed: u32); } @@ -76,7 +78,7 @@ static INIT: Once = Once::new(); // Note: entrypoint cannot currently have a stackframe >4KB, as that will invoke __chkstk on msvc // target without first having setup global `RUNNING_MODE` variable, which __chkstk relies on. -#[no_mangle] +#[unsafe(no_mangle)] pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_level: u64) { if peb_address == 0 { panic!("PEB address is null"); diff --git a/src/hyperlight_guest/src/gdt.rs b/src/hyperlight_guest/src/gdt.rs index 62f70e44c..34150ebd0 100644 --- a/src/hyperlight_guest/src/gdt.rs +++ b/src/hyperlight_guest/src/gdt.rs @@ -73,25 +73,27 @@ struct GdtPointer { /// Load the GDT pub unsafe fn load_gdt() { - let gdt_ptr = GdtPointer { - size: (core::mem::size_of::<[GdtEntry; 3]>() - 1) as u16, - base: addr_of!(GDT) as *const _ as u64, - }; + unsafe { + let gdt_ptr = GdtPointer { + size: (core::mem::size_of::<[GdtEntry; 3]>() - 1) as u16, + base: addr_of!(GDT) as *const _ as u64, + }; - asm!( - "lgdt [{0}]", - "mov ax, 0x10", // Load data segment registers - "mov ds, ax", - "mov es, ax", - "mov fs, ax", - "mov gs, ax", - "mov ss, ax", - "push 0x08", // Push CS (kernel code segment) - "lea rax, [2f + rip]", // Load the next instruction's address - "push rax", // Push address onto stack - "retfq", // Far return to update CS - "2:", // Label for continued execution - in(reg) &gdt_ptr, - options(nostack, preserves_flags) - ); + asm!( + "lgdt [{0}]", + "mov ax, 0x10", // Load data segment registers + "mov ds, ax", + "mov es, ax", + "mov fs, ax", + "mov gs, ax", + "mov ss, ax", + "push 0x08", // Push CS (kernel code segment) + "lea rax, [2f + rip]", // Load the next instruction's address + "push rax", // Push address onto stack + "retfq", // Far return to update CS + "2:", // Label for continued execution + in(reg) &gdt_ptr, + options(nostack, preserves_flags) + ); + } } diff --git a/src/hyperlight_guest/src/guest_error.rs b/src/hyperlight_guest/src/guest_error.rs index c255789e3..71e1cc21b 100644 --- a/src/hyperlight_guest/src/guest_error.rs +++ b/src/hyperlight_guest/src/guest_error.rs @@ -92,12 +92,12 @@ pub(crate) fn set_error_and_halt(error_code: ErrorCode, message: &str) { halt(); } -#[no_mangle] +#[unsafe(no_mangle)] pub(crate) extern "win64" fn set_stack_allocate_error() { outb(OutBAction::Abort as u16, ErrorCode::StackOverflow as u8); } -#[no_mangle] +#[unsafe(no_mangle)] pub(crate) extern "win64" fn set_invalid_runmode_error() { panic!("Invalid run mode in __chkstk"); } @@ -107,7 +107,7 @@ pub(crate) extern "win64" fn set_invalid_runmode_error() { /// # Safety /// TODO /// cbindgen:ignore -#[no_mangle] +#[unsafe(no_mangle)] #[allow(non_camel_case_types)] pub unsafe extern "C" fn setError(code: u64, message: *const c_char) { let error_code = ErrorCode::from(code); diff --git a/src/hyperlight_guest/src/guest_function_call.rs b/src/hyperlight_guest/src/guest_function_call.rs index 60d5548db..1f4dfb96c 100644 --- a/src/hyperlight_guest/src/guest_function_call.rs +++ b/src/hyperlight_guest/src/guest_function_call.rs @@ -21,12 +21,12 @@ use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, Functi use hyperlight_common::flatbuffer_wrappers::function_types::ParameterType; use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; +use crate::REGISTERED_GUEST_FUNCTIONS; use crate::entrypoint::halt; use crate::error::{HyperlightGuestError, Result}; use crate::guest_error::{reset_error, set_error}; use crate::shared_input_data::try_pop_shared_input_data_into; use crate::shared_output_data::push_shared_output_data; -use crate::REGISTERED_GUEST_FUNCTIONS; type GuestFunc = fn(&FunctionCall) -> Result>; @@ -43,8 +43,9 @@ pub(crate) fn call_guest_function(function_call: FunctionCall) -> Result } // Find the function definition for the function call. - if let Some(registered_function_definition) = - unsafe { REGISTERED_GUEST_FUNCTIONS.get(&function_call.function_name) } + if let Some(registered_function_definition) = REGISTERED_GUEST_FUNCTIONS + .lock() + .get(&function_call.function_name) { let function_call_parameter_types: Vec = function_call .parameters @@ -68,7 +69,7 @@ pub(crate) fn call_guest_function(function_call: FunctionCall) -> Result // TODO: ideally we would define a default implementation of this with weak linkage so the guest is not required // to implement the function but its seems that weak linkage is an unstable feature so for now its probably better // to not do that. - extern "Rust" { + unsafe extern "Rust" { fn guest_dispatch_function(function_call: FunctionCall) -> Result>; } @@ -78,7 +79,7 @@ pub(crate) fn call_guest_function(function_call: FunctionCall) -> Result // This function is marked as no_mangle/inline to prevent the compiler from inlining it , if its inlined the epilogue will not be called // and we will leak memory as the epilogue will not be called as halt() is not going to return. -#[no_mangle] +#[unsafe(no_mangle)] #[inline(never)] fn internal_dispatch_function() -> Result<()> { reset_error(); diff --git a/src/hyperlight_guest/src/guest_function_register.rs b/src/hyperlight_guest/src/guest_function_register.rs index 6acdc6f43..504a6229f 100644 --- a/src/hyperlight_guest/src/guest_function_register.rs +++ b/src/hyperlight_guest/src/guest_function_register.rs @@ -54,11 +54,7 @@ impl GuestFunctionRegister { } pub fn register_function(function_definition: GuestFunctionDefinition) { - unsafe { - // This is currently safe, because we are single threaded, but we - // should find a better way to do this, see issue #808 - #[allow(static_mut_refs)] - let gfd = &mut REGISTERED_GUEST_FUNCTIONS; - gfd.register(function_definition); - } + REGISTERED_GUEST_FUNCTIONS + .lock() + .register(function_definition); } diff --git a/src/hyperlight_guest/src/host_function_call.rs b/src/hyperlight_guest/src/host_function_call.rs index c5a496c8c..42e82d2b9 100644 --- a/src/hyperlight_guest/src/host_function_call.rs +++ b/src/hyperlight_guest/src/host_function_call.rs @@ -110,7 +110,7 @@ pub fn outb(port: u16, value: u8) { } } -extern "win64" { +unsafe extern "win64" { fn hloutb(port: u16, value: u8); } diff --git a/src/hyperlight_guest/src/idtr.rs b/src/hyperlight_guest/src/idtr.rs index 598e62ff0..93c764318 100644 --- a/src/hyperlight_guest/src/idtr.rs +++ b/src/hyperlight_guest/src/idtr.rs @@ -1,6 +1,6 @@ use core::ptr::addr_of; -use crate::idt::{init_idt, IdtEntry, IDT}; +use crate::idt::{IDT, IdtEntry, init_idt}; #[repr(C, packed)] pub struct Idtr { @@ -17,16 +17,23 @@ impl Idtr { } pub unsafe fn load(&self) { - core::arch::asm!("lidt [{}]", in(reg) self, options(readonly, nostack, preserves_flags)); + unsafe { + core::arch::asm!("lidt [{}]", in(reg) self, options(readonly, nostack, preserves_flags)); + } } } pub(crate) unsafe fn load_idt() { - init_idt(); + unsafe { + init_idt(); - let idt_size = 256 * size_of::(); - let expected_base = addr_of!(IDT) as *const _ as u64; + let idt_size = 256 * size_of::(); + let expected_base = addr_of!(IDT) as *const _ as u64; - IDTR.init(expected_base, idt_size as u16); - IDTR.load(); + #[allow(static_mut_refs)] // we are single threaded so should be OK for now + { + IDTR.init(expected_base, idt_size as u16); + IDTR.load(); + } + } } diff --git a/src/hyperlight_guest/src/interrupt_entry.rs b/src/hyperlight_guest/src/interrupt_entry.rs index 62ecd79f1..2c60419b7 100644 --- a/src/hyperlight_guest/src/interrupt_entry.rs +++ b/src/hyperlight_guest/src/interrupt_entry.rs @@ -21,7 +21,7 @@ use core::arch::global_asm; use crate::interrupt_handlers::hl_exception_handler; -extern "sysv64" { +unsafe extern "sysv64" { // Exception handlers pub(crate) fn _do_excp0(); pub(crate) fn _do_excp1(); @@ -164,7 +164,7 @@ macro_rules! generate_exceptions { // jmp _do_excp_common // ``` macro_rules! generate_excp { - ($num:expr) => { + ($num:expr_2021) => { concat!( ".global _do_excp", stringify!($num), @@ -185,7 +185,7 @@ macro_rules! generate_excp { " jmp _do_excp_common\n" ) }; - ($num:expr, pusherrcode) => { + ($num:expr_2021, pusherrcode) => { concat!( ".global _do_excp", stringify!($num), @@ -210,7 +210,7 @@ macro_rules! generate_excp { " jmp _do_excp_common\n" ) }; - ($num:expr, pagefault) => { + ($num:expr_2021, pagefault) => { concat!( ".global _do_excp", stringify!($num), diff --git a/src/hyperlight_guest/src/interrupt_handlers.rs b/src/hyperlight_guest/src/interrupt_handlers.rs index 3b9e401ac..f3daff768 100644 --- a/src/hyperlight_guest/src/interrupt_handlers.rs +++ b/src/hyperlight_guest/src/interrupt_handlers.rs @@ -15,7 +15,7 @@ limitations under the License. */ /// Exception handler -#[no_mangle] +#[unsafe(no_mangle)] pub extern "sysv64" fn hl_exception_handler( stack_pointer: u64, exception_number: u64, diff --git a/src/hyperlight_guest/src/lib.rs b/src/hyperlight_guest/src/lib.rs index 181274c1e..daf6dc928 100644 --- a/src/hyperlight_guest/src/lib.rs +++ b/src/hyperlight_guest/src/lib.rs @@ -19,13 +19,14 @@ limitations under the License. use alloc::string::ToString; use core::hint::unreachable_unchecked; use core::ptr::copy_nonoverlapping; +use spin::Mutex; use buddy_system_allocator::LockedHeap; use guest_function_register::GuestFunctionRegister; use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; use hyperlight_common::mem::{HyperlightPEB, RunMode}; -use crate::host_function_call::{outb, OutBAction}; +use crate::host_function_call::{OutBAction, outb}; extern crate alloc; // Modules @@ -59,10 +60,10 @@ pub mod logging; // Unresolved symbols ///cbindgen:ignore -#[no_mangle] +#[unsafe(no_mangle)] pub(crate) extern "C" fn __CxxFrameHandler3() {} ///cbindgen:ignore -#[no_mangle] +#[unsafe(no_mangle)] pub(crate) static _fltused: i32 = 0; // It looks like rust-analyzer doesn't correctly manage no_std crates, @@ -91,7 +92,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! { pub(crate) static HEAP_ALLOCATOR: LockedHeap<32> = LockedHeap::<32>::empty(); ///cbindgen:ignore -#[no_mangle] +#[unsafe(no_mangle)] pub(crate) static mut __security_cookie: u64 = 0; pub(crate) static mut P_PEB: Option<*mut HyperlightPEB> = None; @@ -104,5 +105,5 @@ pub(crate) static mut OUTB_PTR_WITH_CONTEXT: Option< > = None; pub static mut RUNNING_MODE: RunMode = RunMode::None; -pub(crate) static mut REGISTERED_GUEST_FUNCTIONS: GuestFunctionRegister = - GuestFunctionRegister::new(); +pub(crate) static REGISTERED_GUEST_FUNCTIONS: Mutex = + Mutex::new(GuestFunctionRegister::new()); diff --git a/src/hyperlight_guest/src/memory.rs b/src/hyperlight_guest/src/memory.rs index 70390cbdc..6f78b0990 100644 --- a/src/hyperlight_guest/src/memory.rs +++ b/src/hyperlight_guest/src/memory.rs @@ -81,9 +81,9 @@ unsafe fn alloc_helper(size: usize, zero: bool) -> *mut c_void { /// /// # Safety /// The returned pointer must be freed with `memory::free` when it is no longer needed, otherwise memory will leak. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn malloc(size: usize) -> *mut c_void { - alloc_helper(size, false) + unsafe { alloc_helper(size, false) } } /// Allocates a block of memory for an array of `nmemb` elements, each of `size` bytes. @@ -91,20 +91,22 @@ pub unsafe extern "C" fn malloc(size: usize) -> *mut c_void { /// /// # Safety /// The returned pointer must be freed with `memory::free` when it is no longer needed, otherwise memory will leak. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn calloc(nmemb: usize, size: usize) -> *mut c_void { - let total_size = nmemb - .checked_mul(size) - .expect("nmemb * size should not overflow in calloc"); + unsafe { + let total_size = nmemb + .checked_mul(size) + .expect("nmemb * size should not overflow in calloc"); - alloc_helper(total_size, true) + alloc_helper(total_size, true) + } } /// Frees the memory block pointed to by `ptr`. /// /// # Safety /// `ptr` must be a pointer to a memory block previously allocated by `memory::malloc`, `memory::calloc`, or `memory::realloc`. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn free(ptr: *mut c_void) { if !ptr.is_null() { unsafe { @@ -120,20 +122,20 @@ pub unsafe extern "C" fn free(ptr: *mut c_void) { /// /// # Safety /// `ptr` must be a pointer to a memory block previously allocated by `memory::malloc`, `memory::calloc`, or `memory::realloc`. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn realloc(ptr: *mut c_void, size: usize) -> *mut c_void { - if ptr.is_null() { - // If the pointer is null, treat as a malloc - return malloc(size); - } + unsafe { + if ptr.is_null() { + // If the pointer is null, treat as a malloc + return malloc(size); + } - if size == 0 { - // If the size is 0, treat as a free and return null - free(ptr); - return ptr::null_mut(); - } + if size == 0 { + // If the size is 0, treat as a free and return null + free(ptr); + return ptr::null_mut(); + } - unsafe { let total_new_size = size .checked_add(size_of::()) .expect("data and layout size should not overflow in realloc"); diff --git a/src/hyperlight_guest/src/print.rs b/src/hyperlight_guest/src/print.rs index b7dd8404f..200c5caff 100644 --- a/src/hyperlight_guest/src/print.rs +++ b/src/hyperlight_guest/src/print.rs @@ -31,38 +31,40 @@ static mut MESSAGE_BUFFER: Vec = Vec::new(); /// /// # Safety /// This function is not thread safe -#[no_mangle] +#[unsafe(no_mangle)] #[allow(static_mut_refs)] pub unsafe extern "C" fn _putchar(c: c_char) { - let char = c as u8; + unsafe { + let char = c as u8; - // Extend buffer capacity if it's empty (like `with_capacity` in lazy_static). - // TODO: replace above Vec::new() with Vec::with_capacity once it's stable in const contexts. - if MESSAGE_BUFFER.capacity() == 0 { - MESSAGE_BUFFER.reserve(BUFFER_SIZE); - } + // Extend buffer capacity if it's empty (like `with_capacity` in lazy_static). + // TODO: replace above Vec::new() with Vec::with_capacity once it's stable in const contexts. + if MESSAGE_BUFFER.capacity() == 0 { + MESSAGE_BUFFER.reserve(BUFFER_SIZE); + } - MESSAGE_BUFFER.push(char); + MESSAGE_BUFFER.push(char); - if MESSAGE_BUFFER.len() == BUFFER_SIZE || char == b'\0' { - let str = if char == b'\0' { - CStr::from_bytes_until_nul(&MESSAGE_BUFFER) - .expect("No null byte in buffer") - .to_string_lossy() - .into_owned() - } else { - String::from_utf8(mem::take(&mut MESSAGE_BUFFER)) - .expect("Failed to convert buffer to string") - }; + if MESSAGE_BUFFER.len() == BUFFER_SIZE || char == b'\0' { + let str = if char == b'\0' { + CStr::from_bytes_until_nul(&MESSAGE_BUFFER) + .expect("No null byte in buffer") + .to_string_lossy() + .into_owned() + } else { + String::from_utf8(mem::take(&mut MESSAGE_BUFFER)) + .expect("Failed to convert buffer to string") + }; - call_host_function( - "HostPrint", - Some(Vec::from(&[ParameterValue::String(str)])), - ReturnType::Void, - ) - .expect("Failed to call HostPrint"); + call_host_function( + "HostPrint", + Some(Vec::from(&[ParameterValue::String(str)])), + ReturnType::Void, + ) + .expect("Failed to call HostPrint"); - // Clear the buffer after sending - MESSAGE_BUFFER.clear(); + // Clear the buffer after sending + MESSAGE_BUFFER.clear(); + } } } diff --git a/src/hyperlight_guest/src/security_check.rs b/src/hyperlight_guest/src/security_check.rs index b21a94af8..3aa0a59a2 100644 --- a/src/hyperlight_guest/src/security_check.rs +++ b/src/hyperlight_guest/src/security_check.rs @@ -23,7 +23,7 @@ use crate::__security_cookie; use crate::guest_error::set_error_and_halt; ///cbindgen:ignore -#[no_mangle] +#[unsafe(no_mangle)] pub(crate) extern "C" fn __security_check_cookie(cookie: u64) { unsafe { if __security_cookie != cookie { diff --git a/src/hyperlight_guest/src/setjmp.rs b/src/hyperlight_guest/src/setjmp.rs index 2d9139205..34a658c00 100644 --- a/src/hyperlight_guest/src/setjmp.rs +++ b/src/hyperlight_guest/src/setjmp.rs @@ -96,15 +96,15 @@ ok: /* Adapt the calling convention of the above to the native "C" calling * convention. */ -extern "win64" { +unsafe extern "win64" { fn win64_setjmp(x: u64) -> u64; fn win64_longjmp(x: u64, y: u64) -> !; } -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn setjmp(x: u64) -> u64 { unsafe { win64_setjmp(x) } } -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn longjmp(x: u64, y: u64) -> ! { unsafe { win64_longjmp(x, y) } } diff --git a/src/hyperlight_guest_capi/Cargo.toml b/src/hyperlight_guest_capi/Cargo.toml index 843f2577e..cab61a50e 100644 --- a/src/hyperlight_guest_capi/Cargo.toml +++ b/src/hyperlight_guest_capi/Cargo.toml @@ -15,6 +15,7 @@ workspace = true hyperlight-guest = { workspace = true, default-features = true } hyperlight-common = { workspace = true, default-features = false } log = { version = "0.4", default-features = false } +spin = "0.9.8" [build-dependencies] cbindgen = "0.28.0" diff --git a/src/hyperlight_guest_capi/src/dispatch.rs b/src/hyperlight_guest_capi/src/dispatch.rs index eacd7b374..bd831bc06 100644 --- a/src/hyperlight_guest_capi/src/dispatch.rs +++ b/src/hyperlight_guest_capi/src/dispatch.rs @@ -1,7 +1,7 @@ use alloc::boxed::Box; use alloc::slice; use alloc::vec::Vec; -use core::ffi::{c_char, CStr}; +use core::ffi::{CStr, c_char}; use core::mem; use hyperlight_common::flatbuffer_wrappers::function_call::FunctionCall; @@ -11,22 +11,25 @@ use hyperlight_guest::error::{HyperlightGuestError, Result}; use hyperlight_guest::guest_function_definition::GuestFunctionDefinition; use hyperlight_guest::guest_function_register::GuestFunctionRegister; use hyperlight_guest::host_function_call::call_host_function; +use spin::Mutex; use crate::types::{FfiFunctionCall, FfiVec}; -static mut REGISTERED_C_GUEST_FUNCTIONS: GuestFunctionRegister = GuestFunctionRegister::new(); +static REGISTERED_C_GUEST_FUNCTIONS: Mutex = + Mutex::new(GuestFunctionRegister::new()); type CGuestFunc = extern "C" fn(&FfiFunctionCall) -> Box; -extern "C" { +unsafe extern "C" { // NOTE *mut FfiVec must be a Box. This will be the case as long as the guest // returns a FfiVec that they created using the c-api hl_flatbuffer_result_from_* functions. fn c_guest_dispatch_function(function_call: &FfiFunctionCall) -> *mut FfiVec; } -#[no_mangle] +#[unsafe(no_mangle)] pub fn guest_dispatch_function(function_call: FunctionCall) -> Result> { - if let Some(registered_func) = - unsafe { REGISTERED_C_GUEST_FUNCTIONS.get(&function_call.function_name) } + if let Some(registered_func) = REGISTERED_C_GUEST_FUNCTIONS + .lock() + .get(&function_call.function_name) { let function_call_parameter_types: Vec = function_call .parameters @@ -64,7 +67,7 @@ pub fn guest_dispatch_function(function_call: FunctionCall) -> Result> { } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_register_function_definition( function_name: *const c_char, func_ptr: CGuestFunc, @@ -79,12 +82,11 @@ pub extern "C" fn hl_register_function_definition( let func_def = GuestFunctionDefinition::new(func_name, func_params, return_type, func_ptr as usize); - #[allow(static_mut_refs)] - unsafe { &mut REGISTERED_C_GUEST_FUNCTIONS }.register(func_def); + REGISTERED_C_GUEST_FUNCTIONS.lock().register(func_def); } /// The caller is responsible for freeing the memory associated with given `FfiFunctionCall`. -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_call_host_function(function_call: &FfiFunctionCall) { let parameters = unsafe { function_call.copy_parameters() }; let func_name = unsafe { function_call.copy_function_name() }; diff --git a/src/hyperlight_guest_capi/src/error.rs b/src/hyperlight_guest_capi/src/error.rs index 948abae3a..8f64d241f 100644 --- a/src/hyperlight_guest_capi/src/error.rs +++ b/src/hyperlight_guest_capi/src/error.rs @@ -3,19 +3,19 @@ use core::ffi::c_char; use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; use hyperlight_guest::guest_error::setError; -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_set_error(err: ErrorCode, message: *const c_char) { unsafe { setError(err.into(), message); } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_abort_with_code(err: i32) { hyperlight_guest::entrypoint::abort_with_code(err); } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_abort_with_code_and_message(err: i32, message: *const c_char) { unsafe { hyperlight_guest::entrypoint::abort_with_code_and_message(err, message) }; } diff --git a/src/hyperlight_guest_capi/src/flatbuffer.rs b/src/hyperlight_guest_capi/src/flatbuffer.rs index 33cfdbb4b..825772f94 100644 --- a/src/hyperlight_guest_capi/src/flatbuffer.rs +++ b/src/hyperlight_guest_capi/src/flatbuffer.rs @@ -1,5 +1,5 @@ use alloc::boxed::Box; -use core::ffi::{c_char, CStr}; +use core::ffi::{CStr, c_char}; use hyperlight_common::flatbuffer_wrappers::util::get_flatbuffer_result; use hyperlight_guest::host_function_call::get_host_return_value; @@ -10,56 +10,56 @@ use crate::types::FfiVec; // is to match the names of the variants in hl_ReturnType, // which is used in the C macros in macro.h -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_Int(value: i32) -> Box { let vec = get_flatbuffer_result(value); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_UInt(value: u32) -> Box { let vec = get_flatbuffer_result(value); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_Long(value: i64) -> Box { let vec = get_flatbuffer_result(value); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_ULong(value: u64) -> Box { let vec = get_flatbuffer_result(value); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_Float(value: f32) -> Box { let vec = get_flatbuffer_result(value); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_Double(value: f64) -> Box { let vec = get_flatbuffer_result(value); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_Void() -> Box { let vec = get_flatbuffer_result(()); Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_String(value: *const c_char) -> Box { let str = unsafe { CStr::from_ptr(value) }; let vec = get_flatbuffer_result(str.to_string_lossy().as_ref()); @@ -67,7 +67,7 @@ pub extern "C" fn hl_flatbuffer_result_from_String(value: *const c_char) -> Box< Box::new(unsafe { FfiVec::from_vec(vec) }) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_flatbuffer_result_from_Bytes(data: *const u8, len: usize) -> Box { let slice = unsafe { core::slice::from_raw_parts(data, len) }; @@ -78,23 +78,23 @@ pub extern "C" fn hl_flatbuffer_result_from_Bytes(data: *const u8, len: usize) - //--- Functions for getting values returned by host functions calls -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_get_host_return_value_as_Int() -> i32 { get_host_return_value().expect("Unable to get host return value as int") } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_get_host_return_value_as_UInt() -> u32 { get_host_return_value().expect("Unable to get host return value as uint") } // the same for long, ulong -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_get_host_return_value_as_Long() -> i64 { get_host_return_value().expect("Unable to get host return value as long") } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_get_host_return_value_as_ULong() -> u64 { get_host_return_value().expect("Unable to get host return value as ulong") } diff --git a/src/hyperlight_guest_capi/src/logging.rs b/src/hyperlight_guest_capi/src/logging.rs index 8bba45e32..2846fa3fe 100644 --- a/src/hyperlight_guest_capi/src/logging.rs +++ b/src/hyperlight_guest_capi/src/logging.rs @@ -1,6 +1,6 @@ use core::ffi::c_char; -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hl_log( level: log::Level, message: *const c_char, diff --git a/src/hyperlight_guest_capi/src/types/function_call.rs b/src/hyperlight_guest_capi/src/types/function_call.rs index 391ebef82..7147d13d5 100644 --- a/src/hyperlight_guest_capi/src/types/function_call.rs +++ b/src/hyperlight_guest_capi/src/types/function_call.rs @@ -3,7 +3,7 @@ use alloc::ffi::CString; use alloc::slice; use alloc::string::String; use alloc::vec::Vec; -use core::ffi::{c_char, CStr}; +use core::ffi::{CStr, c_char}; use hyperlight_common::flatbuffer_wrappers::function_call::FunctionCall; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; diff --git a/src/hyperlight_guest_capi/src/types/parameter.rs b/src/hyperlight_guest_capi/src/types/parameter.rs index 8a7d18a30..08515c752 100644 --- a/src/hyperlight_guest_capi/src/types/parameter.rs +++ b/src/hyperlight_guest_capi/src/types/parameter.rs @@ -1,5 +1,5 @@ use alloc::ffi::CString; -use core::ffi::{c_char, CStr}; +use core::ffi::{CStr, c_char}; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterType, ParameterValue}; use hyperlight_guest::error::Result; diff --git a/src/hyperlight_host/benches/benchmarks.rs b/src/hyperlight_host/benches/benchmarks.rs index db71d8a95..84372d6ee 100644 --- a/src/hyperlight_host/benches/benchmarks.rs +++ b/src/hyperlight_host/benches/benchmarks.rs @@ -16,13 +16,13 @@ limitations under the License. use std::sync::{Arc, Mutex}; -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; +use hyperlight_host::GuestBinary; use hyperlight_host::func::HostFunction2; use hyperlight_host::sandbox::{MultiUseSandbox, UninitializedSandbox}; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; -use hyperlight_host::GuestBinary; use hyperlight_testing::simple_guest_as_string; fn create_uninit_sandbox() -> UninitializedSandbox { diff --git a/src/hyperlight_host/examples/func_ctx/main.rs b/src/hyperlight_host/examples/func_ctx/main.rs index 2967616e4..4738de77e 100644 --- a/src/hyperlight_host/examples/func_ctx/main.rs +++ b/src/hyperlight_host/examples/func_ctx/main.rs @@ -19,7 +19,7 @@ use hyperlight_host::func::call_ctx::MultiUseGuestCallContext; use hyperlight_host::sandbox::{MultiUseSandbox, UninitializedSandbox}; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; -use hyperlight_host::{new_error, GuestBinary, Result}; +use hyperlight_host::{GuestBinary, Result, new_error}; use hyperlight_testing::simple_guest_as_string; fn main() { diff --git a/src/hyperlight_host/examples/guest-debugging/main.rs b/src/hyperlight_host/examples/guest-debugging/main.rs index da3010b9c..925312201 100644 --- a/src/hyperlight_host/examples/guest-debugging/main.rs +++ b/src/hyperlight_host/examples/guest-debugging/main.rs @@ -19,9 +19,9 @@ use std::thread; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; use hyperlight_host::func::HostFunction0; +use hyperlight_host::sandbox::SandboxConfiguration; #[cfg(gdb)] use hyperlight_host::sandbox::config::DebugInfo; -use hyperlight_host::sandbox::SandboxConfiguration; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; use hyperlight_host::{MultiUseSandbox, UninitializedSandbox}; @@ -89,7 +89,7 @@ mod tests { use std::process::{Command, Stdio}; use std::time::Duration; - use hyperlight_host::{new_error, Result}; + use hyperlight_host::{Result, new_error}; use io::{BufReader, BufWriter, Read, Write}; use super::*; diff --git a/src/hyperlight_host/examples/metrics/main.rs b/src/hyperlight_host/examples/metrics/main.rs index 2028c21f7..d97dfe2ec 100644 --- a/src/hyperlight_host/examples/metrics/main.rs +++ b/src/hyperlight_host/examples/metrics/main.rs @@ -16,13 +16,13 @@ limitations under the License. extern crate hyperlight_host; use std::sync::{Arc, Mutex}; -use std::thread::{spawn, JoinHandle}; +use std::thread::{JoinHandle, spawn}; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; use hyperlight_host::sandbox::uninitialized::UninitializedSandbox; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; -use hyperlight_host::{set_metrics_registry, GuestBinary, MultiUseSandbox, Result}; +use hyperlight_host::{GuestBinary, MultiUseSandbox, Result, set_metrics_registry}; use hyperlight_testing::simple_guest_as_string; use lazy_static::lazy_static; use prometheus::Registry; diff --git a/src/hyperlight_host/examples/otlp_tracing/main.rs b/src/hyperlight_host/examples/otlp_tracing/main.rs index ccddc3626..4864ac99d 100644 --- a/src/hyperlight_host/examples/otlp_tracing/main.rs +++ b/src/hyperlight_host/examples/otlp_tracing/main.rs @@ -18,7 +18,7 @@ use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, Ret //use opentelemetry_sdk::resource::ResourceBuilder; use opentelemetry_sdk::trace::SdkTracerProvider; use rand::Rng; -use tracing::{span, Level}; +use tracing::{Level, span}; use tracing_opentelemetry::OpenTelemetryLayer; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; @@ -26,7 +26,7 @@ extern crate hyperlight_host; use std::error::Error; use std::io::stdin; use std::sync::{Arc, Mutex}; -use std::thread::{self, spawn, JoinHandle}; +use std::thread::{self, JoinHandle, spawn}; use hyperlight_host::sandbox::uninitialized::UninitializedSandbox; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; @@ -34,7 +34,7 @@ use hyperlight_host::sandbox_state::transition::Noop; use hyperlight_host::{GuestBinary, MultiUseSandbox, Result as HyperlightResult}; use hyperlight_testing::simple_guest_as_string; use opentelemetry::trace::TracerProvider; -use opentelemetry::{global, KeyValue}; +use opentelemetry::{KeyValue, global}; use opentelemetry_otlp::{SpanExporter, WithExportConfig}; //use opentelemetry_sdk::runtime::Tokio; use opentelemetry_sdk::Resource; diff --git a/src/hyperlight_host/examples/tracing/main.rs b/src/hyperlight_host/examples/tracing/main.rs index 1778a3d47..f8dbb5dcd 100644 --- a/src/hyperlight_host/examples/tracing/main.rs +++ b/src/hyperlight_host/examples/tracing/main.rs @@ -15,10 +15,10 @@ limitations under the License. */ use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; -use tracing::{span, Level}; +use tracing::{Level, span}; extern crate hyperlight_host; use std::sync::{Arc, Mutex}; -use std::thread::{spawn, JoinHandle}; +use std::thread::{JoinHandle, spawn}; use hyperlight_host::sandbox::uninitialized::UninitializedSandbox; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; diff --git a/src/hyperlight_host/src/error.rs b/src/hyperlight_host/src/error.rs index 76fdb8d05..51f2d980e 100644 --- a/src/hyperlight_host/src/error.rs +++ b/src/hyperlight_host/src/error.rs @@ -361,7 +361,7 @@ macro_rules! new_error { }; $crate::HyperlightError::Error(__err_msg) }}; - ($fmtstr:expr, $($arg:tt)*) => {{ + ($fmtstr:expr_2021, $($arg:tt)*) => {{ let __err_msg = std::format!($fmtstr, $($arg)*); $crate::error::HyperlightError::Error(__err_msg) }}; diff --git a/src/hyperlight_host/src/func/call_ctx.rs b/src/hyperlight_host/src/func/call_ctx.rs index bc48e249c..da0907ce0 100644 --- a/src/hyperlight_host/src/func/call_ctx.rs +++ b/src/hyperlight_host/src/func/call_ctx.rs @@ -17,7 +17,7 @@ limitations under the License. use hyperlight_common::flatbuffer_wrappers::function_types::{ ParameterValue, ReturnType, ReturnValue, }; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::guest_dispatch::call_function_on_guest; use crate::{MultiUseSandbox, Result}; diff --git a/src/hyperlight_host/src/func/guest_dispatch.rs b/src/hyperlight_host/src/func/guest_dispatch.rs index 4462a8a66..bedd5481d 100644 --- a/src/hyperlight_host/src/func/guest_dispatch.rs +++ b/src/hyperlight_host/src/func/guest_dispatch.rs @@ -18,12 +18,12 @@ use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, Functi use hyperlight_common::flatbuffer_wrappers::function_types::{ ParameterValue, ReturnType, ReturnValue, }; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::guest_err::check_for_guest_error; +use crate::HyperlightError::GuestExecutionHungOnHostFunctionCall; use crate::hypervisor::hypervisor_handler::HypervisorHandlerAction; use crate::sandbox::WrapperGetter; -use crate::HyperlightError::GuestExecutionHungOnHostFunctionCall; use crate::{HyperlightError, Result}; /// Call a guest function by name, using the given `wrapper_getter`. @@ -117,7 +117,7 @@ mod tests { use crate::sandbox::uninitialized::GuestBinary; use crate::sandbox_state::sandbox::EvolvableSandbox; use crate::sandbox_state::transition::Noop; - use crate::{new_error, HyperlightError, MultiUseSandbox, Result, UninitializedSandbox}; + use crate::{HyperlightError, MultiUseSandbox, Result, UninitializedSandbox, new_error}; // simple function fn test_function0(_: MultiUseGuestCallContext) -> Result { diff --git a/src/hyperlight_host/src/func/guest_err.rs b/src/hyperlight_host/src/func/guest_err.rs index 58baa8c56..082a445ae 100644 --- a/src/hyperlight_host/src/func/guest_err.rs +++ b/src/hyperlight_host/src/func/guest_err.rs @@ -22,7 +22,7 @@ use crate::error::HyperlightError::{GuestError, OutBHandlingError, StackOverflow use crate::mem::shared_mem::HostSharedMemory; use crate::sandbox::mem_mgr::MemMgrWrapper; use crate::sandbox::metrics::SandboxMetric::GuestErrorCount; -use crate::{int_counter_vec_inc, log_then_return, Result}; +use crate::{Result, int_counter_vec_inc, log_then_return}; /// Check for a guest error and return an `Err` if one was found, /// and `Ok` if one was not found. pub(crate) fn check_for_guest_error(mgr: &MemMgrWrapper) -> Result<()> { diff --git a/src/hyperlight_host/src/func/host_functions.rs b/src/hyperlight_host/src/func/host_functions.rs index ce30d9c45..f6194b6cc 100644 --- a/src/hyperlight_host/src/func/host_functions.rs +++ b/src/hyperlight_host/src/func/host_functions.rs @@ -20,12 +20,12 @@ use std::sync::{Arc, Mutex}; use hyperlight_common::flatbuffer_wrappers::function_types::ParameterValue; use hyperlight_common::flatbuffer_wrappers::host_function_definition::HostFunctionDefinition; use paste::paste; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::{HyperlightFunction, SupportedParameterType, SupportedReturnType}; -use crate::sandbox::{ExtraAllowedSyscall, UninitializedSandbox}; use crate::HyperlightError::UnexpectedNoOfArguments; -use crate::{log_then_return, new_error, Result}; +use crate::sandbox::{ExtraAllowedSyscall, UninitializedSandbox}; +use crate::{Result, log_then_return, new_error}; macro_rules! host_function { // Special case for zero parameters @@ -137,7 +137,7 @@ macro_rules! host_function { } }; // General case for one or more parameters - ($N:expr, $($P:ident),+) => { + ($N:expr_2021, $($P:ident),+) => { paste! { /// Trait for registering a host function with $N parameters. pub trait []<'a, $($P,)* R> diff --git a/src/hyperlight_host/src/func/mod.rs b/src/hyperlight_host/src/func/mod.rs index 6d6c56c21..94e420330 100644 --- a/src/hyperlight_host/src/func/mod.rs +++ b/src/hyperlight_host/src/func/mod.rs @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -use crate::{new_error, Result}; +use crate::{Result, new_error}; /// Context structures used to allow the user to call one or more guest /// functions on the same Hyperlight sandbox instance, all from within the /// same state and mutual exclusion context. @@ -50,7 +50,7 @@ pub use hyperlight_common::flatbuffer_wrappers::function_types::ReturnType; pub use hyperlight_common::flatbuffer_wrappers::function_types::ReturnValue; pub use param_type::SupportedParameterType; pub use ret_type::SupportedReturnType; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; type HLFunc = Arc) -> Result + Send>>>; @@ -81,8 +81,6 @@ impl HyperlightFunction { pub use host_functions::HostFunction0; /// Re-export for `HostFunction1` trait pub use host_functions::HostFunction1; -/// Re-export for `HostFunction10` trait -pub use host_functions::HostFunction10; /// Re-export for `HostFunction2` trait pub use host_functions::HostFunction2; /// Re-export for `HostFunction3` trait @@ -99,3 +97,5 @@ pub use host_functions::HostFunction7; pub use host_functions::HostFunction8; /// Re-export for `HostFunction9` trait pub use host_functions::HostFunction9; +/// Re-export for `HostFunction10` trait +pub use host_functions::HostFunction10; diff --git a/src/hyperlight_host/src/func/param_type.rs b/src/hyperlight_host/src/func/param_type.rs index e64010ed1..a6650c831 100644 --- a/src/hyperlight_host/src/func/param_type.rs +++ b/src/hyperlight_host/src/func/param_type.rs @@ -15,10 +15,10 @@ limitations under the License. */ use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterType, ParameterValue}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::HyperlightError::ParameterValueConversionFailure; -use crate::{log_then_return, Result}; +use crate::{Result, log_then_return}; /// This is a marker trait that is used to indicate that a type is a /// valid Hyperlight parameter type. diff --git a/src/hyperlight_host/src/func/ret_type.rs b/src/hyperlight_host/src/func/ret_type.rs index 0436d5816..6686b649c 100644 --- a/src/hyperlight_host/src/func/ret_type.rs +++ b/src/hyperlight_host/src/func/ret_type.rs @@ -15,10 +15,10 @@ limitations under the License. */ use hyperlight_common::flatbuffer_wrappers::function_types::{ReturnType, ReturnValue}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::HyperlightError::ReturnValueConversionFailure; -use crate::{log_then_return, Result}; +use crate::{Result, log_then_return}; /// This is a marker trait that is used to indicate that a type is a valid Hyperlight return type. pub trait SupportedReturnType { diff --git a/src/hyperlight_host/src/hyperlight_surrogate/Cargo.toml_temp_name b/src/hyperlight_host/src/hyperlight_surrogate/Cargo.toml_temp_name index 935fde038..143f3a45a 100644 --- a/src/hyperlight_host/src/hyperlight_surrogate/Cargo.toml_temp_name +++ b/src/hyperlight_host/src/hyperlight_surrogate/Cargo.toml_temp_name @@ -1,7 +1,7 @@ [package] name = "hyperlight_surrogate" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/hyperlight_host/src/hypervisor/crashdump.rs b/src/hyperlight_host/src/hypervisor/crashdump.rs index a70dc34c1..5a79be356 100644 --- a/src/hyperlight_host/src/hypervisor/crashdump.rs +++ b/src/hyperlight_host/src/hypervisor/crashdump.rs @@ -3,7 +3,7 @@ use std::io::Write; use tempfile::NamedTempFile; use super::Hypervisor; -use crate::{new_error, Result}; +use crate::{Result, new_error}; /// Dump registers + memory regions + raw memory to a tempfile #[cfg(crashdump)] diff --git a/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs b/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs index ee009caa1..bf799126e 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs @@ -18,7 +18,7 @@ use gdbstub::common::Signal; use gdbstub::conn::ConnectionExt; use gdbstub::stub::run_blocking::{self, WaitForStopReasonError}; use gdbstub::stub::{BaseStopReason, DisconnectReason, GdbStub, SingleThreadStopReason}; -use libc::{pthread_kill, SIGRTMIN}; +use libc::{SIGRTMIN, pthread_kill}; use super::x86_64_target::HyperlightSandboxTarget; use super::{DebugResponse, GdbTargetError, VcpuStopReason}; diff --git a/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs b/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs index 51bca3d19..0930d26ae 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs @@ -17,11 +17,11 @@ limitations under the License. use crossbeam_channel::TryRecvError; use gdbstub::arch::Arch; use gdbstub::common::Signal; +use gdbstub::target::ext::base::BaseOps; use gdbstub::target::ext::base::singlethread::{ SingleThreadBase, SingleThreadResume, SingleThreadResumeOps, SingleThreadSingleStep, SingleThreadSingleStepOps, }; -use gdbstub::target::ext::base::BaseOps; use gdbstub::target::ext::breakpoints::{ Breakpoints, BreakpointsOps, HwBreakpoint, HwBreakpointOps, SwBreakpoint, SwBreakpointOps, }; diff --git a/src/hyperlight_host/src/hypervisor/handlers.rs b/src/hyperlight_host/src/hypervisor/handlers.rs index 3ffd64441..f4234298c 100644 --- a/src/hyperlight_host/src/hypervisor/handlers.rs +++ b/src/hyperlight_host/src/hypervisor/handlers.rs @@ -16,9 +16,9 @@ limitations under the License. use std::sync::{Arc, Mutex}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; -use crate::{new_error, Result}; +use crate::{Result, new_error}; /// The trait representing custom logic to handle the case when /// a Hypervisor's virtual CPU (vCPU) informs Hyperlight the guest diff --git a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs index fbbeff222..ad57148f1 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs @@ -30,10 +30,10 @@ use log::error; #[cfg(mshv2)] use mshv_bindings::hv_message; use mshv_bindings::{ - hv_message_type, hv_message_type_HVMSG_GPA_INTERCEPT, hv_message_type_HVMSG_UNMAPPED_GPA, + FloatingPointUnit, SegmentRegister, SpecialRegisters, StandardRegisters, hv_message_type, + hv_message_type_HVMSG_GPA_INTERCEPT, hv_message_type_HVMSG_UNMAPPED_GPA, hv_message_type_HVMSG_X64_HALT, hv_message_type_HVMSG_X64_IO_PORT_INTERCEPT, hv_register_assoc, hv_register_name_HV_X64_REGISTER_RIP, hv_register_value, mshv_user_mem_region, - FloatingPointUnit, SegmentRegister, SpecialRegisters, StandardRegisters, }; #[cfg(mshv3)] use mshv_bindings::{ @@ -41,21 +41,21 @@ use mshv_bindings::{ hv_partition_synthetic_processor_features, }; use mshv_ioctls::{Mshv, VcpuFd, VmFd}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::fpu::{FP_CONTROL_WORD_DEFAULT, FP_TAG_WORD_DEFAULT, MXCSR_DEFAULT}; #[cfg(gdb)] use super::handlers::DbgMemAccessHandlerWrapper; use super::handlers::{MemAccessHandlerWrapper, OutBHandlerWrapper}; use super::{ - Hypervisor, VirtualCPU, CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP, CR4_OSFXSR, - CR4_OSXMMEXCPT, CR4_PAE, EFER_LMA, EFER_LME, EFER_NX, EFER_SCE, + CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP, CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, + EFER_LMA, EFER_LME, EFER_NX, EFER_SCE, Hypervisor, VirtualCPU, }; -use crate::hypervisor::hypervisor_handler::HypervisorHandler; use crate::hypervisor::HyperlightExit; +use crate::hypervisor::hypervisor_handler::HypervisorHandler; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; use crate::mem::ptr::{GuestPtr, RawPtr}; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; /// Determine whether the HyperV for Linux hypervisor API is present /// and functional. diff --git a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs index 6b7c621b5..9aa57266f 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs @@ -20,11 +20,11 @@ use std::fmt::{Debug, Formatter}; use std::string::String; use hyperlight_common::mem::PAGE_SIZE_USIZE; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use windows::Win32::System::Hypervisor::{ - WHvX64RegisterCr0, WHvX64RegisterCr3, WHvX64RegisterCr4, WHvX64RegisterCs, WHvX64RegisterEfer, WHV_MEMORY_ACCESS_TYPE, WHV_PARTITION_HANDLE, WHV_REGISTER_VALUE, WHV_RUN_VP_EXIT_CONTEXT, WHV_RUN_VP_EXIT_REASON, WHV_X64_SEGMENT_REGISTER, WHV_X64_SEGMENT_REGISTER_0, + WHvX64RegisterCr0, WHvX64RegisterCr3, WHvX64RegisterCr4, WHvX64RegisterCs, WHvX64RegisterEfer, }; use super::fpu::{FP_TAG_WORD_DEFAULT, MXCSR_DEFAULT}; @@ -36,15 +36,15 @@ use super::surrogate_process_manager::*; use super::windows_hypervisor_platform::{VMPartition, VMProcessor}; use super::wrappers::{HandleWrapper, WHvFPURegisters}; use super::{ - HyperlightExit, Hypervisor, VirtualCPU, CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP, - CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, EFER_LMA, EFER_LME, EFER_NX, EFER_SCE, + CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP, CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, + EFER_LMA, EFER_LME, EFER_NX, EFER_SCE, HyperlightExit, Hypervisor, VirtualCPU, }; use crate::hypervisor::fpu::FP_CONTROL_WORD_DEFAULT; use crate::hypervisor::hypervisor_handler::HypervisorHandler; use crate::hypervisor::wrappers::WHvGeneralRegisters; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; use crate::mem::ptr::{GuestPtr, RawPtr}; -use crate::{debug, new_error, Result}; +use crate::{Result, debug, new_error}; /// A Hypervisor driver for HyperV-on-Windows. pub(crate) struct HypervWindowsDriver { @@ -491,9 +491,9 @@ pub mod tests { use serial_test::serial; + use crate::Result; use crate::hypervisor::handlers::{MemAccessHandler, OutBHandler}; use crate::hypervisor::tests::test_initialise; - use crate::Result; #[test] #[serial] diff --git a/src/hyperlight_host/src/hypervisor/hypervisor_handler.rs b/src/hyperlight_host/src/hypervisor/hypervisor_handler.rs index a66ebc608..20cb334a9 100644 --- a/src/hyperlight_host/src/hypervisor/hypervisor_handler.rs +++ b/src/hyperlight_host/src/hypervisor/hypervisor_handler.rs @@ -20,31 +20,35 @@ use std::ops::DerefMut; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use std::thread; -use std::thread::{sleep, JoinHandle}; +use std::thread::{JoinHandle, sleep}; use std::time::Duration; #[cfg(target_os = "linux")] use crossbeam::atomic::AtomicCell; use crossbeam_channel::{Receiver, Sender}; #[cfg(target_os = "linux")] -use libc::{pthread_kill, pthread_self, ESRCH}; +use libc::{ESRCH, pthread_kill, pthread_self}; use log::{error, info}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; #[cfg(target_os = "linux")] use vmm_sys_util::signal::SIGRTMIN; #[cfg(target_os = "windows")] -use windows::Win32::System::Hypervisor::{WHvCancelRunVirtualProcessor, WHV_PARTITION_HANDLE}; +use windows::Win32::System::Hypervisor::{WHV_PARTITION_HANDLE, WHvCancelRunVirtualProcessor}; #[cfg(gdb)] use super::gdb::create_gdb_thread; +use crate::HyperlightError::{ + GuestExecutionHungOnHostFunctionCall, + HypervisorHandlerExecutionCancelAttemptOnFinishedExecution, NoHypervisorFound, +}; #[cfg(feature = "function_call_metrics")] use crate::histogram_vec_observe; +use crate::hypervisor::Hypervisor; #[cfg(gdb)] use crate::hypervisor::handlers::DbgMemAccessHandlerWrapper; use crate::hypervisor::handlers::{MemAccessHandlerWrapper, OutBHandlerWrapper}; #[cfg(target_os = "windows")] use crate::hypervisor::wrappers::HandleWrapper; -use crate::hypervisor::Hypervisor; use crate::mem::layout::SandboxMemoryLayout; use crate::mem::mgr::SandboxMemoryManager; use crate::mem::ptr::{GuestPtr, RawPtr}; @@ -52,16 +56,12 @@ use crate::mem::ptr_offset::Offset; use crate::mem::shared_mem::{GuestSharedMemory, HostSharedMemory, SharedMemory}; #[cfg(gdb)] use crate::sandbox::config::DebugInfo; -use crate::sandbox::hypervisor::{get_available_hypervisor, HypervisorType}; +use crate::sandbox::hypervisor::{HypervisorType, get_available_hypervisor}; #[cfg(feature = "function_call_metrics")] use crate::sandbox::metrics::SandboxMetric::GuestFunctionCallDurationMicroseconds; #[cfg(target_os = "linux")] use crate::signal_handlers::setup_signal_handlers; -use crate::HyperlightError::{ - GuestExecutionHungOnHostFunctionCall, - HypervisorHandlerExecutionCancelAttemptOnFinishedExecution, NoHypervisorFound, -}; -use crate::{log_then_return, new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, log_then_return, new_error}; type HypervisorHandlerTx = Sender; type HypervisorHandlerRx = Receiver; @@ -985,15 +985,15 @@ mod tests { use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; use hyperlight_testing::simple_guest_as_string; + use crate::HyperlightError::HypervisorHandlerExecutionCancelAttemptOnFinishedExecution; #[cfg(target_os = "windows")] use crate::sandbox::SandboxConfiguration; use crate::sandbox::WrapperGetter; use crate::sandbox_state::sandbox::EvolvableSandbox; use crate::sandbox_state::transition::Noop; - use crate::HyperlightError::HypervisorHandlerExecutionCancelAttemptOnFinishedExecution; use crate::{ - is_hypervisor_present, GuestBinary, HyperlightError, MultiUseSandbox, Result, - UninitializedSandbox, + GuestBinary, HyperlightError, MultiUseSandbox, Result, UninitializedSandbox, + is_hypervisor_present, }; fn create_multi_use_sandbox() -> MultiUseSandbox { diff --git a/src/hyperlight_host/src/hypervisor/inprocess.rs b/src/hyperlight_host/src/hypervisor/inprocess.rs index 1fec3df54..5d117624c 100644 --- a/src/hyperlight_host/src/hypervisor/inprocess.rs +++ b/src/hyperlight_host/src/hypervisor/inprocess.rs @@ -20,10 +20,10 @@ use std::os::raw::c_void; #[cfg(gdb)] use super::handlers::DbgMemAccessHandlerWrapper; use super::{HyperlightExit, Hypervisor}; +use crate::Result; #[cfg(crashdump)] use crate::mem::memory_region::MemoryRegion; use crate::sandbox::leaked_outb::LeakedOutBWrapper; -use crate::Result; /// Arguments passed to inprocess driver pub struct InprocessArgs<'a> { @@ -66,7 +66,7 @@ impl Debug for InprocessDriver<'_> { } } -impl<'a> Hypervisor for InprocessDriver<'a> { +impl Hypervisor for InprocessDriver<'_> { fn initialise( &mut self, _peb_addr: crate::mem::ptr::RawPtr, diff --git a/src/hyperlight_host/src/hypervisor/kvm.rs b/src/hyperlight_host/src/hypervisor/kvm.rs index 5d01ec8ac..e56fd780a 100644 --- a/src/hyperlight_host/src/hypervisor/kvm.rs +++ b/src/hyperlight_host/src/hypervisor/kvm.rs @@ -19,10 +19,10 @@ use std::fmt::Debug; #[cfg(gdb)] use std::sync::{Arc, Mutex}; -use kvm_bindings::{kvm_fpu, kvm_regs, kvm_userspace_memory_region, KVM_MEM_READONLY}; +use kvm_bindings::{KVM_MEM_READONLY, kvm_fpu, kvm_regs, kvm_userspace_memory_region}; use kvm_ioctls::Cap::UserMemory; use kvm_ioctls::{Kvm, VcpuExit, VcpuFd, VmFd}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::fpu::{FP_CONTROL_WORD_DEFAULT, FP_TAG_WORD_DEFAULT, MXCSR_DEFAULT}; #[cfg(gdb)] @@ -31,35 +31,38 @@ use super::gdb::{DebugCommChannel, DebugMsg, DebugResponse, VcpuStopReason}; use super::handlers::DbgMemAccessHandlerWrapper; use super::handlers::{MemAccessHandlerWrapper, OutBHandlerWrapper}; use super::{ - HyperlightExit, Hypervisor, VirtualCPU, CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP, - CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, EFER_LMA, EFER_LME, EFER_NX, EFER_SCE, + CR0_AM, CR0_ET, CR0_MP, CR0_NE, CR0_PE, CR0_PG, CR0_WP, CR4_OSFXSR, CR4_OSXMMEXCPT, CR4_PAE, + EFER_LMA, EFER_LME, EFER_NX, EFER_SCE, HyperlightExit, Hypervisor, VirtualCPU, }; +#[cfg(gdb)] +use crate::HyperlightError; use crate::hypervisor::hypervisor_handler::HypervisorHandler; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; use crate::mem::ptr::{GuestPtr, RawPtr}; -#[cfg(gdb)] -use crate::HyperlightError; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; /// Return `true` if the KVM API is available, version 12, and has UserMemory capability, or `false` otherwise #[instrument(skip_all, parent = Span::current(), level = "Trace")] pub(crate) fn is_hypervisor_present() -> bool { - if let Ok(kvm) = Kvm::new() { - let api_version = kvm.get_api_version(); - match api_version { - version if version == 12 && kvm.check_extension(UserMemory) => true, - 12 => { - log::info!("KVM does not have KVM_CAP_USER_MEMORY capability"); - false - } - version => { - log::info!("KVM GET_API_VERSION returned {}, expected 12", version); - false + match Kvm::new() { + Ok(kvm) => { + let api_version = kvm.get_api_version(); + match api_version { + version if version == 12 && kvm.check_extension(UserMemory) => true, + 12 => { + log::info!("KVM does not have KVM_CAP_USER_MEMORY capability"); + false + } + version => { + log::info!("KVM GET_API_VERSION returned {}, expected 12", version); + false + } } } - } else { - log::info!("Error creating KVM object"); - false + _ => { + log::info!("Error creating KVM object"); + false + } } } @@ -70,8 +73,8 @@ mod debug { use hyperlight_common::mem::PAGE_SIZE; use kvm_bindings::{ - kvm_guest_debug, kvm_regs, KVM_GUESTDBG_ENABLE, KVM_GUESTDBG_SINGLESTEP, - KVM_GUESTDBG_USE_HW_BP, KVM_GUESTDBG_USE_SW_BP, + KVM_GUESTDBG_ENABLE, KVM_GUESTDBG_SINGLESTEP, KVM_GUESTDBG_USE_HW_BP, + KVM_GUESTDBG_USE_SW_BP, kvm_guest_debug, kvm_regs, }; use kvm_ioctls::VcpuFd; @@ -79,7 +82,7 @@ mod debug { use crate::hypervisor::gdb::{DebugMsg, DebugResponse, VcpuStopReason, X86_64Regs}; use crate::hypervisor::handlers::DbgMemAccessHandlerCaller; use crate::mem::layout::SandboxMemoryLayout; - use crate::{new_error, HyperlightError, Result}; + use crate::{HyperlightError, Result, new_error}; /// Software Breakpoint size in memory pub const SW_BP_SIZE: usize = 1; @@ -923,11 +926,11 @@ impl Hypervisor for KVMDriver { mod tests { use std::sync::{Arc, Mutex}; + use crate::Result; #[cfg(gdb)] use crate::hypervisor::handlers::DbgMemAccessHandlerCaller; use crate::hypervisor::handlers::{MemAccessHandler, OutBHandler}; use crate::hypervisor::tests::test_initialise; - use crate::Result; #[cfg(gdb)] struct DbgMemAccessHandler {} diff --git a/src/hyperlight_host/src/hypervisor/metrics.rs b/src/hyperlight_host/src/hypervisor/metrics.rs index a02d19ed0..a34b23209 100644 --- a/src/hyperlight_host/src/hypervisor/metrics.rs +++ b/src/hyperlight_host/src/hypervisor/metrics.rs @@ -22,7 +22,7 @@ use std::sync::Once; use once_cell::sync::OnceCell; use strum::{EnumIter, IntoStaticStr, VariantNames}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::metrics::{ HyperlightMetric, HyperlightMetricDefinition, HyperlightMetricEnum, HyperlightMetricType, diff --git a/src/hyperlight_host/src/hypervisor/mod.rs b/src/hyperlight_host/src/hypervisor/mod.rs index 929aff0ab..8495677af 100644 --- a/src/hyperlight_host/src/hypervisor/mod.rs +++ b/src/hyperlight_host/src/hypervisor/mod.rs @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::error::HyperlightError::ExecutionCanceledByHost; use crate::hypervisor::metrics::HypervisorMetric::NumberOfCancelledGuestExecutions; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; -use crate::{int_counter_inc, log_then_return, new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, int_counter_inc, log_then_return, new_error}; /// Util for handling x87 fpu state #[cfg(any(kvm, mshv, target_os = "windows"))] @@ -318,7 +318,7 @@ pub(crate) mod tests { use crate::mem::ptr::RawPtr; use crate::sandbox::uninitialized::GuestBinary; use crate::sandbox::{SandboxConfiguration, UninitializedSandbox}; - use crate::{new_error, Result}; + use crate::{Result, new_error}; pub(crate) fn test_initialise( outb_hdl: OutBHandlerWrapper, diff --git a/src/hyperlight_host/src/hypervisor/surrogate_process.rs b/src/hyperlight_host/src/hypervisor/surrogate_process.rs index 4ebbaec94..6ff2bb33c 100644 --- a/src/hyperlight_host/src/hypervisor/surrogate_process.rs +++ b/src/hyperlight_host/src/hypervisor/surrogate_process.rs @@ -16,10 +16,10 @@ limitations under the License. use core::ffi::c_void; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use windows::Win32::Foundation::HANDLE; use windows::Win32::System::Memory::{ - UnmapViewOfFile2, MEMORY_MAPPED_VIEW_ADDRESS, UNMAP_VIEW_OF_FILE_FLAGS, + MEMORY_MAPPED_VIEW_ADDRESS, UNMAP_VIEW_OF_FILE_FLAGS, UnmapViewOfFile2, }; use super::surrogate_process_manager::get_surrogate_process_manager; @@ -78,7 +78,10 @@ impl Drop for SurrogateProcess { Ok(manager) => match manager.return_surrogate_process(self.process_handle) { Ok(_) => (), Err(e) => { - tracing::error!("Failed to return surrogate process to surrogate process manager when dropping : {:?}", e); + tracing::error!( + "Failed to return surrogate process to surrogate process manager when dropping : {:?}", + e + ); return; } }, diff --git a/src/hyperlight_host/src/hypervisor/surrogate_process_manager.rs b/src/hyperlight_host/src/hypervisor/surrogate_process_manager.rs index ebfe28c06..781fec5da 100644 --- a/src/hyperlight_host/src/hypervisor/surrogate_process_manager.rs +++ b/src/hyperlight_host/src/hypervisor/surrogate_process_manager.rs @@ -20,30 +20,30 @@ use std::io::Write; use std::mem::size_of; use std::path::{Path, PathBuf}; -use crossbeam_channel::{unbounded, Receiver, Sender}; +use crossbeam_channel::{Receiver, Sender, unbounded}; use hyperlight_common::mem::PAGE_SIZE_USIZE; use rust_embed::RustEmbed; -use tracing::{info, instrument, Span}; -use windows::core::{s, PCSTR}; +use tracing::{Span, info, instrument}; use windows::Win32::Foundation::HANDLE; use windows::Win32::Security::SECURITY_ATTRIBUTES; use windows::Win32::System::JobObjects::{ - AssignProcessToJobObject, CreateJobObjectA, JobObjectExtendedLimitInformation, - SetInformationJobObject, TerminateJobObject, JOBOBJECT_BASIC_LIMIT_INFORMATION, - JOBOBJECT_EXTENDED_LIMIT_INFORMATION, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, + AssignProcessToJobObject, CreateJobObjectA, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, + JOBOBJECT_BASIC_LIMIT_INFORMATION, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, + JobObjectExtendedLimitInformation, SetInformationJobObject, TerminateJobObject, }; use windows::Win32::System::Memory::{ - MapViewOfFileNuma2, VirtualProtectEx, PAGE_NOACCESS, PAGE_PROTECTION_FLAGS, PAGE_READWRITE, + MapViewOfFileNuma2, PAGE_NOACCESS, PAGE_PROTECTION_FLAGS, PAGE_READWRITE, VirtualProtectEx, }; use windows::Win32::System::SystemServices::NUMA_NO_PREFERRED_NODE; use windows::Win32::System::Threading::{ - CreateProcessA, CREATE_SUSPENDED, PROCESS_INFORMATION, STARTUPINFOA, + CREATE_SUSPENDED, CreateProcessA, PROCESS_INFORMATION, STARTUPINFOA, }; +use windows::core::{PCSTR, s}; use super::surrogate_process::SurrogateProcess; use super::wrappers::{HandleWrapper, PSTRWrapper}; use crate::HyperlightError::WindowsAPIError; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; // Use the rust-embed crate to embed the hyperlights_surrogate.exe // binary in the hyperlight-host library to make dependency management easier. @@ -415,16 +415,16 @@ mod tests { use std::time::{Duration, Instant}; use hyperlight_common::mem::PAGE_SIZE_USIZE; - use rand::{rng, Rng}; + use rand::{Rng, rng}; use serial_test::serial; - use windows::Win32::Foundation::{CloseHandle, BOOL, HANDLE, INVALID_HANDLE_VALUE}; + use windows::Win32::Foundation::{BOOL, CloseHandle, HANDLE, INVALID_HANDLE_VALUE}; use windows::Win32::System::Diagnostics::ToolHelp::{ - CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32, TH32CS_SNAPPROCESS, + CreateToolhelp32Snapshot, PROCESSENTRY32, Process32First, Process32Next, TH32CS_SNAPPROCESS, }; use windows::Win32::System::JobObjects::IsProcessInJob; use windows::Win32::System::Memory::{ - CreateFileMappingA, MapViewOfFile, UnmapViewOfFile, FILE_MAP_ALL_ACCESS, PAGE_READWRITE, - SEC_COMMIT, + CreateFileMappingA, FILE_MAP_ALL_ACCESS, MapViewOfFile, PAGE_READWRITE, SEC_COMMIT, + UnmapViewOfFile, }; use super::*; diff --git a/src/hyperlight_host/src/hypervisor/windows_hypervisor_platform.rs b/src/hyperlight_host/src/hypervisor/windows_hypervisor_platform.rs index 18eda5f23..da56bc097 100644 --- a/src/hyperlight_host/src/hypervisor/windows_hypervisor_platform.rs +++ b/src/hyperlight_host/src/hypervisor/windows_hypervisor_platform.rs @@ -16,17 +16,17 @@ limitations under the License. use core::ffi::c_void; -use tracing::{instrument, Span}; -use windows::core::s; +use tracing::{Span, instrument}; use windows::Win32::Foundation::{FreeLibrary, HANDLE}; use windows::Win32::System::Hypervisor::*; use windows::Win32::System::LibraryLoader::*; +use windows::core::s; use windows_result::HRESULT; use super::wrappers::HandleWrapper; use crate::hypervisor::wrappers::{WHvFPURegisters, WHvGeneralRegisters, WHvSpecialRegisters}; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; -use crate::{new_error, Result}; +use crate::{Result, new_error}; // We need to pass in a primitive array of register names/values // to WHvSetVirtualProcessorRegisters and rust needs to know array size diff --git a/src/hyperlight_host/src/hypervisor/wrappers.rs b/src/hyperlight_host/src/hypervisor/wrappers.rs index aa9943d6a..ae017f00e 100644 --- a/src/hyperlight_host/src/hypervisor/wrappers.rs +++ b/src/hyperlight_host/src/hypervisor/wrappers.rs @@ -16,10 +16,10 @@ limitations under the License. use std::ffi::CString; -use tracing::{instrument, Span}; -use windows::core::PSTR; +use tracing::{Span, instrument}; use windows::Win32::Foundation::{HANDLE, HMODULE}; use windows::Win32::System::Hypervisor::WHV_REGISTER_VALUE; +use windows::core::PSTR; use crate::{HyperlightError, Result}; diff --git a/src/hyperlight_host/src/lib.rs b/src/hyperlight_host/src/lib.rs index 5921889d6..e2acc4644 100644 --- a/src/hyperlight_host/src/lib.rs +++ b/src/hyperlight_host/src/lib.rs @@ -90,10 +90,6 @@ pub(crate) mod testing; pub use error::HyperlightError; /// The re-export for the set_registry function pub use metrics::set_metrics_registry; -/// The re-export for the `is_hypervisor_present` type -pub use sandbox::is_hypervisor_present; -/// The re-export for the `GuestBinary` type -pub use sandbox::uninitialized::GuestBinary; /// Re-export for `HypervisorWrapper` trait /// Re-export for `MemMgrWrapper` type /// A sandbox that can call be used to make multiple calls to guest functions, @@ -103,6 +99,10 @@ pub use sandbox::MultiUseSandbox; pub use sandbox::SandboxRunOptions; /// The re-export for the `UninitializedSandbox` type pub use sandbox::UninitializedSandbox; +/// The re-export for the `is_hypervisor_present` type +pub use sandbox::is_hypervisor_present; +/// The re-export for the `GuestBinary` type +pub use sandbox::uninitialized::GuestBinary; /// The re-export for the `MultiUseGuestCallContext` type` pub use crate::func::call_ctx::MultiUseGuestCallContext; @@ -124,7 +124,7 @@ macro_rules! log_then_return { log::error!("{}", __err); return Err(__err); }}; - ($err:expr $(,)?) => { + ($err:expr_2021 $(,)?) => { log::error!("{}", $err); return Err($err); }; @@ -132,7 +132,7 @@ macro_rules! log_then_return { log::error!("{}", $err); return Err($err); }; - ($fmtstr:expr, $($arg:tt)*) => { + ($fmtstr:expr_2021, $($arg:tt)*) => { let __err_msg = std::format!($fmtstr, $($arg)*); let __err = $crate::error::HyperlightError::Error(__err_msg); log::error!("{}", __err); diff --git a/src/hyperlight_host/src/mem/custom_drop.rs b/src/hyperlight_host/src/mem/custom_drop.rs index 822632af0..2de1c6e01 100644 --- a/src/hyperlight_host/src/mem/custom_drop.rs +++ b/src/hyperlight_host/src/mem/custom_drop.rs @@ -16,7 +16,7 @@ limitations under the License. use std::fmt::Debug; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; /// A struct that stores a `*mut EltT` and allows the creator of the struct /// to specify the functionality to be run when the struct is dropped. @@ -33,7 +33,7 @@ pub(crate) struct CustomPtrDrop<'a, EltT> { drop: Box, } -impl<'a, EltT> CustomPtrDrop<'a, EltT> { +impl CustomPtrDrop<'_, EltT> { #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub(crate) fn new(elt: *mut EltT, drop_fn: Box) -> Self { Self { @@ -47,13 +47,13 @@ impl<'a, EltT> CustomPtrDrop<'a, EltT> { } } -impl<'a, EltT> Debug for CustomPtrDrop<'a, EltT> { +impl Debug for CustomPtrDrop<'_, EltT> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("CustomDrop").finish() } } -impl<'a, EltT> Drop for CustomPtrDrop<'a, EltT> { +impl Drop for CustomPtrDrop<'_, EltT> { #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn drop(&mut self) { let drop_fn = &self.drop; diff --git a/src/hyperlight_host/src/mem/elf.rs b/src/hyperlight_host/src/mem/elf.rs index ec1918323..44d95e946 100644 --- a/src/hyperlight_host/src/mem/elf.rs +++ b/src/hyperlight_host/src/mem/elf.rs @@ -21,7 +21,7 @@ use goblin::elf::reloc::{R_X86_64_NONE, R_X86_64_RELATIVE}; use goblin::elf::{Elf, ProgramHeaders, Reloc}; use goblin::elf64::program_header::PT_LOAD; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; pub(crate) struct ElfInfo { payload: Vec, diff --git a/src/hyperlight_host/src/mem/layout.rs b/src/hyperlight_host/src/mem/layout.rs index 3a13879c4..040f14aba 100644 --- a/src/hyperlight_host/src/mem/layout.rs +++ b/src/hyperlight_host/src/mem/layout.rs @@ -16,10 +16,10 @@ limitations under the License. use std::fmt::Debug; use std::mem::{offset_of, size_of}; -use hyperlight_common::mem::{GuestStackData, HyperlightPEB, RunMode, PAGE_SIZE_USIZE}; +use hyperlight_common::mem::{GuestStackData, HyperlightPEB, PAGE_SIZE_USIZE, RunMode}; use paste::paste; -use rand::{rng, RngCore}; -use tracing::{instrument, Span}; +use rand::{RngCore, rng}; +use tracing::{Span, instrument}; use super::memory_region::MemoryRegionType::{ BootStack, Code, GuardPage, GuestErrorData, Heap, HostExceptionData, HostFunctionDefinitions, @@ -30,7 +30,7 @@ use super::mgr::AMOUNT_OF_MEMORY_PER_PT; use super::shared_mem::{ExclusiveSharedMemory, GuestSharedMemory, SharedMemory}; use crate::error::HyperlightError::{GuestOffsetIsInvalid, MemoryRequestTooBig}; use crate::sandbox::SandboxConfiguration; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; // +-------------------------------------------+ // | Boot Stack (4KiB) | @@ -739,8 +739,7 @@ impl SandboxMemoryLayout { // Get the number of pages needed for the PTs - let num_pages: usize = ((total_mapped_memory_size + AMOUNT_OF_MEMORY_PER_PT - 1) - / AMOUNT_OF_MEMORY_PER_PT) + let num_pages: usize = total_mapped_memory_size.div_ceil(AMOUNT_OF_MEMORY_PER_PT) + 1 // Round up + 3; // PML4, PDPT, PD diff --git a/src/hyperlight_host/src/mem/loaded_lib.rs b/src/hyperlight_host/src/mem/loaded_lib.rs index f579d2e13..692273745 100644 --- a/src/hyperlight_host/src/mem/loaded_lib.rs +++ b/src/hyperlight_host/src/mem/loaded_lib.rs @@ -18,15 +18,15 @@ use std::ffi::OsStr; use std::os::windows::ffi::OsStrExt; use std::sync::{Arc, Mutex, Weak}; -use tracing::{instrument, Span}; -use windows::core::PCWSTR; +use tracing::{Span, instrument}; use windows::Win32::Foundation::HMODULE; use windows::Win32::System::LibraryLoader::LoadLibraryW; +use windows::core::PCWSTR; use windows_sys::Win32::Foundation::FreeLibrary; use super::ptr::RawPtr; use crate::hypervisor::wrappers::HModuleWrapper; -use crate::{log_then_return, Result}; +use crate::{Result, log_then_return}; /// A wrapper around a binary loaded with the Windows /// [`LoadLibraryW`](https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/System/LibraryLoader/fn.LoadLibraryW.html) diff --git a/src/hyperlight_host/src/mem/memory_region.rs b/src/hyperlight_host/src/mem/memory_region.rs index 6956d9635..fdd4ca8a7 100644 --- a/src/hyperlight_host/src/mem/memory_region.rs +++ b/src/hyperlight_host/src/mem/memory_region.rs @@ -30,8 +30,6 @@ use bitflags::bitflags; #[cfg(mshv)] use hyperlight_common::mem::PAGE_SHIFT; use hyperlight_common::mem::PAGE_SIZE_USIZE; -#[cfg(mshv)] -use mshv_bindings::{hv_x64_memory_intercept_message, mshv_user_mem_region}; #[cfg(mshv2)] use mshv_bindings::{ HV_MAP_GPA_EXECUTABLE, HV_MAP_GPA_PERMISSIONS_NONE, HV_MAP_GPA_READABLE, HV_MAP_GPA_WRITABLE, @@ -40,6 +38,8 @@ use mshv_bindings::{ use mshv_bindings::{ MSHV_SET_MEM_BIT_EXECUTABLE, MSHV_SET_MEM_BIT_UNMAP, MSHV_SET_MEM_BIT_WRITABLE, }; +#[cfg(mshv)] +use mshv_bindings::{hv_x64_memory_intercept_message, mshv_user_mem_region}; #[cfg(target_os = "windows")] use windows::Win32::System::Hypervisor::{self, WHV_MEMORY_ACCESS_TYPE}; diff --git a/src/hyperlight_host/src/mem/mgr.rs b/src/hyperlight_host/src/mem/mgr.rs index 993f68679..45057aa82 100644 --- a/src/hyperlight_host/src/mem/mgr.rs +++ b/src/hyperlight_host/src/mem/mgr.rs @@ -20,14 +20,14 @@ use std::str::from_utf8; use std::sync::{Arc, Mutex}; use hyperlight_common::flatbuffer_wrappers::function_call::{ - validate_guest_function_call_buffer, FunctionCall, + FunctionCall, validate_guest_function_call_buffer, }; use hyperlight_common::flatbuffer_wrappers::function_types::ReturnValue; use hyperlight_common::flatbuffer_wrappers::guest_error::{ErrorCode, GuestError}; use hyperlight_common::flatbuffer_wrappers::guest_log_data::GuestLogData; use hyperlight_common::flatbuffer_wrappers::host_function_details::HostFunctionDetails; use serde_json::from_str; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::exe::ExeInfo; use super::layout::SandboxMemoryLayout; @@ -44,7 +44,7 @@ use crate::error::HyperlightError::{ }; use crate::error::HyperlightHostError; use crate::sandbox::SandboxConfiguration; -use crate::{log_then_return, new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, log_then_return, new_error}; /// Paging Flags /// @@ -181,8 +181,7 @@ where let mem_size = usize::try_from(mem_size)?; - let num_pages: usize = - ((mem_size + AMOUNT_OF_MEMORY_PER_PT - 1) / AMOUNT_OF_MEMORY_PER_PT) + 1; + let num_pages: usize = mem_size.div_ceil(AMOUNT_OF_MEMORY_PER_PT) + 1; // Create num_pages PT with 512 PTEs for p in 0..num_pages { @@ -882,9 +881,10 @@ mod tests { panic!("loadlib with elf should fail"); } Err(err) => { - assert!(err - .to_string() - .contains("LoadLibrary can only be used with PE files")); + assert!( + err.to_string() + .contains("LoadLibrary can only be used with PE files") + ); } } } diff --git a/src/hyperlight_host/src/mem/pe/base_relocations.rs b/src/hyperlight_host/src/mem/pe/base_relocations.rs index 6dec8fb34..6012e86f8 100644 --- a/src/hyperlight_host/src/mem/pe/base_relocations.rs +++ b/src/hyperlight_host/src/mem/pe/base_relocations.rs @@ -16,7 +16,7 @@ limitations under the License. use goblin::error; use goblin::pe::section_table::SectionTable; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::Result; @@ -71,7 +71,7 @@ impl<'a> BaseRelocations<'a> { } } -impl<'a> Iterator for BaseRelocations<'a> { +impl Iterator for BaseRelocations<'_> { type Item = BaseRelocation; fn next(&mut self) -> Option { // Check if we can read 2 bytes from the array diff --git a/src/hyperlight_host/src/mem/pe/pe_info.rs b/src/hyperlight_host/src/mem/pe/pe_info.rs index ae8ea3ed9..464095636 100644 --- a/src/hyperlight_host/src/mem/pe/pe_info.rs +++ b/src/hyperlight_host/src/mem/pe/pe_info.rs @@ -17,13 +17,13 @@ limitations under the License. use std::io::{Cursor, Read, Write}; use std::{iter, mem}; +use goblin::pe::PE; use goblin::pe::optional_header::OptionalHeader; use goblin::pe::section_table::SectionTable; -use goblin::pe::PE; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::mem::pe::base_relocations; -use crate::{log_then_return, Result}; +use crate::{Result, log_then_return}; const IMAGE_REL_BASED_DIR64: u8 = 10; const IMAGE_REL_BASED_ABSOLUTE: u8 = 0; @@ -81,7 +81,9 @@ impl PEInfo { if optional_header.windows_fields.section_alignment != optional_header.windows_fields.file_alignment { - log_then_return!("unsupported PE file, section alignment does not match file alignment make sure to link the .exe with /FILEALIGN and /ALIGN options set to the same value") + log_then_return!( + "unsupported PE file, section alignment does not match file alignment make sure to link the .exe with /FILEALIGN and /ALIGN options set to the same value" + ) } if (pe.header.coff_header.characteristics & CHARACTERISTICS_RELOCS_STRIPPED) @@ -340,7 +342,7 @@ mod tests { use hyperlight_testing::{callback_guest_exe_as_string, simple_guest_exe_as_string}; use crate::mem::exe::ExeInfo; - use crate::{new_error, Result}; + use crate::{Result, new_error}; #[allow(dead_code)] struct PEFileTest { diff --git a/src/hyperlight_host/src/mem/ptr.rs b/src/hyperlight_host/src/mem/ptr.rs index bacab051c..f830081d1 100644 --- a/src/hyperlight_host/src/mem/ptr.rs +++ b/src/hyperlight_host/src/mem/ptr.rs @@ -16,12 +16,12 @@ limitations under the License. use std::ops::Add; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::ptr_addr_space::{AddressSpace, GuestAddressSpace}; use super::ptr_offset::Offset; -use crate::error::HyperlightError::{self, CheckedAddOverflow, RawPointerLessThanBaseAddress}; use crate::Result; +use crate::error::HyperlightError::{self, CheckedAddOverflow, RawPointerLessThanBaseAddress}; /// A representation of a raw pointer inside a given address space. /// diff --git a/src/hyperlight_host/src/mem/ptr_addr_space.rs b/src/hyperlight_host/src/mem/ptr_addr_space.rs index 3f84549a7..d3e73ebb4 100644 --- a/src/hyperlight_host/src/mem/ptr_addr_space.rs +++ b/src/hyperlight_host/src/mem/ptr_addr_space.rs @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::layout::SandboxMemoryLayout; use crate::Result; diff --git a/src/hyperlight_host/src/mem/ptr_offset.rs b/src/hyperlight_host/src/mem/ptr_offset.rs index 3e4654b9a..53383797e 100644 --- a/src/hyperlight_host/src/mem/ptr_offset.rs +++ b/src/hyperlight_host/src/mem/ptr_offset.rs @@ -18,10 +18,10 @@ use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; use std::convert::From; use std::ops::{Add, Sub}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; -use crate::error::HyperlightError; use crate::Result; +use crate::error::HyperlightError; /// An offset into a given address space. /// @@ -201,10 +201,9 @@ impl Sub for u64 { impl PartialEq for Offset { #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn eq(&self, other: &usize) -> bool { - if let Ok(offset_usize) = usize::try_from(self) { - offset_usize == *other - } else { - false + match usize::try_from(self) { + Ok(offset_usize) => offset_usize == *other, + _ => false, } } } diff --git a/src/hyperlight_host/src/mem/shared_mem.rs b/src/hyperlight_host/src/mem/shared_mem.rs index 721704b41..dbf2802ac 100644 --- a/src/hyperlight_host/src/mem/shared_mem.rs +++ b/src/hyperlight_host/src/mem/shared_mem.rs @@ -22,9 +22,7 @@ use std::ptr::null_mut; use std::sync::{Arc, RwLock}; use hyperlight_common::mem::PAGE_SIZE_USIZE; -use tracing::{instrument, Span}; -#[cfg(target_os = "windows")] -use windows::core::PCSTR; +use tracing::{Span, instrument}; #[cfg(target_os = "windows")] use windows::Win32::Foundation::{CloseHandle, HANDLE, INVALID_HANDLE_VALUE}; #[cfg(all(target_os = "windows", inprocess))] @@ -33,19 +31,21 @@ use windows::Win32::System::Memory::FILE_MAP_EXECUTE; use windows::Win32::System::Memory::PAGE_READWRITE; #[cfg(target_os = "windows")] use windows::Win32::System::Memory::{ - CreateFileMappingA, MapViewOfFile, UnmapViewOfFile, VirtualProtect, FILE_MAP_ALL_ACCESS, - MEMORY_MAPPED_VIEW_ADDRESS, PAGE_EXECUTE_READWRITE, PAGE_NOACCESS, PAGE_PROTECTION_FLAGS, + CreateFileMappingA, FILE_MAP_ALL_ACCESS, MEMORY_MAPPED_VIEW_ADDRESS, MapViewOfFile, + PAGE_EXECUTE_READWRITE, PAGE_NOACCESS, PAGE_PROTECTION_FLAGS, UnmapViewOfFile, VirtualProtect, }; +#[cfg(target_os = "windows")] +use windows::core::PCSTR; #[cfg(target_os = "windows")] use crate::HyperlightError::MemoryAllocationFailed; #[cfg(target_os = "windows")] use crate::HyperlightError::{MemoryRequestTooBig, WindowsAPIError}; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; /// Makes sure that the given `offset` and `size` are within the bounds of the memory with size `mem_size`. macro_rules! bounds_check { - ($offset:expr, $size:expr, $mem_size:expr) => { + ($offset:expr_2021, $size:expr_2021, $mem_size:expr_2021) => { if $offset + $size > $mem_size { return Err(new_error!( "Cannot read value from offset {} with size {} in memory of size {}", @@ -314,8 +314,8 @@ impl ExclusiveSharedMemory { #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub fn new(min_size_bytes: usize) -> Result { use libc::{ - c_int, mmap, mprotect, off_t, size_t, MAP_ANONYMOUS, MAP_FAILED, MAP_NORESERVE, - MAP_SHARED, PROT_NONE, PROT_READ, PROT_WRITE, + MAP_ANONYMOUS, MAP_FAILED, MAP_NORESERVE, MAP_SHARED, PROT_NONE, PROT_READ, PROT_WRITE, + c_int, mmap, mprotect, off_t, size_t, }; use crate::error::HyperlightError::{MemoryRequestTooBig, MmapFailed, MprotectFailed}; @@ -528,7 +528,7 @@ impl ExclusiveSharedMemory { // make the memory executable on Linux #[cfg(target_os = "linux")] { - use libc::{mprotect, PROT_EXEC, PROT_READ, PROT_WRITE}; + use libc::{PROT_EXEC, PROT_READ, PROT_WRITE, mprotect}; let res = unsafe { mprotect( @@ -1016,8 +1016,8 @@ mod tests { use proptest::prelude::*; use super::{ExclusiveSharedMemory, HostSharedMemory, SharedMemory}; - use crate::mem::shared_mem_tests::read_write_test_suite; use crate::Result; + use crate::mem::shared_mem_tests::read_write_test_suite; #[test] fn fill() { diff --git a/src/hyperlight_host/src/mem/shared_mem_snapshot.rs b/src/hyperlight_host/src/mem/shared_mem_snapshot.rs index 28d514b76..b2de715ee 100644 --- a/src/hyperlight_host/src/mem/shared_mem_snapshot.rs +++ b/src/hyperlight_host/src/mem/shared_mem_snapshot.rs @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::shared_mem::SharedMemory; use crate::Result; diff --git a/src/hyperlight_host/src/mem/shared_mem_tests.rs b/src/hyperlight_host/src/mem/shared_mem_tests.rs index 44c54bd03..205c434b7 100644 --- a/src/hyperlight_host/src/mem/shared_mem_tests.rs +++ b/src/hyperlight_host/src/mem/shared_mem_tests.rs @@ -22,7 +22,7 @@ use std::mem::size_of; use hyperlight_common::mem::PAGE_SIZE_USIZE; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; /// A function that knows how to read data of type `T` from a /// `SharedMemory` at a specified offset diff --git a/src/hyperlight_host/src/metrics/histogram.rs b/src/hyperlight_host/src/metrics/histogram.rs index 82ddefdfa..3a473fe94 100644 --- a/src/hyperlight_host/src/metrics/histogram.rs +++ b/src/hyperlight_host/src/metrics/histogram.rs @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -use prometheus::{register_histogram_with_registry, Histogram as PHistogram}; -use tracing::{instrument, Span}; +use prometheus::{Histogram as PHistogram, register_histogram_with_registry}; +use tracing::{Span, instrument}; use super::{ - get_histogram_opts, get_metrics_registry, GetHyperlightMetric, HyperlightMetric, - HyperlightMetricOps, + GetHyperlightMetric, HyperlightMetric, HyperlightMetricOps, get_histogram_opts, + get_metrics_registry, }; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; /// A named histogram #[derive(Debug)] @@ -86,7 +86,7 @@ impl From for HyperlightMetric { /// Observes a value for a Histogram #[macro_export] macro_rules! histogram_observe { - ($metric:expr, $val:expr) => {{ + ($metric:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::Histogram>::metric($metric) { Ok(val) => { if let Err(e) = val.observe($val) { @@ -102,7 +102,7 @@ macro_rules! histogram_observe { /// Returns 0.0 if the metric is not found #[macro_export] macro_rules! histogram_sample_sum { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::Histogram>::metric($metric) { Ok(val) => match val.get_sample_sum() { Ok(val) => val, @@ -124,7 +124,7 @@ macro_rules! histogram_sample_sum { /// Returns 0 if the metric is not found #[macro_export] macro_rules! histogram_sample_count { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::Histogram>::metric($metric) { Ok(val) => match val.get_sample_count() { Ok(val) => val, @@ -144,7 +144,7 @@ macro_rules! histogram_sample_count { /// Observe the time it takes to execute an expression, record that time in microseconds in a Histogram and return the result of that expression #[macro_export] macro_rules! histogram_time_micros { - ($metric:expr, $expr:expr) => {{ + ($metric:expr_2021, $expr:expr_2021) => {{ let start = std::time::Instant::now(); let result = $expr; histogram_observe!($metric, start.elapsed().as_micros() as f64); diff --git a/src/hyperlight_host/src/metrics/histogram_vec.rs b/src/hyperlight_host/src/metrics/histogram_vec.rs index 0c4ff9141..e23952378 100644 --- a/src/hyperlight_host/src/metrics/histogram_vec.rs +++ b/src/hyperlight_host/src/metrics/histogram_vec.rs @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -use prometheus::{register_histogram_vec_with_registry, HistogramVec as PHistogramVec}; -use tracing::{instrument, Span}; +use prometheus::{HistogramVec as PHistogramVec, register_histogram_vec_with_registry}; +use tracing::{Span, instrument}; use super::{ - get_histogram_opts, get_metrics_registry, GetHyperlightMetric, HyperlightMetric, - HyperlightMetricOps, + GetHyperlightMetric, HyperlightMetric, HyperlightMetricOps, get_histogram_opts, + get_metrics_registry, }; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; /// A named bundle of histograms #[derive(Debug)] @@ -98,7 +98,7 @@ impl From for HyperlightMetric { /// Observes a value for a HistogramVec #[macro_export] macro_rules! histogram_vec_observe { - ($metric:expr, $label_vals:expr, $val:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::HistogramVec>::metric($metric) { Ok(val) => { @@ -120,7 +120,7 @@ macro_rules! histogram_vec_observe { /// Returns 0.0 if the metric is not found #[macro_export] macro_rules! histogram_vec_sample_sum { - ($metric:expr, $label_vals:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::HistogramVec>::metric($metric) { Ok(val) => match val.get_sample_sum($label_vals) { @@ -147,7 +147,7 @@ macro_rules! histogram_vec_sample_sum { /// Returns 0 if the metric is not found #[macro_export] macro_rules! histogram_vec_sample_count { - ($metric:expr, $label_vals:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::HistogramVec>::metric($metric) { Ok(val) => match val.get_sample_count($label_vals) { @@ -174,7 +174,7 @@ macro_rules! histogram_vec_sample_count { /// `HistogramVec`, and return the result of that expression #[macro_export] macro_rules! histogram_vec_time_micros { - ($metric:expr, $label_vals:expr, $expr:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021, $expr:expr_2021) => {{ let start = std::time::Instant::now(); let result = $expr; $crate::histogram_vec_observe!($metric, $label_vals, start.elapsed().as_micros() as f64); diff --git a/src/hyperlight_host/src/metrics/int_counter.rs b/src/hyperlight_host/src/metrics/int_counter.rs index b164f50ca..52321c789 100644 --- a/src/hyperlight_host/src/metrics/int_counter.rs +++ b/src/hyperlight_host/src/metrics/int_counter.rs @@ -16,13 +16,13 @@ limitations under the License. use prometheus::core::{AtomicU64, GenericCounter}; use prometheus::register_int_counter_with_registry; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::{ - get_metric_opts, get_metrics_registry, GetHyperlightMetric, HyperlightMetric, - HyperlightMetricOps, + GetHyperlightMetric, HyperlightMetric, HyperlightMetricOps, get_metric_opts, + get_metrics_registry, }; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; /// A named counter backed by an `AtomicU64` #[derive(Debug)] @@ -92,7 +92,7 @@ impl From for HyperlightMetric { /// Increments an IntCounter by 1 or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_inc { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounter>::metric($metric) { Ok(val) => val.inc(), Err(e) => log::error!("error getting metric: {}", e), @@ -103,7 +103,7 @@ macro_rules! int_counter_inc { /// Increments an IntCounter by a given value or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_inc_by { - ($metric:expr, $val:expr) => {{ + ($metric:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounter>::metric($metric) { Ok(val) => val.inc_by($val), Err(e) => log::error!("error getting metric: {}", e), @@ -114,7 +114,7 @@ macro_rules! int_counter_inc_by { /// Gets the value of an IntCounter or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_get { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounter>::metric($metric) { Ok(val) => val.get(), Err(e) => { @@ -128,7 +128,7 @@ macro_rules! int_counter_get { /// Resets an IntCounter or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_reset { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounter>::metric($metric) { Ok(val) => val.reset(), Err(e) => log::error!("error getting metric: {}", e), diff --git a/src/hyperlight_host/src/metrics/int_counter_vec.rs b/src/hyperlight_host/src/metrics/int_counter_vec.rs index 84ed14050..e82768130 100644 --- a/src/hyperlight_host/src/metrics/int_counter_vec.rs +++ b/src/hyperlight_host/src/metrics/int_counter_vec.rs @@ -16,13 +16,13 @@ limitations under the License. use prometheus::core::{AtomicU64, GenericCounterVec}; use prometheus::register_int_counter_vec_with_registry; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::{ - get_metric_opts, get_metrics_registry, GetHyperlightMetric, HyperlightMetric, - HyperlightMetricOps, + GetHyperlightMetric, HyperlightMetric, HyperlightMetricOps, get_metric_opts, + get_metrics_registry, }; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; /// A 64-bit counter #[derive(Debug)] @@ -99,7 +99,7 @@ impl From for HyperlightMetric { /// Increments an IntCounterVec by 1 or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_vec_inc { - ($metric:expr, $label_vals:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounterVec>::metric( $metric, ) { @@ -120,7 +120,7 @@ macro_rules! int_counter_vec_inc { /// Increments an IntCounterVec by a value or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_vec_inc_by { - ($metric:expr, $label_vals:expr, $val:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounterVec>::metric( $metric, ) { @@ -143,7 +143,7 @@ macro_rules! int_counter_vec_inc_by { /// Returns 0 if the metric is not found #[macro_export] macro_rules! int_counter_vec_get { - ($metric:expr, $label_vals:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounterVec>::metric( $metric, ) { @@ -166,7 +166,7 @@ macro_rules! int_counter_vec_get { /// Resets an IntCounterVec or logs an error if the metric is not found #[macro_export] macro_rules! int_counter_vec_reset { - ($metric:expr, $label_vals:expr) => {{ + ($metric:expr_2021, $label_vals:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntCounterVec>::metric( $metric, ) { diff --git a/src/hyperlight_host/src/metrics/int_gauge.rs b/src/hyperlight_host/src/metrics/int_gauge.rs index ed595d462..0beaebcc5 100644 --- a/src/hyperlight_host/src/metrics/int_gauge.rs +++ b/src/hyperlight_host/src/metrics/int_gauge.rs @@ -16,13 +16,13 @@ limitations under the License. use prometheus::core::{AtomicI64, GenericGauge}; use prometheus::register_int_gauge_with_registry; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::{ - get_metric_opts, get_metrics_registry, GetHyperlightMetric, HyperlightMetric, - HyperlightMetricOps, + GetHyperlightMetric, HyperlightMetric, HyperlightMetricOps, get_metric_opts, + get_metrics_registry, }; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; /// A gauge backed by an `AtomicI64` #[derive(Debug)] @@ -102,7 +102,7 @@ impl From for HyperlightMetric { /// Increments an IntGauge by 1 or logs an error if the metric is not found #[macro_export] macro_rules! int_gauge_inc { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntGauge>::metric($metric) { Ok(val) => val.inc(), Err(e) => log::error!("error getting metric: {}", e), @@ -113,7 +113,7 @@ macro_rules! int_gauge_inc { /// Decrements an IntGauge by 1 or logs an error if the metric is not found #[macro_export] macro_rules! int_gauge_dec { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntGauge>::metric($metric) { Ok(val) => val.dec(), Err(e) => log::error!("error getting metric: {}", e), @@ -124,7 +124,7 @@ macro_rules! int_gauge_dec { /// Sets an IntGauge to value or logs an error if the metric is not found #[macro_export] macro_rules! int_gauge_set { - ($metric:expr, $val:expr) => {{ + ($metric:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntGauge>::metric($metric) { Ok(val) => val.set($val), Err(e) => log::error!("error getting metric: {}", e), @@ -136,7 +136,7 @@ macro_rules! int_gauge_set { /// and returns 0 if the metric is not found #[macro_export] macro_rules! int_gauge_get { - ($metric:expr) => {{ + ($metric:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntGauge>::metric($metric) { Ok(val) => val.get(), Err(e) => { @@ -150,7 +150,7 @@ macro_rules! int_gauge_get { /// Adds a value to an IntGauge or logs an error if the metric is not found #[macro_export] macro_rules! int_gauge_add { - ($metric:expr, $val:expr) => {{ + ($metric:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntGauge>::metric($metric) { Ok(val) => val.add($val), Err(e) => log::error!("error getting metric: {}", e), @@ -161,7 +161,7 @@ macro_rules! int_gauge_add { /// Subtracts a value from an IntGauge or logs an error if the metric is not found #[macro_export] macro_rules! int_gauge_sub { - ($metric:expr, $val:expr) => {{ + ($metric:expr_2021, $val:expr_2021) => {{ match $crate::metrics::GetHyperlightMetric::<$crate::metrics::IntGauge>::metric($metric) { Ok(val) => val.sub($val), Err(e) => log::error!("error getting metric: {}", e), diff --git a/src/hyperlight_host/src/metrics/int_gauge_vec.rs b/src/hyperlight_host/src/metrics/int_gauge_vec.rs index de96f2b25..68036e87f 100644 --- a/src/hyperlight_host/src/metrics/int_gauge_vec.rs +++ b/src/hyperlight_host/src/metrics/int_gauge_vec.rs @@ -16,13 +16,13 @@ limitations under the License. use prometheus::core::{AtomicI64, GenericGaugeVec}; use prometheus::register_int_gauge_vec_with_registry; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::{ - get_metric_opts, get_metrics_registry, GetHyperlightMetric, HyperlightMetric, - HyperlightMetricOps, + GetHyperlightMetric, HyperlightMetric, HyperlightMetricOps, get_metric_opts, + get_metrics_registry, }; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; /// A list of gauges, each backed by an `AtomicI64` #[derive(Debug)] diff --git a/src/hyperlight_host/src/metrics/mod.rs b/src/hyperlight_host/src/metrics/mod.rs index 7ff3e6faf..0a38fc277 100644 --- a/src/hyperlight_host/src/metrics/mod.rs +++ b/src/hyperlight_host/src/metrics/mod.rs @@ -19,11 +19,11 @@ use std::sync::Once; use log::error; use once_cell::sync::OnceCell; -use prometheus::{default_registry, histogram_opts, opts, HistogramOpts, Opts, Registry}; +use prometheus::{HistogramOpts, Opts, Registry, default_registry, histogram_opts, opts}; use strum::{IntoEnumIterator, VariantNames}; use crate::error::HyperlightError::{Error, MetricNotFound}; -use crate::{log_then_return, new_error, Result}; +use crate::{Result, log_then_return, new_error}; mod int_gauge_vec; /// An Integer Gauge Metric for Hyperlight /// diff --git a/src/hyperlight_host/src/sandbox/config.rs b/src/hyperlight_host/src/sandbox/config.rs index e0bbaddbe..e4166a6d7 100644 --- a/src/hyperlight_host/src/sandbox/config.rs +++ b/src/hyperlight_host/src/sandbox/config.rs @@ -17,7 +17,7 @@ limitations under the License. use std::cmp::{max, min}; use std::time::Duration; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::mem::exe::ExeInfo; diff --git a/src/hyperlight_host/src/sandbox/host_funcs.rs b/src/hyperlight_host/src/sandbox/host_funcs.rs index 15ef9a46f..5f6052f37 100644 --- a/src/hyperlight_host/src/sandbox/host_funcs.rs +++ b/src/hyperlight_host/src/sandbox/host_funcs.rs @@ -20,14 +20,14 @@ use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, Ret use hyperlight_common::flatbuffer_wrappers::host_function_definition::HostFunctionDefinition; use hyperlight_common::flatbuffer_wrappers::host_function_details::HostFunctionDetails; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::{ExtraAllowedSyscall, FunctionsMap}; +use crate::HyperlightError::HostFunctionNotFound; use crate::func::HyperlightFunction; use crate::mem::mgr::SandboxMemoryManager; use crate::mem::shared_mem::ExclusiveSharedMemory; -use crate::HyperlightError::HostFunctionNotFound; -use crate::{new_error, Result}; +use crate::{Result, new_error}; #[derive(Default, Clone)] /// A Wrapper around details of functions exposed by the Host diff --git a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs index 43f3c7211..7d630efdc 100644 --- a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs +++ b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs @@ -19,17 +19,17 @@ use std::sync::{Arc, Mutex}; use hyperlight_common::flatbuffer_wrappers::function_types::{ ParameterValue, ReturnType, ReturnValue, }; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::host_funcs::HostFuncsWrapper; use super::{MemMgrWrapper, WrapperGetter}; +use crate::Result; use crate::func::call_ctx::MultiUseGuestCallContext; use crate::func::guest_dispatch::call_function_on_guest; use crate::hypervisor::hypervisor_handler::HypervisorHandler; use crate::mem::shared_mem::HostSharedMemory; use crate::sandbox_state::sandbox::{DevolvableSandbox, EvolvableSandbox, Sandbox}; use crate::sandbox_state::transition::{MultiUseContextCallback, Noop}; -use crate::Result; /// A sandbox that supports being used Multiple times. /// The implication of being used multiple times is two-fold: @@ -59,7 +59,10 @@ impl Drop for MultiUseSandbox { match self.hv_handler.kill_hypervisor_handler_thread() { Ok(_) => {} Err(e) => { - log::error!("[POTENTIAL THREAD LEAK] Potentially failed to kill hypervisor handler thread when dropping MultiUseSandbox: {:?}", e); + log::error!( + "[POTENTIAL THREAD LEAK] Potentially failed to kill hypervisor handler thread when dropping MultiUseSandbox: {:?}", + e + ); } } } diff --git a/src/hyperlight_host/src/sandbox/leaked_outb.rs b/src/hyperlight_host/src/sandbox/leaked_outb.rs index 87fc6c344..e3747ad5b 100644 --- a/src/hyperlight_host/src/sandbox/leaked_outb.rs +++ b/src/hyperlight_host/src/sandbox/leaked_outb.rs @@ -17,7 +17,7 @@ limitations under the License. use std::os::raw::c_void; use std::sync::{Arc, Mutex}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::hypervisor::handlers::{OutBHandlerCaller, OutBHandlerWrapper}; use crate::mem::custom_drop::CustomPtrDrop; @@ -79,7 +79,7 @@ pub(crate) struct LeakedOutBWrapper<'a> { hdl_ptr: Arc>>, } -impl<'a> LeakedOutBWrapper<'a> { +impl LeakedOutBWrapper<'_> { #[instrument(skip_all, parent = Span::current(), level = "Trace")] pub(crate) fn new( mgr: &mut SandboxMemoryManager, diff --git a/src/hyperlight_host/src/sandbox/mem_access.rs b/src/hyperlight_host/src/sandbox/mem_access.rs index 7bf4fbdc2..9f1e238a7 100644 --- a/src/hyperlight_host/src/sandbox/mem_access.rs +++ b/src/hyperlight_host/src/sandbox/mem_access.rs @@ -16,7 +16,7 @@ limitations under the License. use std::sync::{Arc, Mutex}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::mem_mgr::MemMgrWrapper; use crate::error::HyperlightError::StackOverflow; @@ -26,7 +26,7 @@ use crate::hypervisor::handlers::{ MemAccessHandler, MemAccessHandlerFunction, MemAccessHandlerWrapper, }; use crate::mem::shared_mem::HostSharedMemory; -use crate::{log_then_return, Result}; +use crate::{Result, log_then_return}; #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub(super) fn handle_mem_access_impl(wrapper: &MemMgrWrapper) -> Result<()> { diff --git a/src/hyperlight_host/src/sandbox/mem_mgr.rs b/src/hyperlight_host/src/sandbox/mem_mgr.rs index 8099b0991..89ca36775 100644 --- a/src/hyperlight_host/src/sandbox/mem_mgr.rs +++ b/src/hyperlight_host/src/sandbox/mem_mgr.rs @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; +use crate::Result; use crate::mem::layout::SandboxMemoryLayout; -use crate::mem::mgr::{SandboxMemoryManager, STACK_COOKIE_LEN}; +use crate::mem::mgr::{STACK_COOKIE_LEN, SandboxMemoryManager}; use crate::mem::shared_mem::{ ExclusiveSharedMemory, GuestSharedMemory, HostSharedMemory, SharedMemory, }; -use crate::Result; /// StackCookie pub type StackCookie = [u8; STACK_COOKIE_LEN]; diff --git a/src/hyperlight_host/src/sandbox/metrics.rs b/src/hyperlight_host/src/sandbox/metrics.rs index 05ef9bae1..3c40b60db 100644 --- a/src/hyperlight_host/src/sandbox/metrics.rs +++ b/src/hyperlight_host/src/sandbox/metrics.rs @@ -22,7 +22,7 @@ use std::sync::Once; use once_cell::sync::OnceCell; use strum::{EnumIter, IntoStaticStr, VariantNames}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use crate::metrics::{ HyperlightMetric, HyperlightMetricDefinition, HyperlightMetricEnum, HyperlightMetricType, diff --git a/src/hyperlight_host/src/sandbox/mod.rs b/src/hyperlight_host/src/sandbox/mod.rs index a88556878..ab81002ae 100644 --- a/src/hyperlight_host/src/sandbox/mod.rs +++ b/src/hyperlight_host/src/sandbox/mod.rs @@ -56,7 +56,7 @@ pub use config::SandboxConfiguration; pub use initialized_multi_use::MultiUseSandbox; /// Re-export for `SandboxRunOptions` type pub use run_options::SandboxRunOptions; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; /// Re-export for `GuestBinary` type pub use uninitialized::GuestBinary; /// Re-export for `UninitializedSandbox` type @@ -161,7 +161,7 @@ mod tests { use crate::sandbox::uninitialized::GuestBinary; use crate::sandbox_state::sandbox::EvolvableSandbox; use crate::sandbox_state::transition::Noop; - use crate::{new_error, MultiUseSandbox, UninitializedSandbox}; + use crate::{MultiUseSandbox, UninitializedSandbox, new_error}; #[test] // TODO: add support for testing on WHP diff --git a/src/hyperlight_host/src/sandbox/outb.rs b/src/hyperlight_host/src/sandbox/outb.rs index dd359ebb2..ec959964a 100644 --- a/src/hyperlight_host/src/sandbox/outb.rs +++ b/src/hyperlight_host/src/sandbox/outb.rs @@ -20,7 +20,7 @@ use hyperlight_common::flatbuffer_wrappers::function_types::ParameterValue; use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode; use hyperlight_common::flatbuffer_wrappers::guest_log_data::GuestLogData; use log::{Level, Record}; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use tracing_log::format_trace; use super::host_funcs::HostFuncsWrapper; @@ -28,7 +28,7 @@ use super::mem_mgr::MemMgrWrapper; use crate::hypervisor::handlers::{OutBHandler, OutBHandlerFunction, OutBHandlerWrapper}; use crate::mem::mgr::SandboxMemoryManager; use crate::mem::shared_mem::HostSharedMemory; -use crate::{new_error, HyperlightError, Result}; +use crate::{HyperlightError, Result, new_error}; pub(super) enum OutBAction { Log, @@ -180,7 +180,7 @@ pub(crate) fn outb_handler_wrapper( #[cfg(test)] mod tests { use hyperlight_common::flatbuffer_wrappers::guest_log_level::LogLevel; - use hyperlight_testing::logger::{Logger, LOGGER}; + use hyperlight_testing::logger::{LOGGER, Logger}; use log::Level; use tracing_core::callsite::rebuild_interest_cache; @@ -188,8 +188,8 @@ mod tests { use crate::mem::layout::SandboxMemoryLayout; use crate::mem::mgr::SandboxMemoryManager; use crate::mem::shared_mem::SharedMemory; - use crate::sandbox::outb::GuestLogData; use crate::sandbox::SandboxConfiguration; + use crate::sandbox::outb::GuestLogData; use crate::testing::log_values::test_value_as_str; use crate::testing::simple_guest_exe_info; diff --git a/src/hyperlight_host/src/sandbox/run_options.rs b/src/hyperlight_host/src/sandbox/run_options.rs index 6c5f6904b..1d0c77bca 100644 --- a/src/hyperlight_host/src/sandbox/run_options.rs +++ b/src/hyperlight_host/src/sandbox/run_options.rs @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; /// Configuration options for setting up a new `UninitializedSandbox` and /// subsequent initialized sandboxes, including `MultiUseSandbox`. diff --git a/src/hyperlight_host/src/sandbox/uninitialized.rs b/src/hyperlight_host/src/sandbox/uninitialized.rs index e38647d8a..6beaade4e 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized.rs @@ -20,23 +20,23 @@ use std::path::Path; use std::sync::{Arc, Mutex}; use std::time::Duration; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; #[cfg(gdb)] use super::config::DebugInfo; -use super::host_funcs::{default_writer_func, HostFuncsWrapper}; +use super::host_funcs::{HostFuncsWrapper, default_writer_func}; use super::mem_mgr::MemMgrWrapper; use super::run_options::SandboxRunOptions; use super::uninitialized_evolve::evolve_impl_multi_use; use crate::error::HyperlightError::GuestBinaryShouldBeAFile; use crate::func::host_functions::HostFunction1; use crate::mem::exe::ExeInfo; -use crate::mem::mgr::{SandboxMemoryManager, STACK_COOKIE_LEN}; +use crate::mem::mgr::{STACK_COOKIE_LEN, SandboxMemoryManager}; use crate::mem::shared_mem::ExclusiveSharedMemory; use crate::sandbox::SandboxConfiguration; use crate::sandbox_state::sandbox::EvolvableSandbox; use crate::sandbox_state::transition::Noop; -use crate::{log_build_details, log_then_return, new_error, MultiUseSandbox, Result}; +use crate::{MultiUseSandbox, Result, log_build_details, log_then_return, new_error}; /// A preliminary `Sandbox`, not yet ready to execute guest code. /// @@ -304,7 +304,7 @@ impl UninitializedSandbox { // Hyperlight is only supported on Windows 11 and Windows Server 2022 and later #[cfg(target_os = "windows")] fn check_windows_version() -> Result<()> { - use windows_version::{is_server, OsVersion}; + use windows_version::{OsVersion, is_server}; const WINDOWS_MAJOR: u32 = 10; const WINDOWS_MINOR: u32 = 0; const WINDOWS_PACK: u32 = 0; @@ -334,24 +334,24 @@ mod tests { use crossbeam_queue::ArrayQueue; use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnValue}; - use hyperlight_testing::logger::{Logger as TestLogger, LOGGER as TEST_LOGGER}; + use hyperlight_testing::logger::{LOGGER as TEST_LOGGER, Logger as TestLogger}; use hyperlight_testing::tracing_subscriber::TracingSubscriber as TestSubcriber; use hyperlight_testing::{simple_guest_as_string, simple_guest_exe_as_string}; use log::Level; use serde_json::{Map, Value}; use serial_test::serial; use tracing::Level as tracing_level; - use tracing_core::callsite::rebuild_interest_cache; use tracing_core::Subscriber; + use tracing_core::callsite::rebuild_interest_cache; use uuid::Uuid; use crate::func::{HostFunction1, HostFunction2}; - use crate::sandbox::uninitialized::GuestBinary; use crate::sandbox::SandboxConfiguration; + use crate::sandbox::uninitialized::GuestBinary; use crate::sandbox_state::sandbox::EvolvableSandbox; use crate::sandbox_state::transition::Noop; use crate::testing::log_values::{test_value_as_str, try_to_strings}; - use crate::{new_error, MultiUseSandbox, Result, SandboxRunOptions, UninitializedSandbox}; + use crate::{MultiUseSandbox, Result, SandboxRunOptions, UninitializedSandbox, new_error}; #[test] fn test_in_process() { @@ -1062,9 +1062,11 @@ mod tests { let logcall = TEST_LOGGER.get_log_call(16).unwrap(); assert_eq!(Level::Error, logcall.level); - assert!(logcall - .args - .starts_with("error=Error(\"GuestBinary not found:")); + assert!( + logcall + .args + .starts_with("error=Error(\"GuestBinary not found:") + ); assert_eq!("hyperlight_host::sandbox::uninitialized", logcall.target); // Log record 18 @@ -1116,9 +1118,11 @@ mod tests { let logcall = TEST_LOGGER.get_log_call(1).unwrap(); assert_eq!(Level::Error, logcall.level); - assert!(logcall - .args - .starts_with("error=Error(\"GuestBinary not found:")); + assert!( + logcall + .args + .starts_with("error=Error(\"GuestBinary not found:") + ); assert_eq!("hyperlight_host::sandbox::uninitialized", logcall.target); } { diff --git a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs index f9e99d7aa..ba04983e4 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs @@ -18,7 +18,7 @@ use core::time::Duration; use std::sync::{Arc, Mutex}; use rand::Rng; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; #[cfg(gdb)] use super::mem_access::dbg_mem_access_handler_wrapper; @@ -35,7 +35,7 @@ use crate::sandbox::mem_access::mem_access_handler_wrapper; use crate::sandbox::outb::outb_handler_wrapper; use crate::sandbox::{HostSharedMemory, MemMgrWrapper}; use crate::sandbox_state::sandbox::Sandbox; -use crate::{new_error, MultiUseSandbox, Result, UninitializedSandbox}; +use crate::{MultiUseSandbox, Result, UninitializedSandbox, new_error}; /// The implementation for evolving `UninitializedSandbox`es to /// `Sandbox`es. @@ -159,8 +159,8 @@ mod tests { use hyperlight_testing::{callback_guest_as_string, simple_guest_as_string}; use super::evolve_impl_multi_use; - use crate::sandbox::uninitialized::GuestBinary; use crate::UninitializedSandbox; + use crate::sandbox::uninitialized::GuestBinary; #[test] fn test_evolve() { diff --git a/src/hyperlight_host/src/sandbox_state/sandbox.rs b/src/hyperlight_host/src/sandbox_state/sandbox.rs index 2ddde372b..403d006c9 100644 --- a/src/hyperlight_host/src/sandbox_state/sandbox.rs +++ b/src/hyperlight_host/src/sandbox_state/sandbox.rs @@ -17,7 +17,7 @@ limitations under the License. use std::fmt::Debug; use std::panic; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::transition::TransitionMetadata; use crate::Result; diff --git a/src/hyperlight_host/src/sandbox_state/transition.rs b/src/hyperlight_host/src/sandbox_state/transition.rs index 6583952d9..42a0eaf0a 100644 --- a/src/hyperlight_host/src/sandbox_state/transition.rs +++ b/src/hyperlight_host/src/sandbox_state/transition.rs @@ -16,11 +16,11 @@ limitations under the License. use std::marker::PhantomData; -use tracing::{instrument, Span}; +use tracing::{Span, instrument}; use super::sandbox::Sandbox; -use crate::func::call_ctx::MultiUseGuestCallContext; use crate::Result; +use crate::func::call_ctx::MultiUseGuestCallContext; /// Metadata about an evolution or devolution. Any `Sandbox` implementation /// that also implements `EvolvableSandbox` or `DevolvableSandbox` @@ -100,7 +100,6 @@ impl TransitionMetadata for Noop where F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()> + 'func, @@ -110,14 +109,14 @@ where cb: F, } -impl<'a, Cur: Sandbox, Next: Sandbox, F> TransitionMetadata - for MultiUseContextCallback<'a, Cur, F> +impl TransitionMetadata + for MultiUseContextCallback<'_, Cur, F> where F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()>, { } -impl<'a, Cur: Sandbox, F> MultiUseContextCallback<'a, Cur, F> +impl MultiUseContextCallback<'_, Cur, F> where F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()>, { @@ -143,8 +142,8 @@ where #[cfg(test)] mod tests { use super::Noop; - use crate::sandbox_state::sandbox::{DevolvableSandbox, EvolvableSandbox, Sandbox}; use crate::Result; + use crate::sandbox_state::sandbox::{DevolvableSandbox, EvolvableSandbox, Sandbox}; #[derive(Debug, Eq, PartialEq, Clone)] struct MySandbox1 {} diff --git a/src/hyperlight_host/src/seccomp/guest.rs b/src/hyperlight_host/src/seccomp/guest.rs index 97aadccfa..824e61782 100644 --- a/src/hyperlight_host/src/seccomp/guest.rs +++ b/src/hyperlight_host/src/seccomp/guest.rs @@ -21,7 +21,7 @@ use seccompiler::{ }; use crate::sandbox::ExtraAllowedSyscall; -use crate::{and, or, Result}; +use crate::{Result, and, or}; fn syscalls_allowlist() -> Result)>> { Ok(vec![ diff --git a/src/hyperlight_host/src/seccomp/mod.rs b/src/hyperlight_host/src/seccomp/mod.rs index 3379e2be2..bb921fc1a 100644 --- a/src/hyperlight_host/src/seccomp/mod.rs +++ b/src/hyperlight_host/src/seccomp/mod.rs @@ -28,12 +28,12 @@ pub(crate) mod guest; /// The rule will take the `Allow` action if _all_ the conditions are true. #[macro_export] macro_rules! and { - ($($x:expr),*) => (SeccompRule::new(vec![$($x),*]).unwrap()) + ($($x:expr_2021),*) => (SeccompRule::new(vec![$($x),*]).unwrap()) } /// Shorthand for chaining `SeccompRule`s with the `or` operator in a `SeccompFilter`. #[macro_export] macro_rules! or { - ($($x:expr,)*) => (vec![$($x),*]); - ($($x:expr),*) => (vec![$($x),*]) + ($($x:expr_2021,)*) => (vec![$($x),*]); + ($($x:expr_2021),*) => (vec![$($x),*]) } diff --git a/src/hyperlight_host/src/testing/log_values.rs b/src/hyperlight_host/src/testing/log_values.rs index 9017d394e..4b3fb561e 100644 --- a/src/hyperlight_host/src/testing/log_values.rs +++ b/src/hyperlight_host/src/testing/log_values.rs @@ -16,7 +16,7 @@ limitations under the License. use serde_json::{Map, Value}; -use crate::{new_error, Result}; +use crate::{Result, new_error}; /// Call `check_value_as_str` and panic if it returned an `Err`. Otherwise, /// do nothing. diff --git a/src/hyperlight_host/src/testing/mod.rs b/src/hyperlight_host/src/testing/mod.rs index 4cbc5ca83..b2399daca 100644 --- a/src/hyperlight_host/src/testing/mod.rs +++ b/src/hyperlight_host/src/testing/mod.rs @@ -20,7 +20,7 @@ use std::path::PathBuf; use hyperlight_testing::rust_guest_as_pathbuf; use crate::mem::exe::ExeInfo; -use crate::{new_error, Result}; +use crate::{Result, new_error}; pub(crate) mod log_values; /// Get an `ExeInfo` representing `simpleguest.exe` diff --git a/src/hyperlight_host/tests/integration_test.rs b/src/hyperlight_host/tests/integration_test.rs index eb3ad8228..40098c340 100644 --- a/src/hyperlight_host/tests/integration_test.rs +++ b/src/hyperlight_host/tests/integration_test.rs @@ -471,7 +471,7 @@ fn recursive_stack_allocate_overflow() { #[test] #[ignore] fn log_message() { - use hyperlight_testing::simplelogger::{SimpleLogger, LOGGER}; + use hyperlight_testing::simplelogger::{LOGGER, SimpleLogger}; // init SimpleLogger::initialize_test_logger(); diff --git a/src/hyperlight_host/tests/sandbox_host_tests.rs b/src/hyperlight_host/tests/sandbox_host_tests.rs index cb8452cac..47f12e4ce 100644 --- a/src/hyperlight_host/tests/sandbox_host_tests.rs +++ b/src/hyperlight_host/tests/sandbox_host_tests.rs @@ -23,7 +23,7 @@ use hyperlight_host::sandbox::SandboxConfiguration; use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; use hyperlight_host::sandbox_state::transition::Noop; use hyperlight_host::{ - new_error, GuestBinary, HyperlightError, MultiUseSandbox, Result, UninitializedSandbox, + GuestBinary, HyperlightError, MultiUseSandbox, Result, UninitializedSandbox, new_error, }; use hyperlight_testing::simple_guest_as_string; #[cfg(target_os = "windows")] @@ -317,7 +317,7 @@ fn multiple_parameters() { "Message: arg1:{} arg2:{} arg3:{} arg4:{} arg5:{} arg6:{} arg7:{} arg8:{} arg9:{} arg10:{} arg11:{}.", "1", 2, 3, "4", "5", true, false, 8, 9, 10, 3.123 ), - ) + ), ]; for mut sandbox in get_simpleguest_sandboxes(Some(&writer_func)).into_iter() { @@ -482,11 +482,13 @@ fn simple_test_helper() -> Result<()> { expected_calls ); - assert!(messages - .try_lock() - .map_err(|e| new_error!("Error locking at {}:{}: {}", file!(), line!(), e))? - .iter() - .all(|msg| msg == message)); + assert!( + messages + .try_lock() + .map_err(|e| new_error!("Error locking at {}:{}: {}", file!(), line!(), e))? + .iter() + .all(|msg| msg == message) + ); Ok(()) } diff --git a/src/hyperlight_testing/Cargo.toml b/src/hyperlight_testing/Cargo.toml index cee179de4..565eba6ba 100644 --- a/src/hyperlight_testing/Cargo.toml +++ b/src/hyperlight_testing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyperlight-testing" -edition = "2021" +edition = "2024" [dependencies] anyhow = "1.0.97" diff --git a/src/hyperlight_testing/src/lib.rs b/src/hyperlight_testing/src/lib.rs index 479e59e8b..c2888d1e5 100644 --- a/src/hyperlight_testing/src/lib.rs +++ b/src/hyperlight_testing/src/lib.rs @@ -19,7 +19,7 @@ limitations under the License. use std::env; use std::path::PathBuf; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; pub const MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); pub mod logger; diff --git a/src/hyperlight_testing/src/logger.rs b/src/hyperlight_testing/src/logger.rs index 136558b0d..1313496ac 100644 --- a/src/hyperlight_testing/src/logger.rs +++ b/src/hyperlight_testing/src/logger.rs @@ -18,7 +18,7 @@ use std::cell::RefCell; use std::sync::Once; use std::thread::current; -use log::{set_logger, set_max_level, Level, LevelFilter, Log, Metadata, Record}; +use log::{Level, LevelFilter, Log, Metadata, Record, set_logger, set_max_level}; use once_cell::sync::Lazy; use tracing_log::LogTracer; diff --git a/src/hyperlight_testing/src/simplelogger.rs b/src/hyperlight_testing/src/simplelogger.rs index 0abdf89bd..bc25e591b 100644 --- a/src/hyperlight_testing/src/simplelogger.rs +++ b/src/hyperlight_testing/src/simplelogger.rs @@ -1,30 +1,11 @@ -/* -Copyright 2024 The Hyperlight Authors. - -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. -*/ - -// this is a non threadsafe logger for testing purposes, to test the log messages emitted by the guest. -// it will only log messages from the hyperlight-guest target. It will not log messages from other targets. -// this target is only used when handling an outb log request from the guest, so this logger will only capture those messages. - -use std::sync::Once; +use std::sync::{Mutex, Once}; use std::thread::current; -use log::{set_logger, set_max_level, Level, Log, Metadata, Record}; +use log::{Level, Log, Metadata, Record, set_logger, set_max_level}; pub static LOGGER: SimpleLogger = SimpleLogger {}; static INITLOGGER: Once = Once::new(); + #[derive(Clone, Eq, PartialEq, Debug)] pub struct LogCall { pub level: Level, @@ -35,8 +16,8 @@ pub struct LogCall { pub module_path: Option, } -static mut LOGCALLS: Vec = Vec::::new(); -static mut NUMBER_OF_ENABLED_CALLS: usize = 0; +static LOGCALLS: Mutex> = Mutex::new(Vec::new()); +static NUMBER_OF_ENABLED_CALLS: Mutex = Mutex::new(0); pub struct SimpleLogger {} @@ -49,29 +30,26 @@ impl SimpleLogger { } pub fn num_enabled_calls(&self) -> usize { - unsafe { NUMBER_OF_ENABLED_CALLS } + *NUMBER_OF_ENABLED_CALLS.lock().unwrap() } pub fn num_log_calls(&self) -> usize { - unsafe { LOGCALLS.len() } + LOGCALLS.lock().unwrap().len() } + pub fn get_log_call(&self, idx: usize) -> Option { - unsafe { LOGCALLS.get(idx).cloned() } + LOGCALLS.lock().unwrap().get(idx).cloned() } pub fn clear_log_calls(&self) { - unsafe { - LOGCALLS.clear(); - NUMBER_OF_ENABLED_CALLS = 0; - } + let mut logcalls = LOGCALLS.lock().unwrap(); + logcalls.clear(); + *NUMBER_OF_ENABLED_CALLS.lock().unwrap() = 0; } pub fn test_log_records)>(&self, f: F) { - unsafe { - // this logger is only used for testing so unsafe is fine here - #[allow(static_mut_refs)] - f(&LOGCALLS); - }; + let logcalls = LOGCALLS.lock().unwrap(); + f(&logcalls); self.clear_log_calls(); } } @@ -82,36 +60,29 @@ impl Log for SimpleLogger { // because the guest derives its log level from the host log level then the number times that enabled is called for // the "hyperlight-guest" target will be the same as the number of messages logged by the guest. // In other words this function should always return true for the "hyperlight-guest" target. - unsafe { - if metadata.target() == "hyperlight-guest" { - NUMBER_OF_ENABLED_CALLS += 1; - } - metadata.target() == "hyperlight-guest" && metadata.level() <= log::max_level() + let mut num_enabled = NUMBER_OF_ENABLED_CALLS.lock().unwrap(); + if metadata.target() == "hyperlight-guest" { + *num_enabled += 1; } + metadata.target() == "hyperlight-guest" && metadata.level() <= log::max_level() } + fn log(&self, record: &Record) { if !self.enabled(record.metadata()) { return; } - unsafe { - LOGCALLS.push(LogCall { - level: record.level(), - args: format!("{}", record.args()), - target: record.target().to_string(), - line: record.line(), - file: match record.file() { - None => record.file_static().map(|file| file.to_string()), - Some(file) => Some(file.to_string()), - }, - module_path: match record.module_path() { - None => record - .module_path_static() - .map(|module_path| module_path.to_string()), - Some(module_path) => Some(module_path.to_string()), - }, - }); - }; + let mut logcalls = LOGCALLS.lock().unwrap(); + logcalls.push(LogCall { + level: record.level(), + args: format!("{}", record.args()), + target: record.target().to_string(), + line: record.line(), + file: record.file().map(|file| file.to_string()), + module_path: record + .module_path() + .map(|module_path| module_path.to_string()), + }); println!("Thread {:?} {:?}", current().id(), record); } diff --git a/src/hyperlight_testing/src/tracing_subscriber.rs b/src/hyperlight_testing/src/tracing_subscriber.rs index 32f34c5b7..211d32743 100644 --- a/src/hyperlight_testing/src/tracing_subscriber.rs +++ b/src/hyperlight_testing/src/tracing_subscriber.rs @@ -17,7 +17,7 @@ limitations under the License. use std::cell::RefCell; use std::collections::HashMap; -use serde_json::{json, to_string_pretty, Value}; +use serde_json::{Value, json, to_string_pretty}; use tracing::Subscriber; use tracing_core::event::Event; use tracing_core::metadata::Metadata; diff --git a/src/tests/rust_guests/callbackguest/Cargo.lock b/src/tests/rust_guests/callbackguest/Cargo.lock index a0a2626e5..2cf82d434 100644 --- a/src/tests/rust_guests/callbackguest/Cargo.lock +++ b/src/tests/rust_guests/callbackguest/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anyhow" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "autocfg" @@ -16,9 +16,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "buddy_system_allocator" @@ -39,9 +39,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.15" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "shlex", ] @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "lock_api" @@ -129,18 +129,18 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -156,15 +156,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "scopeguard" @@ -174,24 +174,24 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -249,9 +249,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -260,6 +260,6 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" diff --git a/src/tests/rust_guests/callbackguest/Cargo.toml b/src/tests/rust_guests/callbackguest/Cargo.toml index 0f9c01028..a1f8c7556 100644 --- a/src/tests/rust_guests/callbackguest/Cargo.toml +++ b/src/tests/rust_guests/callbackguest/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "callbackguest" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] hyperlight-guest = { path = "../../../hyperlight_guest" } diff --git a/src/tests/rust_guests/callbackguest/src/main.rs b/src/tests/rust_guests/callbackguest/src/main.rs index c787599d5..df9f6d501 100644 --- a/src/tests/rust_guests/callbackguest/src/main.rs +++ b/src/tests/rust_guests/callbackguest/src/main.rs @@ -161,7 +161,7 @@ fn call_host_spin(_: &FunctionCall) -> Result> { Ok(get_flatbuffer_result(())) } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hyperlight_main() { let print_output_def = GuestFunctionDefinition::new( "PrintOutput".to_string(), @@ -240,7 +240,7 @@ pub extern "C" fn hyperlight_main() { register_function(call_host_spin_def); } -#[no_mangle] +#[unsafe(no_mangle)] pub fn guest_dispatch_function(function_call: FunctionCall) -> Result> { Err(HyperlightGuestError::new( ErrorCode::GuestFunctionNotFound, diff --git a/src/tests/rust_guests/dummyguest/Cargo.toml b/src/tests/rust_guests/dummyguest/Cargo.toml index 619031cae..a0a95864f 100644 --- a/src/tests/rust_guests/dummyguest/Cargo.toml +++ b/src/tests/rust_guests/dummyguest/Cargo.toml @@ -1,4 +1,4 @@ [package] name = "dummyguest" version = "0.4.0" -edition = "2021" \ No newline at end of file +edition = "2024" \ No newline at end of file diff --git a/src/tests/rust_guests/dummyguest/src/main.rs b/src/tests/rust_guests/dummyguest/src/main.rs index fd15f81b1..03189ff4a 100644 --- a/src/tests/rust_guests/dummyguest/src/main.rs +++ b/src/tests/rust_guests/dummyguest/src/main.rs @@ -41,8 +41,7 @@ fn mmio_read() { } } -#[allow(non_snake_case)] -#[no_mangle] +#[unsafe(no_mangle)] pub extern "win64" fn entrypoint(a: i64, b: i64, c: i32) -> i32 { if a != 0x230000 || b != 1234567890 || c != 4096 { mmio_read(); diff --git a/src/tests/rust_guests/simpleguest/Cargo.lock b/src/tests/rust_guests/simpleguest/Cargo.lock index a0978ff71..caf1f6bfc 100644 --- a/src/tests/rust_guests/simpleguest/Cargo.lock +++ b/src/tests/rust_guests/simpleguest/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anyhow" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "autocfg" @@ -16,9 +16,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "buddy_system_allocator" @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.15" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "shlex", ] @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "lock_api" @@ -121,18 +121,18 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -148,15 +148,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "scopeguard" @@ -166,24 +166,24 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -192,9 +192,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -215,6 +215,7 @@ dependencies = [ "hyperlight-common", "hyperlight-guest", "log", + "spin", ] [[package]] @@ -250,9 +251,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -261,6 +262,6 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" diff --git a/src/tests/rust_guests/simpleguest/Cargo.toml b/src/tests/rust_guests/simpleguest/Cargo.toml index f414efe86..fc40e2d83 100644 --- a/src/tests/rust_guests/simpleguest/Cargo.toml +++ b/src/tests/rust_guests/simpleguest/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" hyperlight-guest = { path = "../../../hyperlight_guest" } hyperlight-common = { path = "../../../hyperlight_common", default-features = false } log = {version = "0.4", default-features = false } +spin = "0.9.8" diff --git a/src/tests/rust_guests/simpleguest/src/main.rs b/src/tests/rust_guests/simpleguest/src/main.rs index 45dd558c7..426f5f821 100644 --- a/src/tests/rust_guests/simpleguest/src/main.rs +++ b/src/tests/rust_guests/simpleguest/src/main.rs @@ -32,6 +32,7 @@ use alloc::{format, vec}; use core::ffi::c_char; use core::hint::black_box; use core::ptr::write_volatile; +use spin::Mutex; use hyperlight_common::flatbuffer_wrappers::function_call::{FunctionCall, FunctionCallType}; use hyperlight_common::flatbuffer_wrappers::function_types::{ @@ -52,15 +53,14 @@ use log::{error, LevelFilter}; extern crate hyperlight_guest; -static mut BIGARRAY: [i32; 1024 * 1024] = [0; 1024 * 1024]; +static BIGARRAY: Mutex<[i32; 1024 * 1024]> = Mutex::new([0; 1024 * 1024]); fn set_static(_: &FunctionCall) -> Result> { - unsafe { - for val in BIGARRAY.iter_mut() { - *val = 1; - } - Ok(get_flatbuffer_result(BIGARRAY.len() as i32)) + let array = &mut BIGARRAY.lock(); + for val in array.iter_mut() { + *val = 1; } + Ok(get_flatbuffer_result(array.len() as i32)) } fn echo_double(function_call: &FunctionCall) -> Result> { @@ -354,7 +354,10 @@ fn print_ten_args(function_call: &FunctionCall) -> Result> { function_call.parameters.clone().unwrap()[8].clone(), function_call.parameters.clone().unwrap()[9].clone(), ) { - let message = format!("Message: arg1:{} arg2:{} arg3:{} arg4:{} arg5:{} arg6:{} arg7:{} arg8:{} arg9:{} arg10:{}.", arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + let message = format!( + "Message: arg1:{} arg2:{} arg3:{} arg4:{} arg5:{} arg6:{} arg7:{} arg8:{} arg9:{} arg10:{}.", + arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 + ); print_output(&message) } else { Err(HyperlightGuestError::new( @@ -390,7 +393,10 @@ fn print_eleven_args(function_call: &FunctionCall) -> Result> { function_call.parameters.clone().unwrap()[9].clone(), function_call.parameters.clone().unwrap()[10].clone(), ) { - let message = format!("Message: arg1:{} arg2:{} arg3:{} arg4:{} arg5:{} arg6:{} arg7:{} arg8:{} arg9:{} arg10:{} arg11:{:.3}.", arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); + let message = format!( + "Message: arg1:{} arg2:{} arg3:{} arg4:{} arg5:{} arg6:{} arg7:{} arg8:{} arg9:{} arg10:{} arg11:{:.3}.", + arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11 + ); print_output(&message) } else { Err(HyperlightGuestError::new( @@ -714,7 +720,7 @@ fn add(function_call: &FunctionCall) -> Result> { } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn hyperlight_main() { let set_static_def = GuestFunctionDefinition::new( "SetStatic".to_string(), @@ -1110,7 +1116,7 @@ pub extern "C" fn hyperlight_main() { register_function(trigger_exception_def); } -#[no_mangle] +#[unsafe(no_mangle)] pub fn guest_dispatch_function(function_call: FunctionCall) -> Result> { // This test checks the stack behavior of the input/output buffer // by calling the host before serializing the function call. @@ -1168,7 +1174,7 @@ fn fuzz_host_function(func: FunctionCall) -> Result> { return Err(HyperlightGuestError::new( ErrorCode::GuestFunctionParameterTypeMismatch, "Invalid parameters passed to fuzz_host_function".to_string(), - )) + )); } }; call_host_function(&host_func_name, Some(params), func.expected_return_type)