mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 10:15:03 +00:00
Merge branch 'master' into feat-network-rebuild
This commit is contained in:
commit
06b0853a1b
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,7 +16,6 @@ docs/_build
|
||||
draft
|
||||
cppcheck.xml
|
||||
/target/
|
||||
Cargo.lock
|
||||
.cache
|
||||
compile_commands.json
|
||||
/logs/
|
||||
|
513
build-scripts/Cargo.lock
generated
Normal file
513
build-scripts/Cargo.lock
generated
Normal file
@ -0,0 +1,513 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.61.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"peeking_take_while",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 1.0.109",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||
|
||||
[[package]]
|
||||
name = "elf"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel_build"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"lazy_static",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.150"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
|
||||
|
||||
[[package]]
|
||||
name = "linux_boot_helper"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"elf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.193"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.193"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.43",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
1
kernel/.gitignore
vendored
1
kernel/.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
target/
|
||||
src/kernel
|
||||
Cargo.lock
|
||||
D.config
|
||||
|
||||
# 将自动生成的C-Rust FFI加到gitignore
|
||||
|
2278
kernel/Cargo.lock
generated
Normal file
2278
kernel/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -106,4 +106,4 @@ debug = true # Controls whether the compiler passes `-g`
|
||||
|
||||
# The release profile, used for `cargo build --release`
|
||||
[profile.release]
|
||||
debug = true
|
||||
debug = false
|
||||
|
@ -20,7 +20,6 @@ all:
|
||||
|
||||
|
||||
clean:
|
||||
rm -f Cargo.lock
|
||||
$(MAKE) -C src clean ARCH=$(ARCH)
|
||||
|
||||
.PHONY: fmt
|
||||
|
@ -18,6 +18,7 @@
|
||||
//! # Implementing GlobalAlloc
|
||||
//! See the [global alloc](https://github.com/gz/rust-slabmalloc/tree/master/examples/global_alloc.rs) example.
|
||||
#![allow(unused_features)]
|
||||
#![cfg_attr(test, feature(test, c_void_variant))]
|
||||
#![no_std]
|
||||
#![crate_name = "slabmalloc"]
|
||||
#![crate_type = "lib"]
|
||||
@ -33,8 +34,18 @@ pub use pages::*;
|
||||
pub use sc::*;
|
||||
pub use zone::*;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
#[cfg(test)]
|
||||
extern crate test;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use core::alloc::Layout;
|
||||
use core::fmt;
|
||||
use core::mem;
|
||||
use core::ptr::{self, NonNull};
|
||||
|
||||
use log::trace;
|
||||
@ -71,7 +82,6 @@ pub unsafe trait Allocator<'a> {
|
||||
layout: Layout,
|
||||
slab_callback: &'static dyn CallBack,
|
||||
) -> Result<(), AllocationError>;
|
||||
|
||||
/// Refill the allocator with a [`ObjectPage`].
|
||||
///
|
||||
/// # Safety
|
||||
|
@ -1,11 +1,6 @@
|
||||
use alloc::boxed::Box;
|
||||
|
||||
use crate::*;
|
||||
use core::{
|
||||
mem,
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
};
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::sync::atomic::{AtomicU64, Ordering};
|
||||
/// A trait defining bitfield operations we need for tracking allocated objects within a page.
|
||||
pub(crate) trait Bitfield {
|
||||
fn initialize(&mut self, for_size: usize, capacity: usize);
|
||||
@ -38,7 +33,7 @@ impl Bitfield for [AtomicU64] {
|
||||
fn initialize(&mut self, for_size: usize, capacity: usize) {
|
||||
// Set everything to allocated
|
||||
for bitmap in self.iter_mut() {
|
||||
*bitmap = AtomicU64::new(u64::MAX);
|
||||
*bitmap = AtomicU64::new(u64::max_value());
|
||||
}
|
||||
|
||||
// Mark actual slots as free
|
||||
@ -59,12 +54,9 @@ impl Bitfield for [AtomicU64] {
|
||||
layout: Layout,
|
||||
page_size: usize,
|
||||
) -> Option<(usize, usize)> {
|
||||
let start_offset = get_offset_for_align(layout);
|
||||
let data_start = base_addr + start_offset;
|
||||
|
||||
for (base_idx, b) in self.iter().enumerate() {
|
||||
let bitval = b.load(Ordering::Relaxed);
|
||||
if bitval == u64::MAX {
|
||||
if bitval == u64::max_value() {
|
||||
continue;
|
||||
} else {
|
||||
let negated = !bitval;
|
||||
@ -79,7 +71,7 @@ impl Bitfield for [AtomicU64] {
|
||||
return None;
|
||||
}
|
||||
|
||||
let addr: usize = data_start + offset;
|
||||
let addr: usize = base_addr + offset;
|
||||
let alignment_ok = addr % layout.align() == 0;
|
||||
let block_is_free = bitval & (1 << first_free) == 0;
|
||||
if alignment_ok && block_is_free {
|
||||
@ -125,7 +117,7 @@ impl Bitfield for [AtomicU64] {
|
||||
#[inline(always)]
|
||||
fn is_full(&self) -> bool {
|
||||
self.iter()
|
||||
.filter(|&x| x.load(Ordering::Relaxed) != u64::MAX)
|
||||
.filter(|&x| x.load(Ordering::Relaxed) != u64::max_value())
|
||||
.count()
|
||||
== 0
|
||||
}
|
||||
@ -157,32 +149,6 @@ impl Bitfield for [AtomicU64] {
|
||||
}
|
||||
}
|
||||
|
||||
/// # get_offset_for_align - 根据布局大小获取page内对齐偏移量
|
||||
///
|
||||
/// 这个函数根据给定的`Layout`大小确定一个合适的对齐偏移量。
|
||||
///
|
||||
/// ## 参数
|
||||
///
|
||||
/// - layout: Layout,这是需要计算对齐偏移量的布局参数。
|
||||
///
|
||||
/// ## 返回值
|
||||
///
|
||||
/// - usize: 成功时返回一个usize类型的对齐偏移量。
|
||||
fn get_offset_for_align(layout: Layout) -> usize {
|
||||
match layout.size() {
|
||||
0..=8 => 80,
|
||||
9..=16 => 80,
|
||||
17..=32 => 96,
|
||||
33..=64 => 128,
|
||||
65..=128 => 128,
|
||||
129..=256 => 256,
|
||||
257..=512 => 512,
|
||||
513..=1024 => 1024,
|
||||
1025..=2048 => 2048,
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// This trait is used to define a page from which objects are allocated
|
||||
/// in an `SCAllocator`.
|
||||
///
|
||||
@ -242,8 +208,7 @@ pub trait AllocablePage {
|
||||
ptr,
|
||||
layout
|
||||
);
|
||||
let align_offset = get_offset_for_align(layout);
|
||||
let page_offset = ((ptr.as_ptr() as usize) - align_offset) & (Self::SIZE - 1);
|
||||
let page_offset = (ptr.as_ptr() as usize) & (Self::SIZE - 1);
|
||||
assert!(page_offset % layout.size() == 0);
|
||||
let idx = page_offset / layout.size();
|
||||
assert!(
|
||||
@ -282,20 +247,20 @@ pub trait AllocablePage {
|
||||
/// It is marked `repr(C)` because we rely on a well defined order of struct
|
||||
/// members (e.g., dealloc does a cast to find the bitfield).
|
||||
#[repr(C)]
|
||||
#[repr(align(4096))]
|
||||
pub struct ObjectPage<'a> {
|
||||
/// Holds memory objects.
|
||||
#[allow(dead_code)]
|
||||
/// A bit-field to track free/allocated memory within `data`.
|
||||
pub(crate) bitfield: [AtomicU64; 8],
|
||||
data: [u8; OBJECT_PAGE_SIZE - OBJECT_PAGE_METADATA_OVERHEAD],
|
||||
|
||||
/// Next element in list (used by `PageList`).
|
||||
next: Rawlink<ObjectPage<'a>>,
|
||||
/// Previous element in list (used by `PageList`)
|
||||
prev: Rawlink<ObjectPage<'a>>,
|
||||
|
||||
/// Holds memory objects.
|
||||
data: [u8; OBJECT_PAGE_SIZE - OBJECT_PAGE_METADATA_OVERHEAD],
|
||||
/// A bit-field to track free/allocated memory within `data`.
|
||||
pub(crate) bitfield: [AtomicU64; 8],
|
||||
}
|
||||
|
||||
impl<'a> ObjectPage<'a> {
|
||||
pub fn new() -> Box<ObjectPage<'a>> {
|
||||
unsafe { Box::new_uninit().assume_init() }
|
||||
@ -303,10 +268,10 @@ impl<'a> ObjectPage<'a> {
|
||||
}
|
||||
|
||||
// These needs some more work to be really safe...
|
||||
unsafe impl Send for ObjectPage<'_> {}
|
||||
unsafe impl Sync for ObjectPage<'_> {}
|
||||
unsafe impl<'a> Send for ObjectPage<'a> {}
|
||||
unsafe impl<'a> Sync for ObjectPage<'a> {}
|
||||
|
||||
impl AllocablePage for ObjectPage<'_> {
|
||||
impl<'a> AllocablePage for ObjectPage<'a> {
|
||||
const SIZE: usize = OBJECT_PAGE_SIZE;
|
||||
|
||||
fn bitfield(&self) -> &[AtomicU64; 8] {
|
||||
@ -331,7 +296,7 @@ impl<'a> Default for ObjectPage<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ObjectPage<'_> {
|
||||
impl<'a> fmt::Debug for ObjectPage<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ObjectPage")
|
||||
}
|
||||
@ -424,7 +389,6 @@ impl<'a, T: AllocablePage> PageList<'a, T> {
|
||||
}
|
||||
|
||||
/// Removes `slab_page` from the list.
|
||||
#[allow(clippy::manual_inspect)]
|
||||
pub(crate) fn pop<'b>(&'b mut self) -> Option<&'a mut T> {
|
||||
match self.head {
|
||||
None => None,
|
||||
@ -468,7 +432,6 @@ impl<'a, P: AllocablePage + 'a> Iterator for ObjectPageIterMut<'a, P> {
|
||||
type Item = &'a mut P;
|
||||
|
||||
#[inline]
|
||||
#[allow(clippy::manual_inspect)]
|
||||
fn next(&mut self) -> Option<&'a mut P> {
|
||||
unsafe {
|
||||
self.head.resolve_mut().map(|next| {
|
||||
|
@ -1,7 +1,5 @@
|
||||
//! A SCAllocator that can allocate fixed size objects.
|
||||
|
||||
use core::mem;
|
||||
|
||||
use crate::*;
|
||||
|
||||
/// A genius(?) const min()
|
||||
@ -73,7 +71,7 @@ macro_rules! new_sc_allocator {
|
||||
SCAllocator {
|
||||
size: $size,
|
||||
allocation_count: 0,
|
||||
obj_per_page,
|
||||
obj_per_page: obj_per_page,
|
||||
empty_slabs: PageList::new(),
|
||||
slabs: PageList::new(),
|
||||
full_slabs: PageList::new(),
|
||||
@ -235,6 +233,10 @@ impl<'a, P: AllocablePage> SCAllocator<'a, P> {
|
||||
}
|
||||
}
|
||||
|
||||
self.free_obj_count = self
|
||||
.free_obj_count
|
||||
.saturating_sub(reclaimed * self.obj_per_page);
|
||||
|
||||
reclaimed
|
||||
}
|
||||
|
||||
@ -247,7 +249,6 @@ impl<'a, P: AllocablePage> SCAllocator<'a, P> {
|
||||
.initialize(self.size, P::SIZE - OBJECT_PAGE_METADATA_OVERHEAD);
|
||||
*page.prev() = Rawlink::none();
|
||||
*page.next() = Rawlink::none();
|
||||
trace!("adding page to SCAllocator {:p}", page);
|
||||
self.insert_empty(page);
|
||||
self.free_obj_count += self.obj_per_page;
|
||||
}
|
||||
@ -314,15 +315,13 @@ impl<'a, P: AllocablePage> SCAllocator<'a, P> {
|
||||
/// May return an error in case an invalid `layout` is provided.
|
||||
/// The function may also move internal slab pages between lists partial -> empty
|
||||
/// or full -> partial lists.
|
||||
///
|
||||
/// # Safety
|
||||
/// The caller must ensure that the `layout` is valid.
|
||||
pub unsafe fn deallocate(
|
||||
&mut self,
|
||||
ptr: NonNull<u8>,
|
||||
layout: Layout,
|
||||
slab_callback: &'static dyn CallBack,
|
||||
) -> Result<(), AllocationError> {
|
||||
) -> Result<bool, AllocationError> {
|
||||
assert!(layout.size() <= self.size);
|
||||
assert!(self.size <= (P::SIZE - OBJECT_PAGE_METADATA_OVERHEAD));
|
||||
trace!(
|
||||
@ -342,17 +341,16 @@ impl<'a, P: AllocablePage> SCAllocator<'a, P> {
|
||||
|
||||
let ret = slab_page.deallocate(ptr, new_layout);
|
||||
debug_assert!(ret.is_ok(), "Slab page deallocate won't fail at the moment");
|
||||
|
||||
self.free_obj_count += 1;
|
||||
let is_empty_after_dealloc = slab_page.is_empty(self.obj_per_page);
|
||||
|
||||
let mut need_reclaim = false;
|
||||
// 如果slab_page是空白的,且空闲块数大于free_limit,将slab_page归还buddy
|
||||
if self.free_obj_count >= self.free_limit && is_empty_after_dealloc {
|
||||
self.slabs.remove_from_list(slab_page);
|
||||
// 将slab_page归还buddy
|
||||
slab_callback.free_slab_page(slab_page as *const P as *mut u8, P::SIZE);
|
||||
need_reclaim = true;
|
||||
}
|
||||
self.check_page_assignments();
|
||||
|
||||
ret
|
||||
ret.map(|_| need_reclaim)
|
||||
}
|
||||
}
|
||||
|
582
kernel/crates/rust-slabmalloc/src/tests.rs
Normal file
582
kernel/crates/rust-slabmalloc/src/tests.rs
Normal file
@ -0,0 +1,582 @@
|
||||
use env_logger;
|
||||
use rand;
|
||||
use std::alloc;
|
||||
use std::alloc::Layout;
|
||||
use std::collections::HashSet;
|
||||
use std::mem::{size_of, transmute};
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use crate::*;
|
||||
use test::Bencher;
|
||||
|
||||
/// A simple page allocator based on GlobalAlloc (for testing purposes).
|
||||
struct Pager {
|
||||
base_pages: HashSet<*mut u8>, // probably should be hash-tables
|
||||
}
|
||||
|
||||
unsafe impl Send for Pager {}
|
||||
unsafe impl Sync for Pager {}
|
||||
|
||||
impl Pager {
|
||||
pub fn new() -> Pager {
|
||||
Pager {
|
||||
base_pages: HashSet::with_capacity(1024),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Pager {
|
||||
pub fn currently_allocated(&self) -> usize {
|
||||
self.base_pages.len()
|
||||
}
|
||||
|
||||
fn alloc_page(&mut self, page_size: usize) -> Option<*mut u8> {
|
||||
let r =
|
||||
unsafe { std::alloc::alloc(Layout::from_size_align(page_size, page_size).unwrap()) };
|
||||
|
||||
if !r.is_null() {
|
||||
match page_size {
|
||||
OBJECT_PAGE_SIZE => self.base_pages.insert(r),
|
||||
_ => unreachable!("invalid page-size supplied"),
|
||||
};
|
||||
Some(r)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn dealloc_page(&mut self, ptr: *mut u8, page_size: usize) {
|
||||
let layout = match page_size {
|
||||
OBJECT_PAGE_SIZE => {
|
||||
assert!(
|
||||
self.base_pages.contains(&ptr),
|
||||
"Trying to deallocate invalid base-page"
|
||||
);
|
||||
self.base_pages.remove(&ptr);
|
||||
Layout::from_size_align(OBJECT_PAGE_SIZE, OBJECT_PAGE_SIZE).unwrap()
|
||||
}
|
||||
|
||||
_ => unreachable!("invalid page-size supplied"),
|
||||
};
|
||||
|
||||
unsafe { std::alloc::dealloc(ptr, layout) };
|
||||
}
|
||||
}
|
||||
|
||||
trait PageProvider<'a>: Send {
|
||||
fn allocate_page(&mut self) -> Option<&'a mut ObjectPage<'a>>;
|
||||
fn release_page(&mut self, page: &'a mut ObjectPage<'a>);
|
||||
}
|
||||
|
||||
impl<'a> PageProvider<'a> for Pager {
|
||||
/// Allocates a new ObjectPage from the system.
|
||||
///
|
||||
/// Uses `mmap` to map a page and casts it to a ObjectPage.
|
||||
fn allocate_page(&mut self) -> Option<&'a mut ObjectPage<'a>> {
|
||||
self.alloc_page(OBJECT_PAGE_SIZE)
|
||||
.map(|r| unsafe { transmute(r as usize) })
|
||||
}
|
||||
|
||||
/// Release a ObjectPage back to the system.slab_page
|
||||
///
|
||||
/// Uses `munmap` to release the page back to the OS.
|
||||
fn release_page(&mut self, p: &'a mut ObjectPage<'a>) {
|
||||
self.dealloc_page(p as *const ObjectPage as *mut u8, OBJECT_PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_size() {
|
||||
assert_eq!(
|
||||
OBJECT_PAGE_SIZE as usize,
|
||||
size_of::<ObjectPage>(),
|
||||
"ObjectPage should be exactly the size of a single page."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mmap_allocator() {
|
||||
let mut mmap = Pager::new();
|
||||
|
||||
match mmap.allocate_page() {
|
||||
Some(sp) => {
|
||||
sp.bitfield.initialize(8, OBJECT_PAGE_SIZE - 80);
|
||||
assert!(!sp.is_full(), "Got empty slab");
|
||||
assert!(sp.is_empty(6 * 64), "Got empty slab");
|
||||
mmap.release_page(sp)
|
||||
}
|
||||
None => panic!("failed to allocate ObjectPage"),
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! test_sc_allocation {
|
||||
($test:ident, $size:expr, $alignment:expr, $allocations:expr, $type:ty) => {
|
||||
#[test]
|
||||
fn $test() {
|
||||
let _ = env_logger::try_init();
|
||||
let mut mmap = Pager::new();
|
||||
{
|
||||
let mut sa: SCAllocator<$type> = SCAllocator::new($size);
|
||||
let alignment = $alignment;
|
||||
|
||||
let mut objects: Vec<NonNull<u8>> = Vec::new();
|
||||
let mut vec: Vec<(usize, &mut [usize; $size / 8])> = Vec::new();
|
||||
let layout = Layout::from_size_align($size, alignment).unwrap();
|
||||
|
||||
for _ in 0..$allocations {
|
||||
loop {
|
||||
match sa.allocate(layout) {
|
||||
// Allocation was successful
|
||||
Ok(nptr) => {
|
||||
unsafe {
|
||||
vec.push((rand::random::<usize>(), transmute(nptr.as_ptr())))
|
||||
};
|
||||
objects.push(nptr);
|
||||
break;
|
||||
}
|
||||
// Couldn't allocate need to refill first
|
||||
Err(AllocationError::OutOfMemory) => {
|
||||
let page = mmap.allocate_page().unwrap();
|
||||
unsafe {
|
||||
sa.refill(page);
|
||||
}
|
||||
}
|
||||
// Unexpected errors
|
||||
Err(AllocationError::InvalidLayout) => unreachable!("Unexpected error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write the objects with a random pattern
|
||||
for item in vec.iter_mut() {
|
||||
let (pattern, ref mut obj) = *item;
|
||||
assert!(obj.len() == $size / 8);
|
||||
for i in 0..obj.len() {
|
||||
obj[i] = pattern;
|
||||
}
|
||||
}
|
||||
|
||||
for item in vec.iter() {
|
||||
let (pattern, ref obj) = *item;
|
||||
for i in 0..obj.len() {
|
||||
assert_eq!(
|
||||
obj[i], pattern,
|
||||
"No two allocations point to the same memory."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we can correctly deallocate:
|
||||
let pages_allocated = sa.slabs.elements;
|
||||
|
||||
// Deallocate all the objects
|
||||
for item in objects.iter_mut() {
|
||||
unsafe {
|
||||
sa.deallocate(*item, layout).expect("Can't deallocate");
|
||||
}
|
||||
}
|
||||
|
||||
objects.clear();
|
||||
sa.check_page_assignments();
|
||||
|
||||
// then allocate everything again,
|
||||
for _ in 0..$allocations {
|
||||
loop {
|
||||
match sa.allocate(layout) {
|
||||
// Allocation was successful
|
||||
Ok(nptr) => {
|
||||
unsafe {
|
||||
vec.push((rand::random::<usize>(), transmute(nptr.as_ptr())))
|
||||
};
|
||||
objects.push(nptr);
|
||||
break;
|
||||
}
|
||||
// Couldn't allocate need to refill first
|
||||
Err(AllocationError::OutOfMemory) => {
|
||||
let page = mmap.allocate_page().unwrap();
|
||||
unsafe {
|
||||
sa.refill(page);
|
||||
}
|
||||
}
|
||||
// Unexpected errors
|
||||
Err(AllocationError::InvalidLayout) => unreachable!("Unexpected error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// and make sure we do not request more pages than what we had previously
|
||||
// println!("{} {}", pages_allocated, sa.slabs.elements);
|
||||
assert_eq!(
|
||||
pages_allocated, sa.slabs.elements,
|
||||
"Did not use more memory for 2nd allocation run."
|
||||
);
|
||||
|
||||
// Deallocate everything once more
|
||||
for item in objects.iter_mut() {
|
||||
unsafe {
|
||||
sa.deallocate(*item, layout).expect("Can't deallocate");
|
||||
}
|
||||
}
|
||||
|
||||
// Drain the slab-allocator and give unused pages back to the OS
|
||||
sa.try_reclaim_pages(usize::MAX, &mut |p: *mut ObjectPage| unsafe {
|
||||
mmap.release_page(&mut *p)
|
||||
});
|
||||
}
|
||||
|
||||
// Check that we released everything to our page allocator:
|
||||
assert_eq!(
|
||||
mmap.currently_allocated(),
|
||||
0,
|
||||
"Released all pages to the underlying memory manager."
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test_sc_allocation!(op_512_size8_alignment1, 8, 1, 512, ObjectPage);
|
||||
test_sc_allocation!(op_4096_size8_alignment8, 8, 8, 4096, ObjectPage);
|
||||
test_sc_allocation!(op_500_size8_alignment64, 8, 64, 500, ObjectPage);
|
||||
test_sc_allocation!(op_4096_size12_alignment1, 12, 1, 4096, ObjectPage);
|
||||
test_sc_allocation!(op_4096_size13_alignment1, 13, 1, 4096, ObjectPage);
|
||||
test_sc_allocation!(op_2000_size14_alignment1, 14, 1, 2000, ObjectPage);
|
||||
test_sc_allocation!(op_4096_size15_alignment1, 15, 1, 4096, ObjectPage);
|
||||
test_sc_allocation!(op_8000_size16_alignment1, 16, 1, 8000, ObjectPage);
|
||||
test_sc_allocation!(op_1024_size24_alignment1, 24, 1, 1024, ObjectPage);
|
||||
test_sc_allocation!(op_3090_size32_alignment1, 32, 1, 3090, ObjectPage);
|
||||
test_sc_allocation!(op_4096_size64_alignment1, 64, 1, 4096, ObjectPage);
|
||||
test_sc_allocation!(op_1000_size512_alignment1, 512, 1, 1000, ObjectPage);
|
||||
test_sc_allocation!(op_4096_size1024_alignment1, 1024, 1, 4096, ObjectPage);
|
||||
test_sc_allocation!(op_10_size2048_alignment1, 2048, 1, 10, ObjectPage);
|
||||
test_sc_allocation!(op_10000_size512_alignment1, 512, 1, 10000, ObjectPage);
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn invalid_alignment() {
|
||||
let _layout = Layout::from_size_align(10, 3).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_readme() -> Result<(), AllocationError> {
|
||||
let object_size = 12;
|
||||
let alignment = 4;
|
||||
let layout = Layout::from_size_align(object_size, alignment).unwrap();
|
||||
|
||||
// We need something that can provide backing memory
|
||||
// (4 KiB and 2 MiB pages) to our ZoneAllocator
|
||||
// (see tests.rs for a dummy implementation).
|
||||
let mut pager = Pager::new();
|
||||
let page = pager.allocate_page().expect("Can't allocate a page");
|
||||
|
||||
let mut zone: ZoneAllocator = Default::default();
|
||||
// Prematurely fill the ZoneAllocator with memory.
|
||||
// Alternatively, the allocate call would return an
|
||||
// error which we can capture to refill on-demand.
|
||||
unsafe { zone.refill(layout, page)? };
|
||||
|
||||
let allocated = zone.allocate(layout)?;
|
||||
unsafe { zone.deallocate(allocated, layout, &SlabCallback) }?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_readme2() -> Result<(), AllocationError> {
|
||||
let object_size = 10;
|
||||
let alignment = 8;
|
||||
let layout = Layout::from_size_align(object_size, alignment).unwrap();
|
||||
|
||||
// We need something that can provide backing memory
|
||||
// (4 KiB and 2 MiB pages) to our ZoneAllocator
|
||||
// (see tests.rs for a dummy implementation).
|
||||
let mut pager = Pager::new();
|
||||
let page = pager.allocate_page().expect("Can't allocate a page");
|
||||
|
||||
let mut sa: SCAllocator<ObjectPage> = SCAllocator::new(object_size);
|
||||
// Prematurely fill the SCAllocator with memory.
|
||||
// Alternatively, the allocate call would return an
|
||||
// error which we can capture to refill on-demand.
|
||||
unsafe { sa.refill(page) };
|
||||
|
||||
sa.allocate(layout)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bug1() -> Result<(), AllocationError> {
|
||||
let _ = env_logger::try_init();
|
||||
|
||||
let mut mmap = Pager::new();
|
||||
let page = mmap.allocate_page();
|
||||
|
||||
let mut sa: SCAllocator<ObjectPage> = SCAllocator::new(8);
|
||||
unsafe {
|
||||
sa.refill(page.unwrap());
|
||||
}
|
||||
|
||||
let ptr1 = sa.allocate(Layout::from_size_align(1, 1).unwrap())?;
|
||||
let ptr2 = sa.allocate(Layout::from_size_align(2, 1).unwrap())?;
|
||||
unsafe { sa.deallocate(ptr1, Layout::from_size_align(1, 1).unwrap()) }?;
|
||||
let _ptr3 = sa.allocate(Layout::from_size_align(4, 1).unwrap())?;
|
||||
unsafe {
|
||||
sa.deallocate(ptr2, Layout::from_size_align(2, 1).unwrap())
|
||||
.map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn slabmalloc_allocate_deallocate(b: &mut Bencher) {
|
||||
let _ = env_logger::try_init();
|
||||
|
||||
let mut mmap = Pager::new();
|
||||
let mut sa: SCAllocator<ObjectPage> = SCAllocator::new(8);
|
||||
let layout = Layout::from_size_align(8, 1).unwrap();
|
||||
|
||||
let page = mmap.allocate_page();
|
||||
unsafe {
|
||||
sa.refill(page.unwrap());
|
||||
}
|
||||
|
||||
let ptr = sa.allocate(layout).expect("Can't allocate");
|
||||
test::black_box(ptr);
|
||||
b.iter(|| {
|
||||
let ptr = sa.allocate(layout).expect("Can't allocate");
|
||||
test::black_box(ptr);
|
||||
unsafe { sa.deallocate(ptr, layout).expect("Can't deallocate") };
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn slabmalloc_allocate_deallocate_big(b: &mut Bencher) {
|
||||
let _ = env_logger::try_init();
|
||||
|
||||
let mut mmap = Pager::new();
|
||||
let mut sa: SCAllocator<ObjectPage> = SCAllocator::new(512);
|
||||
|
||||
let page = mmap.allocate_page();
|
||||
unsafe {
|
||||
sa.refill(page.unwrap());
|
||||
}
|
||||
|
||||
let layout = Layout::from_size_align(512, 1).unwrap();
|
||||
let ptr = sa.allocate(layout).expect("Can't allocate");
|
||||
test::black_box(ptr);
|
||||
|
||||
b.iter(|| {
|
||||
let ptr = sa.allocate(layout).expect("Can't allocate");
|
||||
test::black_box(ptr);
|
||||
unsafe { sa.deallocate(ptr, layout).expect("Can't deallocate") };
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn jemalloc_allocate_deallocate(b: &mut Bencher) {
|
||||
let layout = Layout::from_size_align(8, 1).unwrap();
|
||||
let ptr = unsafe { alloc::alloc(layout) };
|
||||
test::black_box(ptr);
|
||||
|
||||
b.iter(|| unsafe {
|
||||
let ptr = alloc::alloc(layout);
|
||||
test::black_box(ptr);
|
||||
alloc::dealloc(ptr, layout);
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn jemalloc_allocate_deallocate_big(b: &mut Bencher) {
|
||||
let layout = Layout::from_size_align(512, 1).unwrap();
|
||||
let ptr = unsafe { alloc::alloc(layout) };
|
||||
test::black_box(ptr);
|
||||
|
||||
b.iter(|| unsafe {
|
||||
let ptr = alloc::alloc(layout);
|
||||
test::black_box(ptr);
|
||||
alloc::dealloc(ptr, layout);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn check_first_fit() {
|
||||
let op: ObjectPage = Default::default();
|
||||
let layout = Layout::from_size_align(8, 8).unwrap();
|
||||
println!("{:?}", op.first_fit(layout));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_pop() {
|
||||
let mut op1: ObjectPage = Default::default();
|
||||
let op1_ptr = &op1 as *const ObjectPage<'_>;
|
||||
let mut op2: ObjectPage = Default::default();
|
||||
let op2_ptr = &op2 as *const ObjectPage<'_>;
|
||||
let mut op3: ObjectPage = Default::default();
|
||||
let op3_ptr = &op3 as *const ObjectPage<'_>;
|
||||
let mut op4: ObjectPage = Default::default();
|
||||
let op4_ptr = &op4 as *const ObjectPage<'_>;
|
||||
|
||||
let mut list: PageList<ObjectPage> = PageList::new();
|
||||
list.insert_front(&mut op1);
|
||||
list.insert_front(&mut op2);
|
||||
list.insert_front(&mut op3);
|
||||
|
||||
assert!(list.contains(op1_ptr));
|
||||
assert!(list.contains(op2_ptr));
|
||||
assert!(list.contains(op3_ptr));
|
||||
assert!(!list.contains(op4_ptr));
|
||||
|
||||
let popped = list.pop();
|
||||
assert_eq!(popped.unwrap() as *const ObjectPage, op3_ptr);
|
||||
assert!(!list.contains(op3_ptr));
|
||||
|
||||
let popped = list.pop();
|
||||
assert_eq!(popped.unwrap() as *const ObjectPage, op2_ptr);
|
||||
assert!(!list.contains(op2_ptr));
|
||||
|
||||
list.insert_front(&mut op4);
|
||||
assert!(list.contains(op4_ptr));
|
||||
let popped = list.pop();
|
||||
assert_eq!(popped.unwrap() as *const ObjectPage, op4_ptr);
|
||||
assert!(!list.contains(op4_ptr));
|
||||
|
||||
let popped = list.pop();
|
||||
assert_eq!(popped.unwrap() as *const ObjectPage, op1_ptr);
|
||||
assert!(!list.contains(op1_ptr));
|
||||
|
||||
let popped = list.pop();
|
||||
assert!(popped.is_none());
|
||||
|
||||
assert!(!list.contains(op1_ptr));
|
||||
assert!(!list.contains(op2_ptr));
|
||||
assert!(!list.contains(op3_ptr));
|
||||
assert!(!list.contains(op4_ptr));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn iter_empty_list() {
|
||||
let mut new_head1: ObjectPage = Default::default();
|
||||
let mut l = PageList::new();
|
||||
l.insert_front(&mut new_head1);
|
||||
for _p in l.iter_mut() {}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn check_is_full_8() {
|
||||
let _r = env_logger::try_init();
|
||||
let layout = Layout::from_size_align(8, 1).unwrap();
|
||||
|
||||
let mut page: ObjectPage = Default::default();
|
||||
page.bitfield.initialize(8, OBJECT_PAGE_SIZE - 80);
|
||||
let obj_per_page = core::cmp::min((OBJECT_PAGE_SIZE - 80) / 8, 8 * 64);
|
||||
|
||||
let mut allocs = 0;
|
||||
loop {
|
||||
if page.allocate(layout).is_null() {
|
||||
break;
|
||||
}
|
||||
allocs += 1;
|
||||
|
||||
if allocs < obj_per_page {
|
||||
assert!(
|
||||
!page.is_full(),
|
||||
"Page mistakenly considered full after {} allocs",
|
||||
allocs
|
||||
);
|
||||
assert!(!page.is_empty(obj_per_page));
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(allocs, obj_per_page, "Can use all bitmap space");
|
||||
assert!(page.is_full());
|
||||
}
|
||||
|
||||
// Test for bug that reports pages not as full when
|
||||
// the entire bitfield wasn't allocated.
|
||||
#[test]
|
||||
pub fn check_is_full_512() {
|
||||
let _r = env_logger::try_init();
|
||||
let mut page: ObjectPage = Default::default();
|
||||
page.bitfield.initialize(512, OBJECT_PAGE_SIZE - 80);
|
||||
let layout = Layout::from_size_align(512, 1).unwrap();
|
||||
let obj_per_page = core::cmp::min((OBJECT_PAGE_SIZE - 80) / 512, 6 * 64);
|
||||
|
||||
let mut allocs = 0;
|
||||
loop {
|
||||
if page.allocate(layout).is_null() {
|
||||
break;
|
||||
}
|
||||
|
||||
allocs += 1;
|
||||
|
||||
if allocs < (OBJECT_PAGE_SIZE - 80) / 512 {
|
||||
assert!(!page.is_full());
|
||||
assert!(!page.is_empty(obj_per_page));
|
||||
}
|
||||
}
|
||||
assert!(page.is_full());
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn issue_9() -> Result<(), AllocationError> {
|
||||
let mut pager = Pager::new();
|
||||
let mut zone: ZoneAllocator = Default::default();
|
||||
|
||||
// size: 256 align: 1 | my pager gets called
|
||||
let l1 = Layout::from_size_align(256, 1).unwrap();
|
||||
assert!(zone.allocate(l1).is_err(), "my pager gets called");
|
||||
let page = pager.allocate_page().expect("Can't allocate a page");
|
||||
unsafe { zone.refill(l1, page)? };
|
||||
let p1 = zone.allocate(l1)?;
|
||||
|
||||
// size: 48 align: 8 | my pager gets called
|
||||
let l2 = Layout::from_size_align(48, 8).unwrap();
|
||||
assert!(zone.allocate(l2).is_err(), "my pager gets called");
|
||||
let page = pager.allocate_page().expect("Can't allocate a page");
|
||||
unsafe { zone.refill(l2, page)? };
|
||||
let p2 = zone.allocate(l2)?;
|
||||
assert_eq!(p2.as_ptr() as usize % l2.align(), 0);
|
||||
assert_ne!(p2, p1);
|
||||
|
||||
// size: 6 align: 1 | my pager gets called and returns the properly aligned address X
|
||||
let l3 = Layout::from_size_align(6, 1).unwrap();
|
||||
assert!(
|
||||
zone.allocate(l3).is_err(),
|
||||
"my pager gets called and returns the properly aligned address X"
|
||||
);
|
||||
let page = pager.allocate_page().expect("Can't allocate a page");
|
||||
unsafe { zone.refill(l3, page)? };
|
||||
let p3 = zone.allocate(l3)?;
|
||||
assert_eq!(p3.as_ptr() as usize % l3.align(), 0);
|
||||
assert_ne!(p3, p2);
|
||||
assert_ne!(p3, p1);
|
||||
|
||||
//size: 8 align: 1 | my pager doesn't get called
|
||||
let l4 = Layout::from_size_align(8, 1).unwrap();
|
||||
// my pager doesn't get called
|
||||
let p4 = zone.allocate(l4)?;
|
||||
assert_eq!(p4.as_ptr() as usize % l4.align(), 0);
|
||||
assert_ne!(p4, p3);
|
||||
assert_ne!(p4, p2);
|
||||
assert_ne!(p4, p1);
|
||||
|
||||
// size: 16 align: 1 | my pager gets called
|
||||
let l5 = Layout::from_size_align(16, 1).unwrap();
|
||||
assert!(zone.allocate(l5).is_err(), "my pager gets called");
|
||||
let page = pager.allocate_page().expect("Can't allocate a page");
|
||||
unsafe { zone.refill(l5, page)? };
|
||||
let p5 = zone.allocate(l5)?;
|
||||
assert_eq!(p5.as_ptr() as usize % l5.align(), 0);
|
||||
assert_ne!(p5, p1);
|
||||
assert_ne!(p5, p2);
|
||||
assert_ne!(p5, p3);
|
||||
assert_ne!(p5, p4);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 归还slab_page给buddy的回调
|
||||
struct SlabCallback;
|
||||
impl CallBack for SlabCallback {
|
||||
unsafe fn free_slab_page(&self, base_addr: *mut u8, size: usize) {
|
||||
assert_eq!(base_addr as usize & (OBJECT_PAGE_SIZE - 1), 0); // 确认地址4k对齐
|
||||
assert_eq!(size, OBJECT_PAGE_SIZE); // 确认释放的slab_page大小
|
||||
}
|
||||
}
|
@ -120,6 +120,7 @@ impl<'a> ZoneAllocator<'a> {
|
||||
// reclaim的page数
|
||||
let just_reclaimed = slab.try_reclaim_pages(to_reclaim, &mut dealloc);
|
||||
self.total -= (just_reclaimed * OBJECT_PAGE_SIZE) as u64;
|
||||
|
||||
to_reclaim = to_reclaim.saturating_sub(just_reclaimed);
|
||||
if to_reclaim == 0 {
|
||||
break;
|
||||
@ -177,7 +178,20 @@ unsafe impl<'a> crate::Allocator<'a> for ZoneAllocator<'a> {
|
||||
slab_callback: &'static dyn CallBack,
|
||||
) -> Result<(), AllocationError> {
|
||||
match ZoneAllocator::get_slab(layout.size()) {
|
||||
Slab::Base(idx) => self.small_slabs[idx].deallocate(ptr, layout, slab_callback),
|
||||
Slab::Base(idx) => {
|
||||
let r = self.small_slabs[idx].deallocate(ptr, layout);
|
||||
if let Ok(true) = r {
|
||||
self.small_slabs[idx].try_reclaim_pages(
|
||||
1,
|
||||
&mut |slab_page: *mut ObjectPage| {
|
||||
// 将slab_page归还buddy
|
||||
slab_callback
|
||||
.free_slab_page(slab_page as *const _ as *mut u8, ObjectPage::SIZE);
|
||||
},
|
||||
);
|
||||
}
|
||||
r.map(|_| ())
|
||||
}
|
||||
Slab::Unsupported => Err(AllocationError::InvalidLayout),
|
||||
}
|
||||
}
|
||||
|
@ -1,111 +0,0 @@
|
||||
use crate::arch::kvm::vmx::vmcs::VmcsFields;
|
||||
use crate::arch::kvm::vmx::vmx_asm_wrapper::{vmx_vmlaunch, vmx_vmread};
|
||||
use crate::libs::mutex::Mutex;
|
||||
use crate::virt::kvm::vm;
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use core::arch::asm;
|
||||
use log::{debug, error};
|
||||
use raw_cpuid::CpuId;
|
||||
use system_error::SystemError;
|
||||
// use crate::virt::kvm::guest_code;
|
||||
use self::vmx::mmu::{kvm_mmu_setup, kvm_vcpu_mtrr_init};
|
||||
use self::vmx::vcpu::VmxVcpu;
|
||||
pub mod vmx;
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct X86_64KVMArch {
|
||||
// n_used_mmu_pages: u32,
|
||||
// n_requested_mmu_pages: u32,
|
||||
// n_max_mmu_pages: u32,
|
||||
// mmu_valid_gen: u64,
|
||||
// // mmu_page_hash:[],
|
||||
// active_mmu_pages: LinkedList<KvmMmuPage>, // 所有分配的mmu page都挂到active_mmu_pages上
|
||||
// zapped_obsolete_pages: LinkedList<KvmMmuPage>, // 释放的mmu page都挂到zapped_obsolete_pages上,一个全局的invalid_list
|
||||
}
|
||||
|
||||
impl X86_64KVMArch {
|
||||
/// @brief 查看CPU是否支持虚拟化
|
||||
pub fn kvm_arch_cpu_supports_vm() -> Result<(), SystemError> {
|
||||
let cpuid = CpuId::new();
|
||||
// Check to see if CPU is Intel (“GenuineIntel”).
|
||||
if let Some(vi) = cpuid.get_vendor_info() {
|
||||
if vi.as_str() != "GenuineIntel" {
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
}
|
||||
// Check processor supports for Virtual Machine Extension (VMX) technology
|
||||
// CPUID.1:ECX.VMX[bit 5] = 1 (Intel Manual: 24.6 Discovering Support for VMX)
|
||||
if let Some(fi) = cpuid.get_feature_info() {
|
||||
if !fi.has_vmx() {
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// @brief 初始化KVM
|
||||
pub fn kvm_arch_init() -> Result<(), SystemError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[deny(clippy::match_single_binding)]
|
||||
pub fn kvm_arch_dev_ioctl(cmd: u32, _arg: usize) -> Result<usize, SystemError> {
|
||||
error!("unknown kvm ioctl cmd: {}", cmd);
|
||||
return Err(SystemError::EINVAL);
|
||||
}
|
||||
|
||||
pub fn kvm_arch_vcpu_create(id: u32) -> Result<Arc<Mutex<VmxVcpu>>, SystemError> {
|
||||
// let guest_rip = current_kvm.lock().memslots[0].memslots[0].userspace_addr;
|
||||
let vcpu = VmxVcpu::new(id, vm(0).unwrap()).unwrap();
|
||||
return Ok(Arc::new(Mutex::new(vcpu)));
|
||||
}
|
||||
|
||||
pub fn kvm_arch_vcpu_setup(vcpu: &Mutex<VmxVcpu>) -> Result<(), SystemError> {
|
||||
kvm_vcpu_mtrr_init(vcpu)?;
|
||||
kvm_mmu_setup(vcpu);
|
||||
Ok(())
|
||||
}
|
||||
pub fn kvm_arch_vcpu_ioctl_run(_vcpu: &Mutex<VmxVcpu>) -> Result<(), SystemError> {
|
||||
match vmx_vmlaunch() {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
let vmx_err = vmx_vmread(VmcsFields::VMEXIT_INSTR_ERR as u32).unwrap();
|
||||
debug!("vmlaunch failed: {:?}", vmx_err);
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// pub fn kvm_arch_create_memslot(_slot: &mut KvmMemorySlot, _npages: u64) {
|
||||
|
||||
// }
|
||||
|
||||
// pub fn kvm_arch_commit_memory_region(
|
||||
// _mem: &KvmUserspaceMemoryRegion,
|
||||
// _new_slot: &KvmMemorySlot,
|
||||
// _old_slot: &KvmMemorySlot,
|
||||
// _change: KvmMemoryChange) {
|
||||
// // let kvm = KVM();
|
||||
// // let mut num_mmu_pages = 0;
|
||||
// // if kvm.lock().arch.n_requested_mmu_pages == 0{
|
||||
// // num_mmu_pages = kvm_mmu_calculate_mmu_pages();
|
||||
// // }
|
||||
// // if num_mmu_pages != 0 {
|
||||
// // // kvm_mmu_change_mmu_pages(num_mmu_pages);
|
||||
// // }
|
||||
// }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn guest_code() {
|
||||
debug!("guest_code");
|
||||
loop {
|
||||
unsafe {
|
||||
asm!("mov rax, 0", "mov rcx, 0", "cpuid");
|
||||
}
|
||||
unsafe { asm!("nop") };
|
||||
debug!("guest_code");
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
use crate::arch::mm::LockedFrameAllocator;
|
||||
use crate::arch::mm::PageMapper;
|
||||
use crate::arch::MMArch;
|
||||
use crate::mm::page::EntryFlags;
|
||||
use crate::mm::{PageTableKind, PhysAddr, VirtAddr};
|
||||
use crate::smp::core::smp_get_processor_id;
|
||||
use crate::smp::cpu::AtomicProcessorId;
|
||||
use crate::smp::cpu::ProcessorId;
|
||||
use core::sync::atomic::{compiler_fence, AtomicUsize, Ordering};
|
||||
use system_error::SystemError;
|
||||
use x86::msr;
|
||||
|
||||
/// Check if MTRR is supported
|
||||
pub fn check_ept_features() -> Result<(), SystemError> {
|
||||
const MTRR_ENABLE_BIT: u64 = 1 << 11;
|
||||
let ia32_mtrr_def_type = unsafe { msr::rdmsr(msr::IA32_MTRR_DEF_TYPE) };
|
||||
if (ia32_mtrr_def_type & MTRR_ENABLE_BIT) == 0 {
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// pub fn ept_build_mtrr_map() -> Result<(), SystemError> {
|
||||
// let ia32_mtrr_cap = unsafe { msr::rdmsr(msr::IA32_MTRRCAP) };
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
/// 标志当前没有处理器持有内核映射器的锁
|
||||
/// 之所以需要这个标志,是因为AtomicUsize::new(0)会把0当作一个处理器的id
|
||||
const EPT_MAPPER_NO_PROCESSOR: ProcessorId = ProcessorId::INVALID;
|
||||
/// 当前持有内核映射器锁的处理器
|
||||
static EPT_MAPPER_LOCK_OWNER: AtomicProcessorId = AtomicProcessorId::new(EPT_MAPPER_NO_PROCESSOR);
|
||||
/// 内核映射器的锁计数器
|
||||
static EPT_MAPPER_LOCK_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub struct EptMapper {
|
||||
/// EPT页表映射器
|
||||
mapper: PageMapper,
|
||||
/// 标记当前映射器是否为只读
|
||||
readonly: bool,
|
||||
// EPT页表根地址
|
||||
// root_hpa: PhysAddr,
|
||||
}
|
||||
|
||||
impl EptMapper {
|
||||
fn lock_cpu(cpuid: ProcessorId, mapper: PageMapper) -> Self {
|
||||
loop {
|
||||
match EPT_MAPPER_LOCK_OWNER.compare_exchange_weak(
|
||||
EPT_MAPPER_NO_PROCESSOR,
|
||||
cpuid,
|
||||
Ordering::Acquire,
|
||||
Ordering::Relaxed,
|
||||
) {
|
||||
Ok(_) => break,
|
||||
// 当前处理器已经持有了锁
|
||||
Err(id) if id == cpuid => break,
|
||||
// either CAS failed, or some other hardware thread holds the lock
|
||||
Err(_) => core::hint::spin_loop(),
|
||||
}
|
||||
}
|
||||
|
||||
let prev_count = EPT_MAPPER_LOCK_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||
compiler_fence(Ordering::Acquire);
|
||||
|
||||
// 本地核心已经持有过锁,因此标记当前加锁获得的映射器为只读
|
||||
let readonly = prev_count > 0;
|
||||
|
||||
return Self { mapper, readonly };
|
||||
}
|
||||
|
||||
/// @brief 锁定内核映射器, 并返回一个内核映射器对象
|
||||
#[inline(always)]
|
||||
pub fn lock() -> Self {
|
||||
let cpuid = smp_get_processor_id();
|
||||
let mapper = unsafe { PageMapper::current(PageTableKind::EPT, LockedFrameAllocator) };
|
||||
return Self::lock_cpu(cpuid, mapper);
|
||||
}
|
||||
|
||||
/// 映射guest physical addr(gpa)到指定的host physical addr(hpa)。
|
||||
///
|
||||
/// ## 参数
|
||||
///
|
||||
/// - `gpa`: 要映射的guest physical addr
|
||||
/// - `hpa`: 要映射的host physical addr
|
||||
/// - `flags`: 页面标志
|
||||
///
|
||||
/// ## 返回
|
||||
///
|
||||
/// - 成功:返回Ok(())
|
||||
/// - 失败: 如果当前映射器为只读,则返回EAGAIN_OR_EWOULDBLOCK
|
||||
pub unsafe fn walk(
|
||||
&mut self,
|
||||
gpa: u64,
|
||||
hpa: u64,
|
||||
flags: EntryFlags<MMArch>,
|
||||
) -> Result<(), SystemError> {
|
||||
if self.readonly {
|
||||
return Err(SystemError::EAGAIN_OR_EWOULDBLOCK);
|
||||
}
|
||||
self.mapper
|
||||
.map_phys(
|
||||
VirtAddr::new(gpa as usize),
|
||||
PhysAddr::new(hpa as usize),
|
||||
flags,
|
||||
)
|
||||
.unwrap()
|
||||
.flush();
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// fn get_ept_index(addr: u64, level: usize) -> u64 {
|
||||
// let pt64_level_shift = PAGE_SHIFT + (level - 1) * PT64_LEVEL_BITS;
|
||||
// (addr >> pt64_level_shift) & ((1 << PT64_LEVEL_BITS) - 1)
|
||||
// }
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
// pub struct X86Exception {
|
||||
// vector: u8,
|
||||
// error_code_valid: bool,
|
||||
// error_code: u16,
|
||||
// // bool nested_page_fault;
|
||||
// address: u64, /* cr2 or nested page fault gpa */
|
||||
// }
|
@ -1,248 +0,0 @@
|
||||
use crate::{
|
||||
arch::kvm::vmx::ept::EptMapper,
|
||||
libs::mutex::Mutex,
|
||||
mm::{page::EntryFlags, syscall::ProtFlags},
|
||||
virt::kvm::host_mem::{__gfn_to_pfn, kvm_vcpu_gfn_to_memslot, PAGE_MASK, PAGE_SHIFT},
|
||||
};
|
||||
use bitfield_struct::bitfield;
|
||||
use log::debug;
|
||||
use system_error::SystemError;
|
||||
|
||||
use super::{
|
||||
ept::check_ept_features,
|
||||
vcpu::VmxVcpu,
|
||||
vmcs::VmcsFields,
|
||||
vmx_asm_wrapper::{vmx_vmread, vmx_vmwrite},
|
||||
};
|
||||
use crate::arch::kvm::vmx::mmu::VmcsFields::CTRL_EPTP_PTR;
|
||||
|
||||
// pub const PT64_ROOT_LEVEL: u32 = 4;
|
||||
// pub const PT32_ROOT_LEVEL: u32 = 2;
|
||||
// pub const PT32E_ROOT_LEVEL: u32 = 3;
|
||||
|
||||
// pub struct KvmMmuPage{
|
||||
// gfn: u64, // 管理地址范围的起始地址对应的 gfn
|
||||
// role: KvmMmuPageRole, // 基本信息,包括硬件特性和所属层级等
|
||||
// // spt: *mut u64, // spt: shadow page table,指向 struct page 的地址,其包含了所有页表项 (pte)。同时 page->private 会指向该 kvm_mmu_page
|
||||
// }
|
||||
|
||||
#[bitfield(u32)]
|
||||
pub struct KvmMmuPageRole {
|
||||
#[bits(4)]
|
||||
level: usize, // 页所处的层级
|
||||
cr4_pae: bool, // cr4.pae,1 表示使用 64bit gpte
|
||||
#[bits(2)]
|
||||
quadrant: usize, // 如果 cr4.pae=0,则 gpte 为 32bit,但 spte 为 64bit,因此需要用多个 spte 来表示一个 gpte,该字段指示是 gpte 的第几块
|
||||
direct: bool,
|
||||
#[bits(3)]
|
||||
access: usize, // 访问权限
|
||||
invalid: bool, // 失效,一旦 unpin 就会被销毁
|
||||
nxe: bool, // efer.nxe,不可执行
|
||||
cr0_wp: bool, // cr0.wp, 写保护
|
||||
smep_andnot_wp: bool, // smep && !cr0.wp,SMEP启用,用户模式代码将无法执行位于内核地址空间中的指令。
|
||||
smap_andnot_wp: bool, // smap && !cr0.wp
|
||||
#[bits(8)]
|
||||
unused: usize,
|
||||
#[bits(8)]
|
||||
smm: usize, // 1 表示处于 system management mode, 0 表示非 SMM
|
||||
}
|
||||
|
||||
// We don't want allocation failures within the mmu code, so we preallocate
|
||||
// enough memory for a single page fault in a cache.
|
||||
// pub struct KvmMmuMemoryCache {
|
||||
// num_objs: u32,
|
||||
// objs: [*mut u8; KVM_NR_MEM_OBJS as usize],
|
||||
// }
|
||||
pub type KvmMmuPageFaultHandler =
|
||||
fn(vcpu: &mut VmxVcpu, gpa: u64, error_code: u32, prefault: bool) -> Result<(), SystemError>;
|
||||
#[derive(Default)]
|
||||
pub struct KvmMmu {
|
||||
pub root_hpa: u64,
|
||||
pub root_level: u32,
|
||||
pub base_role: KvmMmuPageRole,
|
||||
// ...还有一些变量不知道用来做什么
|
||||
pub get_cr3: Option<fn(&VmxVcpu) -> u64>,
|
||||
pub set_eptp: Option<fn(u64) -> Result<(), SystemError>>,
|
||||
pub page_fault: Option<KvmMmuPageFaultHandler>,
|
||||
// get_pdptr: Option<fn(& VmxVcpu, index:u32) -> u64>, // Page Directory Pointer Table Register?暂时不知道和CR3的区别是什么
|
||||
// inject_page_fault: Option<fn(&mut VmxVcpu, fault: &X86Exception)>,
|
||||
// gva_to_gpa: Option<fn(&mut VmxVcpu, gva: u64, access: u32, exception: &X86Exception) -> u64>,
|
||||
// translate_gpa: Option<fn(&mut VmxVcpu, gpa: u64, access: u32, exception: &X86Exception) -> u64>,
|
||||
// sync_page: Option<fn(&mut VmxVcpu, &mut KvmMmuPage)>,
|
||||
// invlpg: Option<fn(&mut VmxVcpu, gva: u64)>, // invalid entry
|
||||
// update_pte: Option<fn(&mut VmxVcpu, sp: &KvmMmuPage, spte: u64, pte: u64)>,
|
||||
}
|
||||
|
||||
impl core::fmt::Debug for KvmMmu {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("KvmMmu")
|
||||
.field("root_hpa", &self.root_hpa)
|
||||
.field("root_level", &self.root_level)
|
||||
.field("base_role", &self.base_role)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
fn tdp_get_cr3(_vcpu: &VmxVcpu) -> u64 {
|
||||
let guest_cr3 = vmx_vmread(VmcsFields::GUEST_CR3 as u32).expect("Failed to read eptp");
|
||||
return guest_cr3;
|
||||
}
|
||||
|
||||
pub fn tdp_set_eptp(root_hpa: u64) -> Result<(), SystemError> {
|
||||
// 设置权限位,目前是写死的,可读可写可执行
|
||||
// EPT paging-structure memory type: Uncacheable
|
||||
let mut eptp = 0x0_u64;
|
||||
// This value is 1 less than the EPT page-walk length. 3 means 4-level paging.
|
||||
eptp |= 0x3 << 3;
|
||||
eptp |= root_hpa & (PAGE_MASK as u64);
|
||||
vmx_vmwrite(CTRL_EPTP_PTR as u32, eptp)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn tdp_page_fault(
|
||||
vcpu: &mut VmxVcpu,
|
||||
gpa: u64,
|
||||
error_code: u32,
|
||||
prefault: bool,
|
||||
) -> Result<(), SystemError> {
|
||||
debug!("tdp_page_fault");
|
||||
let gfn = gpa >> PAGE_SHIFT; // 物理地址右移12位得到物理页框号(相对于虚拟机而言)
|
||||
// 分配缓存池,为了避免在运行时分配空间失败,这里提前分配/填充足额的空间
|
||||
mmu_topup_memory_caches(vcpu)?;
|
||||
// TODO:获取gfn使用的level,处理hugepage的问题
|
||||
let level = 1; // 4KB page
|
||||
// TODO: 快速处理由读写操作引起violation,即present同时有写权限的非mmio page fault
|
||||
// fast_page_fault(vcpu, gpa, level, error_code)
|
||||
// gfn->pfn
|
||||
let mut map_writable = false;
|
||||
let write = error_code & ((1_u32) << 1);
|
||||
let pfn = mmu_gfn_to_pfn_fast(vcpu, gpa, prefault, gfn, write == 0, &mut map_writable)?;
|
||||
// direct map就是映射ept页表的过程
|
||||
__direct_map(vcpu, gpa, write, map_writable, level, gfn, pfn, prefault)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/*
|
||||
* Caculate mmu pages needed for kvm.
|
||||
*/
|
||||
// pub fn kvm_mmu_calculate_mmu_pages() -> u32 {
|
||||
// let mut nr_mmu_pages:u32;
|
||||
// let mut nr_pages = 0;
|
||||
|
||||
// let kvm = vm(0).unwrap();
|
||||
// for as_id in 0..KVM_ADDRESS_SPACE_NUM {
|
||||
// let slots = kvm.memslots[as_id];
|
||||
// for i in 0..KVM_MEM_SLOTS_NUM {
|
||||
// let memslot = slots.memslots[i as usize];
|
||||
// nr_pages += memslot.npages;
|
||||
// }
|
||||
// }
|
||||
|
||||
// nr_mmu_pages = (nr_pages as u32)* KVM_PERMILLE_MMU_PAGES / 1000;
|
||||
// nr_mmu_pages = nr_mmu_pages.max(KVM_MIN_ALLOC_MMU_PAGES);
|
||||
// return nr_mmu_pages;
|
||||
// }
|
||||
|
||||
// pub fn kvm_mmu_change_mmu_pages(mut goal_nr_mmu_pages: u32){
|
||||
// let kvm = KVM();
|
||||
// // 释放多余的mmu page
|
||||
// if kvm.lock().arch.n_used_mmu_pages > goal_nr_mmu_pages {
|
||||
// while kvm.lock().arch.n_used_mmu_pages > goal_nr_mmu_pages {
|
||||
// if !prepare_zap_oldest_mmu_page() {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// // kvm_mmu_commit_zap_page();
|
||||
// goal_nr_mmu_pages = kvm.lock().arch.n_used_mmu_pages;
|
||||
|
||||
// }
|
||||
// kvm.lock().arch.n_max_mmu_pages = goal_nr_mmu_pages;
|
||||
// }
|
||||
|
||||
// pub fn prepare_zap_oldest_mmu_page() -> bool {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
pub fn kvm_mmu_setup(vcpu: &Mutex<VmxVcpu>) {
|
||||
// TODO: init_kvm_softmmu(vcpu), init_kvm_nested_mmu(vcpu)
|
||||
init_kvm_tdp_mmu(vcpu);
|
||||
}
|
||||
|
||||
pub fn kvm_vcpu_mtrr_init(_vcpu: &Mutex<VmxVcpu>) -> Result<(), SystemError> {
|
||||
check_ept_features()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn init_kvm_tdp_mmu(vcpu: &Mutex<VmxVcpu>) {
|
||||
let context = &mut vcpu.lock().mmu;
|
||||
context.page_fault = Some(tdp_page_fault);
|
||||
context.get_cr3 = Some(tdp_get_cr3);
|
||||
context.set_eptp = Some(tdp_set_eptp);
|
||||
// context.inject_page_fault = kvm_inject_page_fault; TODO: inject_page_fault
|
||||
// context.invlpg = nonpaging_invlpg;
|
||||
// context.sync_page = nonpaging_sync_page;
|
||||
// context.update_pte = nonpaging_update_pte;
|
||||
|
||||
// TODO: gva to gpa in kvm
|
||||
// if !is_paging(vcpu) { // vcpu不分页
|
||||
// context.gva_to_gpa = nonpaging_gva_to_gpa;
|
||||
// context.root_level = 0;
|
||||
// } else if (is_long_mode(vcpu)) {
|
||||
// context.gva_to_gpa = paging64_gva_to_gpa;
|
||||
// context.root_level = PT64_ROOT_LEVEL;
|
||||
// TODO:: different paging strategy
|
||||
// } else if (is_pae(vcpu)) {
|
||||
// context.gva_to_gpa = paging64_gva_to_gpa;
|
||||
// context.root_level = PT32E_ROOT_LEVEL;
|
||||
// } else {
|
||||
// context.gva_to_gpa = paging32_gva_to_gpa;
|
||||
// context.root_level = PT32_ROOT_LEVEL;
|
||||
// }
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn __direct_map(
|
||||
vcpu: &mut VmxVcpu,
|
||||
gpa: u64,
|
||||
_write: u32,
|
||||
_map_writable: bool,
|
||||
_level: i32,
|
||||
_gfn: u64,
|
||||
pfn: u64,
|
||||
_prefault: bool,
|
||||
) -> Result<u32, SystemError> {
|
||||
debug!("gpa={}, pfn={}, root_hpa={:x}", gpa, pfn, vcpu.mmu.root_hpa);
|
||||
// 判断vcpu.mmu.root_hpa是否有效
|
||||
if vcpu.mmu.root_hpa == 0 {
|
||||
return Err(SystemError::KVM_HVA_ERR_BAD);
|
||||
}
|
||||
// 把gpa映射到hpa
|
||||
let mut ept_mapper = EptMapper::lock();
|
||||
let page_flags = EntryFlags::from_prot_flags(ProtFlags::from_bits_truncate(0x7_u64), false);
|
||||
unsafe {
|
||||
assert!(ept_mapper.walk(gpa, pfn << PAGE_SHIFT, page_flags).is_ok());
|
||||
}
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
pub fn mmu_gfn_to_pfn_fast(
|
||||
vcpu: &mut VmxVcpu,
|
||||
_gpa: u64,
|
||||
_prefault: bool,
|
||||
gfn: u64,
|
||||
write: bool,
|
||||
writable: &mut bool,
|
||||
) -> Result<u64, SystemError> {
|
||||
let slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
|
||||
let pfn = __gfn_to_pfn(slot, gfn, false, write, writable)?;
|
||||
Ok(pfn)
|
||||
}
|
||||
|
||||
// TODO: 添加cache
|
||||
pub fn mmu_topup_memory_caches(_vcpu: &mut VmxVcpu) -> Result<(), SystemError> {
|
||||
// 如果 vcpu->arch.mmu_page_header_cache 不足,从 mmu_page_header_cache 中分配
|
||||
// pte_list_desc_cache 和 mmu_page_header_cache 两块全局 slab cache 在 kvm_mmu_module_init 中被创建
|
||||
// mmu_topup_memory_cache(vcpu.mmu_page_header_cache,
|
||||
// mmu_page_header_cache, 4);
|
||||
Ok(())
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
pub mod ept;
|
||||
pub mod kvm_emulation;
|
||||
pub mod mmu;
|
||||
pub mod seg;
|
||||
pub mod vcpu;
|
||||
pub mod vmcs;
|
||||
pub mod vmexit;
|
||||
pub mod vmx_asm_wrapper;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub enum VcpuRegIndex {
|
||||
Rax = 0,
|
||||
Rbx = 1,
|
||||
Rcx = 2,
|
||||
Rdx = 3,
|
||||
Rsi = 4,
|
||||
Rdi = 5,
|
||||
Rsp = 6,
|
||||
Rbp = 7,
|
||||
R8 = 8,
|
||||
R9 = 9,
|
||||
R10 = 10,
|
||||
R11 = 11,
|
||||
R12 = 12,
|
||||
R13 = 13,
|
||||
R14 = 14,
|
||||
R15 = 15,
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct X86_CR0: u32{
|
||||
const CR0_PE = 1 << 0; /* Protection Enable */
|
||||
const CR0_MP = 1 << 1; /* Monitor Coprocessor */
|
||||
const CR0_EM = 1 << 2; /* Emulation */
|
||||
const CR0_TS = 1 << 3; /* Task Switched */
|
||||
const CR0_ET = 1 << 4; /* Extension Type */
|
||||
const CR0_NE = 1 << 5; /* Numeric Error */
|
||||
const CR0_WP = 1 << 16; /* Write Protect */
|
||||
const CR0_AM = 1 << 18; /* Alignment Mask */
|
||||
const CR0_NW = 1 << 29; /* Not Write-through */
|
||||
const CR0_CD = 1 << 30; /* Cache Disable */
|
||||
const CR0_PG = 1 << 31; /* Paging */
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_CS_ACCESS_RIGHTS, GUEST_CS_BASE, GUEST_CS_LIMIT, GUEST_CS_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_DS_ACCESS_RIGHTS, GUEST_DS_BASE, GUEST_DS_LIMIT, GUEST_DS_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_ES_ACCESS_RIGHTS, GUEST_ES_BASE, GUEST_ES_LIMIT, GUEST_ES_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_FS_ACCESS_RIGHTS, GUEST_FS_BASE, GUEST_FS_LIMIT, GUEST_FS_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_GS_ACCESS_RIGHTS, GUEST_GS_BASE, GUEST_GS_LIMIT, GUEST_GS_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_LDTR_ACCESS_RIGHTS, GUEST_LDTR_BASE, GUEST_LDTR_LIMIT, GUEST_LDTR_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_SS_ACCESS_RIGHTS, GUEST_SS_BASE, GUEST_SS_LIMIT, GUEST_SS_SELECTOR,
|
||||
};
|
||||
use crate::arch::kvm::VmcsFields::{
|
||||
GUEST_TR_ACCESS_RIGHTS, GUEST_TR_BASE, GUEST_TR_LIMIT, GUEST_TR_SELECTOR,
|
||||
};
|
||||
use system_error::SystemError;
|
||||
|
||||
use super::vmx_asm_wrapper::vmx_vmwrite;
|
||||
|
||||
// pub const TSS_IOPB_BASE_OFFSET: usize = 0x66;
|
||||
// pub const TSS_BASE_SIZE: usize = 0x68;
|
||||
// pub const TSS_IOPB_SIZE: usize = 65536 / 8;
|
||||
// pub const TSS_REDIRECTION_SIZE: usize = 256 / 8;
|
||||
// pub const RMODE_TSS_SIZE: usize = TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct KvmVmxSegmentField {
|
||||
selector: u32,
|
||||
base: u32,
|
||||
limit: u32,
|
||||
access_rights: u32,
|
||||
}
|
||||
|
||||
macro_rules! VMX_SEGMENT_FIELD {
|
||||
($struct_name: ident) => {
|
||||
KvmVmxSegmentField {
|
||||
selector: concat_idents!(GUEST_, $struct_name, _SELECTOR) as u32,
|
||||
base: concat_idents!(GUEST_, $struct_name, _BASE) as u32,
|
||||
limit: concat_idents!(GUEST_, $struct_name, _LIMIT) as u32,
|
||||
access_rights: concat_idents!(GUEST_, $struct_name, _ACCESS_RIGHTS) as u32,
|
||||
}
|
||||
};
|
||||
}
|
||||
#[derive(FromPrimitive)]
|
||||
pub enum Sreg {
|
||||
ES = 0,
|
||||
CS = 1,
|
||||
SS = 2,
|
||||
DS = 3,
|
||||
FS = 4,
|
||||
GS = 5,
|
||||
TR = 6,
|
||||
LDTR = 7,
|
||||
}
|
||||
|
||||
static KVM_VMX_SEGMENT_FIELDS: [KvmVmxSegmentField; 8] = [
|
||||
VMX_SEGMENT_FIELD!(ES),
|
||||
VMX_SEGMENT_FIELD!(CS),
|
||||
VMX_SEGMENT_FIELD!(SS),
|
||||
VMX_SEGMENT_FIELD!(DS),
|
||||
VMX_SEGMENT_FIELD!(FS),
|
||||
VMX_SEGMENT_FIELD!(GS),
|
||||
VMX_SEGMENT_FIELD!(TR),
|
||||
VMX_SEGMENT_FIELD!(LDTR),
|
||||
];
|
||||
|
||||
pub fn seg_setup(seg: usize) -> Result<(), SystemError> {
|
||||
let seg_field = &KVM_VMX_SEGMENT_FIELDS[seg];
|
||||
let mut access_rigt = 0x0093;
|
||||
if seg == Sreg::CS as usize {
|
||||
access_rigt |= 0x08;
|
||||
}
|
||||
// setup segment fields
|
||||
vmx_vmwrite(seg_field.selector, 0)?;
|
||||
vmx_vmwrite(seg_field.base, 0)?;
|
||||
vmx_vmwrite(seg_field.limit, 0x0000_FFFF)?;
|
||||
vmx_vmwrite(seg_field.access_rights, access_rigt)?;
|
||||
|
||||
Ok(())
|
||||
}
|
@ -1,651 +0,0 @@
|
||||
use super::vmcs::{
|
||||
VMCSRegion, VmcsFields, VmxEntryCtrl, VmxPrimaryExitCtrl, VmxPrimaryProcessBasedExecuteCtrl,
|
||||
VmxSecondaryProcessBasedExecuteCtrl,
|
||||
};
|
||||
use super::vmx_asm_wrapper::{vmx_vmclear, vmx_vmptrld, vmx_vmread, vmx_vmwrite, vmxoff, vmxon};
|
||||
use crate::arch::kvm::vmx::mmu::KvmMmu;
|
||||
use crate::arch::kvm::vmx::seg::{seg_setup, Sreg};
|
||||
use crate::arch::kvm::vmx::{VcpuRegIndex, X86_CR0};
|
||||
use crate::arch::mm::{LockedFrameAllocator, PageMapper};
|
||||
use crate::arch::x86_64::mm::X86_64MMArch;
|
||||
use crate::arch::MMArch;
|
||||
|
||||
use crate::mm::{MemoryManagementArch, PageTableKind};
|
||||
use crate::mm::{PhysAddr, VirtAddr};
|
||||
use crate::virt::kvm::vcpu::Vcpu;
|
||||
use crate::virt::kvm::vm::Vm;
|
||||
use alloc::alloc::Global;
|
||||
use alloc::boxed::Box;
|
||||
use core::slice;
|
||||
use log::debug;
|
||||
use raw_cpuid::CpuId;
|
||||
use system_error::SystemError;
|
||||
use x86;
|
||||
use x86::{controlregs, msr, segmentation};
|
||||
// use crate::arch::kvm::vmx::seg::RMODE_TSS_SIZE;
|
||||
// use crate::virt::kvm::{KVM};
|
||||
|
||||
// KERNEL_ALLOCATOR
|
||||
pub const PAGE_SIZE: usize = 0x1000;
|
||||
pub const NR_VCPU_REGS: usize = 16;
|
||||
|
||||
#[repr(C, align(4096))]
|
||||
#[derive(Debug)]
|
||||
pub struct VmxonRegion {
|
||||
pub revision_id: u32,
|
||||
pub data: [u8; PAGE_SIZE - 4],
|
||||
}
|
||||
|
||||
#[repr(C, align(4096))]
|
||||
#[derive(Debug)]
|
||||
pub struct MSRBitmap {
|
||||
pub data: [u8; PAGE_SIZE],
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub struct VcpuData {
|
||||
/// The virtual and physical address of the Vmxon naturally aligned 4-KByte region of memory
|
||||
pub vmxon_region: Box<VmxonRegion>,
|
||||
pub vmxon_region_physical_address: u64, // vmxon需要该地址
|
||||
/// The virtual and physical address of the Vmcs naturally aligned 4-KByte region of memory
|
||||
/// holds the complete CPU state of both the host and the guest.
|
||||
/// includes the segment registers, GDT, IDT, TR, various MSR’s
|
||||
/// and control field structures for handling exit and entry operations
|
||||
pub vmcs_region: Box<VMCSRegion>,
|
||||
pub vmcs_region_physical_address: u64, // vmptrld, vmclear需要该地址
|
||||
pub msr_bitmap: Box<MSRBitmap>,
|
||||
pub msr_bitmap_physical_address: u64,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct VcpuContextFrame {
|
||||
pub regs: [usize; NR_VCPU_REGS], // 通用寄存器
|
||||
pub rip: usize,
|
||||
pub rflags: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum VcpuState {
|
||||
Inv = 0,
|
||||
Pend = 1,
|
||||
Act = 2,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub struct VmxVcpu {
|
||||
pub vcpu_id: u32,
|
||||
pub vcpu_ctx: VcpuContextFrame, // 保存vcpu切换时的上下文,如通用寄存器等
|
||||
pub vcpu_state: VcpuState, // vcpu当前运行状态
|
||||
pub mmu: KvmMmu, // vcpu的内存管理单元
|
||||
pub data: VcpuData, // vcpu的数据
|
||||
pub parent_vm: Vm, // parent KVM
|
||||
}
|
||||
|
||||
impl VcpuData {
|
||||
pub fn alloc() -> Result<Self, SystemError> {
|
||||
let vmxon_region: Box<VmxonRegion> = unsafe {
|
||||
Box::try_new_zeroed_in(Global)
|
||||
.expect("Try new zeroed fail!")
|
||||
.assume_init()
|
||||
};
|
||||
let vmcs_region: Box<VMCSRegion> = unsafe {
|
||||
Box::try_new_zeroed_in(Global)
|
||||
.expect("Try new zeroed fail!")
|
||||
.assume_init()
|
||||
};
|
||||
let msr_bitmap: Box<MSRBitmap> = unsafe {
|
||||
Box::try_new_zeroed_in(Global)
|
||||
.expect("Try new zeroed fail!")
|
||||
.assume_init()
|
||||
};
|
||||
// FIXME: virt_2_phys的转换正确性存疑
|
||||
let vmxon_region_physical_address = {
|
||||
let vaddr = VirtAddr::new(vmxon_region.as_ref() as *const _ as _);
|
||||
unsafe { MMArch::virt_2_phys(vaddr).unwrap().data() as u64 }
|
||||
};
|
||||
let vmcs_region_physical_address = {
|
||||
let vaddr = VirtAddr::new(vmcs_region.as_ref() as *const _ as _);
|
||||
unsafe { MMArch::virt_2_phys(vaddr).unwrap().data() as u64 }
|
||||
};
|
||||
let msr_bitmap_physical_address = {
|
||||
let vaddr = VirtAddr::new(msr_bitmap.as_ref() as *const _ as _);
|
||||
unsafe { MMArch::virt_2_phys(vaddr).unwrap().data() as u64 }
|
||||
};
|
||||
|
||||
let mut instance = Self {
|
||||
// Allocate a naturally aligned 4-KByte VMXON region of memory to enable VMX operation (Intel Manual: 25.11.5 VMXON Region)
|
||||
vmxon_region,
|
||||
vmxon_region_physical_address,
|
||||
// Allocate a naturally aligned 4-KByte VMCS region of memory
|
||||
vmcs_region,
|
||||
vmcs_region_physical_address,
|
||||
msr_bitmap,
|
||||
msr_bitmap_physical_address,
|
||||
};
|
||||
// printk_color!(GREEN, BLACK, "[+] init_region\n");
|
||||
instance.init_region()?;
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
pub fn init_region(&mut self) -> Result<(), SystemError> {
|
||||
// Get the Virtual Machine Control Structure revision identifier (VMCS revision ID)
|
||||
// (Intel Manual: 25.11.5 VMXON Region)
|
||||
let revision_id = unsafe { (msr::rdmsr(msr::IA32_VMX_BASIC) as u32) & 0x7FFF_FFFF };
|
||||
debug!("[+] VMXON Region Virtual Address: {:p}", self.vmxon_region);
|
||||
debug!(
|
||||
"[+] VMXON Region Physical Addresss: 0x{:x}",
|
||||
self.vmxon_region_physical_address
|
||||
);
|
||||
debug!("[+] VMCS Region Virtual Address: {:p}", self.vmcs_region);
|
||||
debug!(
|
||||
"[+] VMCS Region Physical Address1: 0x{:x}",
|
||||
self.vmcs_region_physical_address
|
||||
);
|
||||
self.vmxon_region.revision_id = revision_id;
|
||||
self.vmcs_region.revision_id = revision_id;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
impl VmxVcpu {
|
||||
pub fn new(vcpu_id: u32, parent_vm: Vm) -> Result<Self, SystemError> {
|
||||
debug!("Creating processor {}", vcpu_id);
|
||||
let instance = Self {
|
||||
vcpu_id,
|
||||
vcpu_ctx: VcpuContextFrame {
|
||||
regs: [0; NR_VCPU_REGS],
|
||||
rip: 0,
|
||||
rflags: 0,
|
||||
},
|
||||
vcpu_state: VcpuState::Inv,
|
||||
mmu: KvmMmu::default(),
|
||||
data: VcpuData::alloc()?,
|
||||
parent_vm,
|
||||
};
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
pub fn vmx_set_cr0(cr0: X86_CR0) -> Result<(), SystemError> {
|
||||
let mut hw_cr0 = cr0 & !(X86_CR0::CR0_NW | X86_CR0::CR0_CD);
|
||||
hw_cr0 |= X86_CR0::CR0_WP | X86_CR0::CR0_NE;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_CR0 as u32, cr0.bits() as u64)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn vmcs_init_guest(&self) -> Result<(), SystemError> {
|
||||
// https://www.sandpile.org/x86/initial.htm
|
||||
// segment field initialization
|
||||
seg_setup(Sreg::CS as usize)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_CS_SELECTOR as u32, 0xf000)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_CS_BASE as u32, 0xffff0000)?;
|
||||
|
||||
seg_setup(Sreg::DS as usize)?;
|
||||
seg_setup(Sreg::ES as usize)?;
|
||||
seg_setup(Sreg::FS as usize)?;
|
||||
seg_setup(Sreg::GS as usize)?;
|
||||
seg_setup(Sreg::SS as usize)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_TR_SELECTOR as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_TR_BASE as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_TR_LIMIT as u32, 0xffff)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_TR_ACCESS_RIGHTS as u32, 0x008b)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_LDTR_SELECTOR as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_LDTR_BASE as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_LDTR_LIMIT as u32, 0xffff)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_LDTR_ACCESS_RIGHTS as u32, 0x00082)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_RFLAGS as u32, 2)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_GDTR_BASE as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_GDTR_LIMIT as u32, 0x0000_FFFF_u64)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_IDTR_BASE as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_IDTR_LIMIT as u32, 0x0000_FFFF_u64)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_ACTIVITY_STATE as u32, 0)?; // State = Active
|
||||
vmx_vmwrite(VmcsFields::GUEST_INTERRUPTIBILITY_STATE as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_PENDING_DBG_EXCEPTIONS as u32, 0)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::CTRL_VM_ENTRY_INTR_INFO_FIELD as u32, 0)?;
|
||||
|
||||
let cr0 = X86_CR0::CR0_NW | X86_CR0::CR0_CD | X86_CR0::CR0_ET;
|
||||
Self::vmx_set_cr0(cr0)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_CR0 as u32, cr0.bits() as u64)?;
|
||||
|
||||
vmx_vmwrite(
|
||||
VmcsFields::GUEST_SYSENTER_CS as u32,
|
||||
vmx_vmread(VmcsFields::HOST_SYSENTER_CS as u32).unwrap(),
|
||||
)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_VMX_PREEMPT_TIMER_VALUE as u32, 0)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_INTR_STATUS as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_PML_INDEX as u32, 0)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::GUEST_VMCS_LINK_PTR as u32, u64::MAX)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_DEBUGCTL as u32, unsafe {
|
||||
msr::rdmsr(msr::IA32_DEBUGCTL)
|
||||
})?;
|
||||
|
||||
vmx_vmwrite(
|
||||
VmcsFields::GUEST_SYSENTER_ESP as u32,
|
||||
vmx_vmread(VmcsFields::HOST_SYSENTER_ESP as u32).unwrap(),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::GUEST_SYSENTER_EIP as u32,
|
||||
vmx_vmread(VmcsFields::HOST_SYSENTER_EIP as u32).unwrap(),
|
||||
)?;
|
||||
|
||||
// Self::vmx_set_cr0();
|
||||
vmx_vmwrite(VmcsFields::GUEST_CR3 as u32, 0)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::GUEST_CR4 as u32,
|
||||
1, // enable vme
|
||||
)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_DR7 as u32, 0x0000_0000_0000_0400)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::GUEST_RSP as u32,
|
||||
self.vcpu_ctx.regs[VcpuRegIndex::Rsp as usize] as u64,
|
||||
)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_RIP as u32, self.vcpu_ctx.rip as u64)?;
|
||||
debug!("vmcs init guest rip: {:#x}", self.vcpu_ctx.rip as u64);
|
||||
debug!(
|
||||
"vmcs init guest rsp: {:#x}",
|
||||
self.vcpu_ctx.regs[VcpuRegIndex::Rsp as usize] as u64
|
||||
);
|
||||
|
||||
// vmx_vmwrite(VmcsFields::GUEST_RFLAGS as u32, x86::bits64::rflags::read().bits())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub fn vmcs_init_host(&self) -> Result<(), SystemError> {
|
||||
vmx_vmwrite(VmcsFields::HOST_CR0 as u32, unsafe {
|
||||
controlregs::cr0().bits().try_into().unwrap()
|
||||
})?;
|
||||
vmx_vmwrite(VmcsFields::HOST_CR3 as u32, unsafe { controlregs::cr3() })?;
|
||||
vmx_vmwrite(VmcsFields::HOST_CR4 as u32, unsafe {
|
||||
controlregs::cr4().bits().try_into().unwrap()
|
||||
})?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_ES_SELECTOR as u32,
|
||||
(segmentation::es().bits() & (!0x07)).into(),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_CS_SELECTOR as u32,
|
||||
(segmentation::cs().bits() & (!0x07)).into(),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_SS_SELECTOR as u32,
|
||||
(segmentation::ss().bits() & (!0x07)).into(),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_DS_SELECTOR as u32,
|
||||
(segmentation::ds().bits() & (!0x07)).into(),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_FS_SELECTOR as u32,
|
||||
(segmentation::fs().bits() & (!0x07)).into(),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_GS_SELECTOR as u32,
|
||||
(segmentation::gs().bits() & (!0x07)).into(),
|
||||
)?;
|
||||
vmx_vmwrite(VmcsFields::HOST_TR_SELECTOR as u32, unsafe {
|
||||
(x86::task::tr().bits() & (!0x07)).into()
|
||||
})?;
|
||||
vmx_vmwrite(VmcsFields::HOST_FS_BASE as u32, unsafe {
|
||||
msr::rdmsr(msr::IA32_FS_BASE)
|
||||
})?;
|
||||
vmx_vmwrite(VmcsFields::HOST_GS_BASE as u32, unsafe {
|
||||
msr::rdmsr(msr::IA32_GS_BASE)
|
||||
})?;
|
||||
|
||||
let mut pseudo_descriptpr: x86::dtables::DescriptorTablePointer<u64> = Default::default();
|
||||
unsafe {
|
||||
x86::dtables::sgdt(&mut pseudo_descriptpr);
|
||||
};
|
||||
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_TR_BASE as u32,
|
||||
get_segment_base(pseudo_descriptpr.base, pseudo_descriptpr.limit, unsafe {
|
||||
x86::task::tr().bits()
|
||||
}),
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::HOST_GDTR_BASE as u32,
|
||||
pseudo_descriptpr.base as usize as u64,
|
||||
)?;
|
||||
vmx_vmwrite(VmcsFields::HOST_IDTR_BASE as u32, unsafe {
|
||||
let mut pseudo_descriptpr: x86::dtables::DescriptorTablePointer<u64> =
|
||||
Default::default();
|
||||
x86::dtables::sidt(&mut pseudo_descriptpr);
|
||||
pseudo_descriptpr.base as usize as u64
|
||||
})?;
|
||||
|
||||
// fast entry into the kernel
|
||||
vmx_vmwrite(VmcsFields::HOST_SYSENTER_ESP as u32, unsafe {
|
||||
msr::rdmsr(msr::IA32_SYSENTER_ESP)
|
||||
})?;
|
||||
vmx_vmwrite(VmcsFields::HOST_SYSENTER_EIP as u32, unsafe {
|
||||
msr::rdmsr(msr::IA32_SYSENTER_EIP)
|
||||
})?;
|
||||
vmx_vmwrite(VmcsFields::HOST_SYSENTER_CS as u32, unsafe {
|
||||
msr::rdmsr(msr::IA32_SYSENTER_CS)
|
||||
})?;
|
||||
|
||||
// vmx_vmwrite(VmcsFields::HOST_RIP as u32, vmx_return as *const () as u64)?;
|
||||
// debug!("vmcs init host rip: {:#x}", vmx_return as *const () as u64);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Intel SDM Volume 3C Chapter 25.3 “Organization of VMCS Data”
|
||||
pub fn vmcs_init(&self) -> Result<(), SystemError> {
|
||||
vmx_vmwrite(VmcsFields::CTRL_PAGE_FAULT_ERR_CODE_MASK as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::CTRL_PAGE_FAULT_ERR_CODE_MATCH as u32, 0)?;
|
||||
vmx_vmwrite(VmcsFields::CTRL_CR3_TARGET_COUNT as u32, 0)?;
|
||||
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_PIN_BASED_VM_EXEC_CTRLS as u32,
|
||||
adjust_vmx_pinbased_controls() as u64,
|
||||
)?;
|
||||
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_MSR_BITMAP_ADDR as u32,
|
||||
self.data.msr_bitmap_physical_address,
|
||||
)?;
|
||||
|
||||
vmx_vmwrite(VmcsFields::CTRL_CR0_READ_SHADOW as u32, unsafe {
|
||||
controlregs::cr0().bits().try_into().unwrap()
|
||||
})?;
|
||||
vmx_vmwrite(VmcsFields::CTRL_CR4_READ_SHADOW as u32, unsafe {
|
||||
controlregs::cr4().bits().try_into().unwrap()
|
||||
})?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_VM_ENTRY_CTRLS as u32,
|
||||
adjust_vmx_entry_controls() as u64,
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_PRIMARY_VM_EXIT_CTRLS as u32,
|
||||
adjust_vmx_exit_controls() as u64,
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_PRIMARY_PROCESSOR_VM_EXEC_CTRLS as u32,
|
||||
adjust_vmx_primary_process_exec_controls() as u64,
|
||||
)?;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_SECONDARY_PROCESSOR_VM_EXEC_CTRLS as u32,
|
||||
adjust_vmx_secondary_process_exec_controls() as u64,
|
||||
)?;
|
||||
|
||||
self.vmcs_init_host()?;
|
||||
self.vmcs_init_guest()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn kvm_mmu_load(&mut self) -> Result<(), SystemError> {
|
||||
debug!("kvm_mmu_load!");
|
||||
// 申请并创建新的页表
|
||||
let mapper: crate::mm::page::PageMapper<X86_64MMArch, LockedFrameAllocator> = unsafe {
|
||||
PageMapper::create(PageTableKind::EPT, LockedFrameAllocator)
|
||||
.ok_or(SystemError::ENOMEM)?
|
||||
};
|
||||
|
||||
let ept_root_hpa = mapper.table().phys();
|
||||
let set_eptp_fn = self.mmu.set_eptp.unwrap();
|
||||
set_eptp_fn(ept_root_hpa.data() as u64)?;
|
||||
self.mmu.root_hpa = ept_root_hpa.data() as u64;
|
||||
debug!("ept_root_hpa:{:x}!", ept_root_hpa.data() as u64);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn set_regs(&mut self, regs: VcpuContextFrame) -> Result<(), SystemError> {
|
||||
self.vcpu_ctx = regs;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Vcpu for VmxVcpu {
|
||||
/// Virtualize the CPU
|
||||
fn virtualize_cpu(&mut self) -> Result<(), SystemError> {
|
||||
match has_intel_vmx_support() {
|
||||
Ok(_) => {
|
||||
debug!("[+] CPU supports Intel VMX");
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("[-] CPU does not support Intel VMX: {:?}", e);
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
};
|
||||
|
||||
match enable_vmx_operation() {
|
||||
Ok(_) => {
|
||||
debug!("[+] Enabling Virtual Machine Extensions (VMX)");
|
||||
}
|
||||
Err(_) => {
|
||||
debug!("[-] VMX operation is not supported on this processor.");
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
}
|
||||
|
||||
vmxon(self.data.vmxon_region_physical_address)?;
|
||||
debug!("[+] VMXON successful!");
|
||||
vmx_vmclear(self.data.vmcs_region_physical_address)?;
|
||||
vmx_vmptrld(self.data.vmcs_region_physical_address)?;
|
||||
debug!("[+] VMPTRLD successful!");
|
||||
self.vmcs_init().expect("vncs_init fail");
|
||||
debug!("[+] VMCS init!");
|
||||
// debug!("vmcs init host rip: {:#x}", vmx_return as *const () as u64);
|
||||
// debug!("vmcs init host rsp: {:#x}", x86::bits64::registers::rsp());
|
||||
// vmx_vmwrite(VmcsFields::HOST_RSP as u32, x86::bits64::registers::rsp())?;
|
||||
// vmx_vmwrite(VmcsFields::HOST_RIP as u32, vmx_return as *const () as u64)?;
|
||||
// vmx_vmwrite(VmcsFields::HOST_RSP as u32, x86::bits64::registers::rsp())?;
|
||||
self.kvm_mmu_load()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn devirtualize_cpu(&self) -> Result<(), SystemError> {
|
||||
vmxoff()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Gets the index of the current logical/virtual processor
|
||||
fn id(&self) -> u32 {
|
||||
self.vcpu_id
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_segment_base(gdt_base: *const u64, gdt_size: u16, segment_selector: u16) -> u64 {
|
||||
let table = segment_selector & 0x0004; // get table indicator in selector
|
||||
let index = (segment_selector >> 3) as usize; // get index in selector
|
||||
if table == 0 && index == 0 {
|
||||
return 0;
|
||||
}
|
||||
let descriptor_table = unsafe { slice::from_raw_parts(gdt_base, gdt_size.into()) };
|
||||
let descriptor = descriptor_table[index];
|
||||
|
||||
let base_high = (descriptor & 0xFF00_0000_0000_0000) >> 32;
|
||||
let base_mid = (descriptor & 0x0000_00FF_0000_0000) >> 16;
|
||||
let base_low = (descriptor & 0x0000_0000_FFFF_0000) >> 16;
|
||||
let segment_base = (base_high | base_mid | base_low) & 0xFFFFFFFF;
|
||||
let virtaddr = unsafe { MMArch::phys_2_virt(PhysAddr::new(segment_base as usize)).unwrap() };
|
||||
|
||||
return virtaddr.data() as u64;
|
||||
}
|
||||
|
||||
// FIXME: may have bug
|
||||
// pub fn read_segment_access_rights(segement_selector: u16) -> u32{
|
||||
// let table = segement_selector & 0x0004; // get table indicator in selector
|
||||
// let index = segement_selector & 0xFFF8; // get index in selector
|
||||
// let mut flag: u16;
|
||||
// if table==0 && index==0 {
|
||||
// return 0;
|
||||
// }
|
||||
// unsafe{
|
||||
// asm!(
|
||||
// "lar {0:r}, rcx",
|
||||
// "mov {1:r}, {0:r}",
|
||||
// in(reg) segement_selector,
|
||||
// out(reg) flag,
|
||||
// );
|
||||
// }
|
||||
// return (flag >> 8) as u32;
|
||||
// }
|
||||
pub fn adjust_vmx_controls(ctl_min: u32, ctl_opt: u32, msr: u32, result: &mut u32) {
|
||||
let vmx_msr_low: u32 = unsafe { (msr::rdmsr(msr) & 0x0000_0000_FFFF_FFFF) as u32 };
|
||||
let vmx_msr_high: u32 = unsafe { (msr::rdmsr(msr) >> 32) as u32 };
|
||||
let mut ctl: u32 = ctl_min | ctl_opt;
|
||||
ctl &= vmx_msr_high; /* bit == 0 in high word ==> must be zero */
|
||||
ctl |= vmx_msr_low; /* bit == 1 in low word ==> must be one */
|
||||
*result = ctl;
|
||||
}
|
||||
|
||||
pub fn adjust_vmx_entry_controls() -> u32 {
|
||||
let mut entry_controls: u32 = 0;
|
||||
adjust_vmx_controls(
|
||||
VmxEntryCtrl::LOAD_DBG_CTRLS.bits(),
|
||||
VmxEntryCtrl::IA32E_MODE_GUEST.bits(),
|
||||
msr::IA32_VMX_ENTRY_CTLS, //Capability Reporting Register of VM-entry Controls (R/O)
|
||||
&mut entry_controls,
|
||||
);
|
||||
return entry_controls;
|
||||
// msr::IA32_VMX_TRUE_ENTRY_CTLS//Capability Reporting Register of VM-entry Flex Controls (R/O) See Table 35-2
|
||||
}
|
||||
|
||||
pub fn adjust_vmx_exit_controls() -> u32 {
|
||||
let mut exit_controls: u32 = 0;
|
||||
adjust_vmx_controls(
|
||||
VmxPrimaryExitCtrl::SAVE_DBG_CTRLS.bits(),
|
||||
VmxPrimaryExitCtrl::HOST_ADDR_SPACE_SIZE.bits(),
|
||||
msr::IA32_VMX_EXIT_CTLS,
|
||||
&mut exit_controls,
|
||||
);
|
||||
return exit_controls;
|
||||
}
|
||||
|
||||
pub fn adjust_vmx_pinbased_controls() -> u32 {
|
||||
let mut controls: u32 = 16;
|
||||
adjust_vmx_controls(0, 0, msr::IA32_VMX_TRUE_PINBASED_CTLS, &mut controls);
|
||||
// debug!("adjust_vmx_pinbased_controls: {:x}", controls);
|
||||
return controls;
|
||||
}
|
||||
|
||||
pub fn adjust_vmx_primary_process_exec_controls() -> u32 {
|
||||
let mut controls: u32 = 0;
|
||||
adjust_vmx_controls(
|
||||
0,
|
||||
VmxPrimaryProcessBasedExecuteCtrl::USE_MSR_BITMAPS.bits()
|
||||
| VmxPrimaryProcessBasedExecuteCtrl::ACTIVATE_SECONDARY_CONTROLS.bits(),
|
||||
msr::IA32_VMX_PROCBASED_CTLS,
|
||||
&mut controls,
|
||||
);
|
||||
return controls;
|
||||
}
|
||||
|
||||
pub fn adjust_vmx_secondary_process_exec_controls() -> u32 {
|
||||
let mut controls: u32 = 0;
|
||||
adjust_vmx_controls(
|
||||
0,
|
||||
VmxSecondaryProcessBasedExecuteCtrl::ENABLE_RDTSCP.bits()
|
||||
| VmxSecondaryProcessBasedExecuteCtrl::ENABLE_XSAVES_XRSTORS.bits()
|
||||
| VmxSecondaryProcessBasedExecuteCtrl::ENABLE_INVPCID.bits()
|
||||
| VmxSecondaryProcessBasedExecuteCtrl::ENABLE_EPT.bits()
|
||||
| VmxSecondaryProcessBasedExecuteCtrl::UNRESTRICTED_GUEST.bits(),
|
||||
msr::IA32_VMX_PROCBASED_CTLS2,
|
||||
&mut controls,
|
||||
);
|
||||
return controls;
|
||||
}
|
||||
|
||||
/// Check to see if CPU is Intel (“GenuineIntel”).
|
||||
/// Check processor supports for Virtual Machine Extension (VMX) technology
|
||||
// CPUID.1:ECX.VMX[bit 5] = 1 (Intel Manual: 24.6 Discovering Support for VMX)
|
||||
pub fn has_intel_vmx_support() -> Result<(), SystemError> {
|
||||
let cpuid = CpuId::new();
|
||||
if let Some(vi) = cpuid.get_vendor_info() {
|
||||
if vi.as_str() != "GenuineIntel" {
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
}
|
||||
if let Some(fi) = cpuid.get_feature_info() {
|
||||
if !fi.has_vmx() {
|
||||
return Err(SystemError::ENOSYS);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Enables Virtual Machine Extensions
|
||||
// - CR4.VMXE[bit 13] = 1 (Intel Manual: 24.7 Enabling and Entering VMX Operation)
|
||||
pub fn enable_vmx_operation() -> Result<(), SystemError> {
|
||||
let mut cr4 = unsafe { controlregs::cr4() };
|
||||
cr4.set(controlregs::Cr4::CR4_ENABLE_VMX, true);
|
||||
unsafe { controlregs::cr4_write(cr4) };
|
||||
|
||||
set_lock_bit()?;
|
||||
debug!("[+] Lock bit set via IA32_FEATURE_CONTROL");
|
||||
set_cr0_bits();
|
||||
debug!("[+] Mandatory bits in CR0 set/cleared");
|
||||
set_cr4_bits();
|
||||
debug!("[+] Mandatory bits in CR4 set/cleared");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check if we need to set bits in IA32_FEATURE_CONTROL
|
||||
// (Intel Manual: 24.7 Enabling and Entering VMX Operation)
|
||||
fn set_lock_bit() -> Result<(), SystemError> {
|
||||
const VMX_LOCK_BIT: u64 = 1 << 0;
|
||||
const VMXON_OUTSIDE_SMX: u64 = 1 << 2;
|
||||
|
||||
let ia32_feature_control = unsafe { msr::rdmsr(msr::IA32_FEATURE_CONTROL) };
|
||||
|
||||
if (ia32_feature_control & VMX_LOCK_BIT) == 0 {
|
||||
unsafe {
|
||||
msr::wrmsr(
|
||||
msr::IA32_FEATURE_CONTROL,
|
||||
VMXON_OUTSIDE_SMX | VMX_LOCK_BIT | ia32_feature_control,
|
||||
)
|
||||
};
|
||||
} else if (ia32_feature_control & VMXON_OUTSIDE_SMX) == 0 {
|
||||
return Err(SystemError::EPERM);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the mandatory bits in CR0 and clear bits that are mandatory zero
|
||||
/// (Intel Manual: 24.8 Restrictions on VMX Operation)
|
||||
fn set_cr0_bits() {
|
||||
let ia32_vmx_cr0_fixed0 = unsafe { msr::rdmsr(msr::IA32_VMX_CR0_FIXED0) };
|
||||
let ia32_vmx_cr0_fixed1 = unsafe { msr::rdmsr(msr::IA32_VMX_CR0_FIXED1) };
|
||||
|
||||
let mut cr0 = unsafe { controlregs::cr0() };
|
||||
|
||||
cr0 |= controlregs::Cr0::from_bits_truncate(ia32_vmx_cr0_fixed0 as usize);
|
||||
cr0 &= controlregs::Cr0::from_bits_truncate(ia32_vmx_cr0_fixed1 as usize);
|
||||
|
||||
unsafe { controlregs::cr0_write(cr0) };
|
||||
}
|
||||
|
||||
/// Set the mandatory bits in CR4 and clear bits that are mandatory zero
|
||||
/// (Intel Manual: 24.8 Restrictions on VMX Operation)
|
||||
fn set_cr4_bits() {
|
||||
let ia32_vmx_cr4_fixed0 = unsafe { msr::rdmsr(msr::IA32_VMX_CR4_FIXED0) };
|
||||
let ia32_vmx_cr4_fixed1 = unsafe { msr::rdmsr(msr::IA32_VMX_CR4_FIXED1) };
|
||||
|
||||
let mut cr4 = unsafe { controlregs::cr4() };
|
||||
|
||||
cr4 |= controlregs::Cr4::from_bits_truncate(ia32_vmx_cr4_fixed0 as usize);
|
||||
cr4 &= controlregs::Cr4::from_bits_truncate(ia32_vmx_cr4_fixed1 as usize);
|
||||
|
||||
unsafe { controlregs::cr4_write(cr4) };
|
||||
}
|
@ -1,537 +0,0 @@
|
||||
use bitflags::bitflags;
|
||||
use num_derive::FromPrimitive;
|
||||
|
||||
pub const PAGE_SIZE: usize = 0x1000;
|
||||
|
||||
#[repr(C, align(4096))]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VMCSRegion {
|
||||
pub revision_id: u32,
|
||||
pub abort_indicator: u32,
|
||||
data: [u8; PAGE_SIZE - 8],
|
||||
}
|
||||
|
||||
// (Intel Manual: 25.11.2 VMREAD, VMWRITE, and Encodings of VMCS Fields)
|
||||
#[derive(FromPrimitive)]
|
||||
enum VmcsAccessType {
|
||||
FULL = 0,
|
||||
HIGH = 1,
|
||||
}
|
||||
|
||||
#[derive(FromPrimitive)]
|
||||
enum VmcsType {
|
||||
CONTROL = 0,
|
||||
VMEXIT = 1,
|
||||
GUEST = 2,
|
||||
HOST = 3,
|
||||
}
|
||||
|
||||
#[derive(FromPrimitive)]
|
||||
enum VmcsWidth {
|
||||
BIT16 = 0,
|
||||
BIT64 = 1,
|
||||
BIT32 = 2,
|
||||
NATURAL = 3,
|
||||
}
|
||||
|
||||
#[derive(FromPrimitive)]
|
||||
#[allow(non_camel_case_types)]
|
||||
// (Intel Manual: APPENDIX B FIELD ENCODING IN VMCS)
|
||||
pub enum VmcsFields {
|
||||
// [CONTROL] fields
|
||||
// 16-bit control fields
|
||||
CTRL_VIRT_PROC_ID = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT16, 0) as isize,
|
||||
CTRL_POSTED_INTR_N_VECTOR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT16, 1) as isize,
|
||||
CTRL_EPTP_INDEX = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT16, 2) as isize,
|
||||
// 64-bit control fields
|
||||
CTRL_IO_BITMAP_A_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 0) as isize,
|
||||
CTRL_IO_BITMAP_B_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 1) as isize,
|
||||
CTRL_MSR_BITMAP_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 2) as isize, // control whether RDMSR or WRMSR cause VM exit
|
||||
CTRL_VMEXIT_MSR_STORE_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 3) as isize,
|
||||
CTRL_VMEXIT_MSR_LOAD_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 4) as isize,
|
||||
CTRL_VMENTRY_MSR_LOAD_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 5) as isize,
|
||||
CTRL_EXECUTIVE_VMCS_PTR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 6) as isize,
|
||||
CTRL_PML_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 7) as isize,
|
||||
CTRL_TSC_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 8) as isize,
|
||||
CTRL_VIRT_APIC_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 9) as isize,
|
||||
CTRL_APIC_ACCESS_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 10) as isize,
|
||||
CTRL_POSTED_INTR_DESC_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 11) as isize,
|
||||
CTRL_VMFUNC_CTRL = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 12) as isize,
|
||||
CTRL_EPTP_PTR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 13) as isize,
|
||||
CTRL_EOI_EXIT_BITMAP_0 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 14) as isize,
|
||||
CTRL_EOI_EXIT_BITMAP_1 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 15) as isize,
|
||||
CTRL_EOI_EXIT_BITMAP_2 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 16) as isize,
|
||||
CTRL_EOI_EXIT_BITMAP_3 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 17) as isize,
|
||||
CTRL_EPT_LIST_ADDR = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 18) as isize,
|
||||
CTRL_VMREAD_BITMAP_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 19) as isize,
|
||||
CTRL_VMWRITE_BITMAP_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 20) as isize,
|
||||
CTRL_VIRT_EXECPT_INFO_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 21) as isize,
|
||||
CTRL_XSS_EXITING_BITMAP =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 22) as isize,
|
||||
CTRL_ENCLS_EXITING_BITMAP =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 23) as isize,
|
||||
CTRL_TSC_MULTIPLIER = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT64, 25) as isize,
|
||||
// 32-bit control fields
|
||||
CTRL_PIN_BASED_VM_EXEC_CTRLS =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 0) as isize, // control async event handling (i.e. interrupts)
|
||||
CTRL_PRIMARY_PROCESSOR_VM_EXEC_CTRLS =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 1) as isize, // control sync event handling (i.e. instruction exits)
|
||||
CTRL_EXPECTION_BITMAP = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 2) as isize, // bitmap to control exceptions that cause a VM exit
|
||||
CTRL_PAGE_FAULT_ERR_CODE_MASK =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 3) as isize,
|
||||
CTRL_PAGE_FAULT_ERR_CODE_MATCH =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 4) as isize,
|
||||
CTRL_CR3_TARGET_COUNT = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 5) as isize,
|
||||
CTRL_PRIMARY_VM_EXIT_CTRLS =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 6) as isize,
|
||||
CTRL_VM_EXIT_MSR_STORE_COUNT =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 7) as isize,
|
||||
CTRL_VM_EXIT_MSR_LOAD_COUNT =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 8) as isize,
|
||||
CTRL_VM_ENTRY_CTRLS = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 9) as isize,
|
||||
CTRL_VM_ENTRY_MSR_LOAD_COUNT =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 10) as isize,
|
||||
CTRL_VM_ENTRY_INTR_INFO_FIELD =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 11) as isize,
|
||||
CTRL_VM_ENTRY_EXCEPTION_ERR_CODE =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 12) as isize,
|
||||
CTRL_VM_ENTRY_INSTR_LEN =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 13) as isize,
|
||||
CTRL_TPR_THRESHOLD = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 14) as isize,
|
||||
CTRL_SECONDARY_PROCESSOR_VM_EXEC_CTRLS =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 15) as isize,
|
||||
CTRL_PLE_GAP = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 16) as isize,
|
||||
CTRL_PLE_WINDOW = encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::BIT32, 17) as isize,
|
||||
// natural control fields
|
||||
CTRL_CR0_GUEST_HOST_MASK =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 0) as isize, // control executions of insts that access cr0
|
||||
CTRL_CR4_GUEST_HOST_MASK =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 1) as isize,
|
||||
CTRL_CR0_READ_SHADOW =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 2) as isize, // control executions of insts that access cr0
|
||||
CTRL_CR4_READ_SHADOW =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 3) as isize,
|
||||
CTRL_CR3_TARGET_VALUE_0 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 4) as isize,
|
||||
CTRL_CR3_TARGET_VALUE_1 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 5) as isize,
|
||||
CTRL_CR3_TARGET_VALUE_2 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 6) as isize,
|
||||
CTRL_CR3_TARGET_VALUE_3 =
|
||||
encode_vmcs_field_full(VmcsType::CONTROL, VmcsWidth::NATURAL, 7) as isize,
|
||||
|
||||
// [VMEXIT] fields read-only
|
||||
// No 16-bit vmexit fields
|
||||
// 64-bit vmexit fields
|
||||
VMEXIT_GUEST_PHY_ADDR = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT64, 0) as isize,
|
||||
// 32-bit vmexit fields
|
||||
VMEXIT_INSTR_ERR = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 0) as isize,
|
||||
VMEXIT_EXIT_REASON = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 1) as isize,
|
||||
VMEXIT_INT_INFO = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 2) as isize,
|
||||
VMEXIT_INT_ERR_CODE = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 3) as isize,
|
||||
VMEXIT_IDT_VECTOR_INFO = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 4) as isize,
|
||||
VMEXIT_IDT_VECTOR_ERR_CODE =
|
||||
encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 5) as isize,
|
||||
VMEXIT_INSTR_LEN = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 6) as isize,
|
||||
VMEXIT_INSTR_INFO = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::BIT32, 7) as isize,
|
||||
// natural vmexit fields
|
||||
VMEXIT_QUALIFICATION = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::NATURAL, 0) as isize,
|
||||
VMEXIT_IO_RCX = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::NATURAL, 1) as isize,
|
||||
VMEXIT_IO_RSX = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::NATURAL, 2) as isize,
|
||||
VMEXIT_IO_RDI = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::NATURAL, 3) as isize,
|
||||
VMEXIT_IO_RIP = encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::NATURAL, 4) as isize,
|
||||
VMEXIT_GUEST_LINEAR_ADDR =
|
||||
encode_vmcs_field_full(VmcsType::VMEXIT, VmcsWidth::NATURAL, 5) as isize,
|
||||
|
||||
// [GUEST] fields
|
||||
// 16-bit guest fields
|
||||
GUEST_ES_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 0) as isize,
|
||||
GUEST_CS_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 1) as isize,
|
||||
GUEST_SS_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 2) as isize,
|
||||
GUEST_DS_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 3) as isize,
|
||||
GUEST_FS_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 4) as isize,
|
||||
GUEST_GS_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 5) as isize,
|
||||
GUEST_LDTR_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 6) as isize,
|
||||
GUEST_TR_SELECTOR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 7) as isize,
|
||||
GUEST_INTR_STATUS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 8) as isize,
|
||||
GUEST_PML_INDEX = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT16, 9) as isize,
|
||||
// 64-bit guest fields
|
||||
GUEST_VMCS_LINK_PTR = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 0) as isize,
|
||||
GUEST_DEBUGCTL = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 1) as isize,
|
||||
GUEST_PAT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 2) as isize,
|
||||
GUEST_EFER = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 3) as isize,
|
||||
GUEST_PERF_GLOBAL_CTRL = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 4) as isize,
|
||||
GUEST_PDPTE0 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 5) as isize,
|
||||
GUEST_PDPTE1 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 6) as isize,
|
||||
GUEST_PDPTE2 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 7) as isize,
|
||||
GUEST_PDPTE3 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT64, 8) as isize,
|
||||
// 32-bit guest fields
|
||||
GUEST_ES_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 0) as isize,
|
||||
GUEST_CS_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 1) as isize,
|
||||
GUEST_SS_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 2) as isize,
|
||||
GUEST_DS_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 3) as isize,
|
||||
GUEST_FS_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 4) as isize,
|
||||
GUEST_GS_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 5) as isize,
|
||||
GUEST_LDTR_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 6) as isize,
|
||||
GUEST_TR_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 7) as isize,
|
||||
GUEST_GDTR_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 8) as isize,
|
||||
GUEST_IDTR_LIMIT = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 9) as isize,
|
||||
GUEST_ES_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 10) as isize,
|
||||
GUEST_CS_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 11) as isize,
|
||||
GUEST_SS_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 12) as isize,
|
||||
GUEST_DS_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 13) as isize,
|
||||
GUEST_FS_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 14) as isize,
|
||||
GUEST_GS_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 15) as isize,
|
||||
GUEST_LDTR_ACCESS_RIGHTS =
|
||||
encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 16) as isize,
|
||||
GUEST_TR_ACCESS_RIGHTS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 17) as isize,
|
||||
GUEST_INTERRUPTIBILITY_STATE =
|
||||
encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 18) as isize,
|
||||
GUEST_ACTIVITY_STATE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 19) as isize,
|
||||
GUEST_SMBASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 20) as isize,
|
||||
GUEST_SYSENTER_CS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::BIT32, 21) as isize,
|
||||
GUEST_VMX_PREEMPT_TIMER_VALUE = 0x482E_isize,
|
||||
// natural guest fields
|
||||
GUEST_CR0 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 0) as isize,
|
||||
GUEST_CR3 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 1) as isize,
|
||||
GUEST_CR4 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 2) as isize,
|
||||
GUEST_ES_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 3) as isize,
|
||||
GUEST_CS_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 4) as isize,
|
||||
GUEST_SS_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 5) as isize,
|
||||
GUEST_DS_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 6) as isize,
|
||||
GUEST_FS_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 7) as isize,
|
||||
GUEST_GS_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 8) as isize,
|
||||
GUEST_LDTR_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 9) as isize,
|
||||
GUEST_TR_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 10) as isize,
|
||||
GUEST_GDTR_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 11) as isize,
|
||||
GUEST_IDTR_BASE = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 12) as isize,
|
||||
GUEST_DR7 = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 13) as isize,
|
||||
GUEST_RSP = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 14) as isize,
|
||||
GUEST_RIP = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 15) as isize,
|
||||
GUEST_RFLAGS = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 16) as isize,
|
||||
GUEST_PENDING_DBG_EXCEPTIONS =
|
||||
encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 17) as isize,
|
||||
GUEST_SYSENTER_ESP = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 18) as isize,
|
||||
GUEST_SYSENTER_EIP = encode_vmcs_field_full(VmcsType::GUEST, VmcsWidth::NATURAL, 19) as isize,
|
||||
|
||||
// [HOST] fields
|
||||
// host 16 bit fields
|
||||
HOST_ES_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 0) as isize,
|
||||
HOST_CS_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 1) as isize,
|
||||
HOST_SS_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 2) as isize,
|
||||
HOST_DS_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 3) as isize,
|
||||
HOST_FS_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 4) as isize,
|
||||
HOST_GS_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 5) as isize,
|
||||
HOST_TR_SELECTOR = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT16, 6) as isize,
|
||||
// host 64 bit fields
|
||||
HOST_PAT = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT64, 0) as isize,
|
||||
HOST_EFER = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT64, 1) as isize,
|
||||
HOST_PERF_GLOBAL_CTRL = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT64, 2) as isize,
|
||||
// host 32 bit fields
|
||||
HOST_SYSENTER_CS = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::BIT32, 0) as isize,
|
||||
// host natural fields
|
||||
HOST_CR0 = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 0) as isize,
|
||||
HOST_CR3 = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 1) as isize,
|
||||
HOST_CR4 = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 2) as isize,
|
||||
HOST_FS_BASE = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 3) as isize,
|
||||
HOST_GS_BASE = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 4) as isize,
|
||||
HOST_TR_BASE = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 5) as isize,
|
||||
HOST_GDTR_BASE = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 6) as isize,
|
||||
HOST_IDTR_BASE = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 7) as isize,
|
||||
HOST_SYSENTER_ESP = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 8) as isize,
|
||||
HOST_SYSENTER_EIP = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 9) as isize,
|
||||
HOST_RSP = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 10) as isize,
|
||||
HOST_RIP = encode_vmcs_field_full(VmcsType::HOST, VmcsWidth::NATURAL, 11) as isize,
|
||||
}
|
||||
|
||||
// (Intel Manual: 25.6 VM-EXECUTION CONTROL FIELDS)
|
||||
bitflags! {
|
||||
// (Intel Manual: 25.6.1 Pin-Based VM-Execution Controls)
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct VmxPinBasedExecuteCtrl: u32 {
|
||||
const EXTERNAL_INTERRUPT_EXITING = 1 << 0; // external interrupts cause VM exits
|
||||
const NMI_EXITING = 1 << 3; // non-maskable interrupts (NMIs) cause VM exits.
|
||||
const VIRTUAL_NMIS = 1 << 5; // NMIs are never blocked and the “blocking by NMI” bit (bit 3) in the interruptibility-state field indicates “virtual-NMI blocking”
|
||||
const VMX_PREEMPTION_TIMER = 1 << 6; // the VMX-preemption timer counts down in VMX non-root operation
|
||||
const PROCESS_POSTED_INTERRUPTS = 1 << 7; // he processor treats interrupts with the posted-interrupt notification vector
|
||||
}
|
||||
|
||||
// (Intel Manual: 25.6.2 Processor-Based VM-Execution Controls)
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct VmxPrimaryProcessBasedExecuteCtrl: u32{
|
||||
const INTERRUPT_WINDOW_EXITING = 1 << 2; // VM exits on interrupt window RFLAGS.IF = 1
|
||||
const USE_TSC_OFFSETTING = 1 << 3; // TSC offsetting is enabled
|
||||
const HLT_EXITING = 1 << 7;
|
||||
const INVLPG_EXITING = 1 << 9;
|
||||
const MWAIT_EXITING = 1 << 10;
|
||||
const RDPMC_EXITING = 1 << 11;
|
||||
const RDTSC_EXITING = 1 << 12;
|
||||
const CR3_LOAD_EXITING = 1 << 15;
|
||||
const CR3_STR_EXITING = 1 << 16;
|
||||
const CR8_LOAD_EXITING = 1 << 19;
|
||||
const CR8_STR_EXITING = 1 << 20;
|
||||
const USE_TPR_SHADOW = 1 << 21;
|
||||
const NMI_WINDOW_EXITING = 1 << 22;
|
||||
const MOV_DR_EXITING = 1 << 23;
|
||||
const UNCOND_IO_EXITING = 1 << 24;
|
||||
const USE_IO_BITMAPS = 1 << 25;
|
||||
const MONITOR_TRAP_FLAG = 1 << 27;
|
||||
const USE_MSR_BITMAPS = 1 << 28;
|
||||
const MONITOR_EXITING = 1 << 29;
|
||||
const PAUSE_EXITING = 1 << 30;
|
||||
const ACTIVATE_SECONDARY_CONTROLS = 1 << 31;
|
||||
}
|
||||
|
||||
// (Intel Manual: 25.6.2 Processor-Based VM-Execution Controls)
|
||||
pub struct VmxSecondaryProcessBasedExecuteCtrl: u32{
|
||||
const VIRT_APIC_ACCESS = 1 << 0;
|
||||
const ENABLE_EPT = 1 << 1;
|
||||
const DESCRIPTOR_TABLE_EXITING = 1 << 2;
|
||||
const ENABLE_RDTSCP = 1 << 3;
|
||||
const VIRT_X2APIC_MODE = 1 << 4;
|
||||
const ENABLE_VPID = 1 << 5;
|
||||
const WBINVD_EXITING = 1 << 6;
|
||||
const UNRESTRICTED_GUEST = 1 << 7;
|
||||
const APCI_REGISTER_VIRT = 1 << 8;
|
||||
const VIRT_INTR_DELIVERY = 1 << 9;
|
||||
const PAUSE_LOOP_EXITING = 1 << 10;
|
||||
const RDRAND_EXITING = 1 << 11;
|
||||
const ENABLE_INVPCID = 1 << 12;
|
||||
const ENABLE_VM_FUNCTIONS = 1 << 13;
|
||||
const VMCS_SHADOWING = 1 << 14;
|
||||
const ENABLE_ENCLS_EXITING = 1 << 15;
|
||||
const RDSEED_EXITING = 1 << 16;
|
||||
const ENABLE_PML = 1 << 17;
|
||||
const EPT_VIOLATION_VE = 1 << 18;
|
||||
const CONCEAL_VMX_FROM_PT = 1 << 19;
|
||||
const ENABLE_XSAVES_XRSTORS = 1 << 20;
|
||||
const PASID_TRANSLATION = 1 << 21;
|
||||
const MODE_BASED_EPT_EXEC = 1 << 22;
|
||||
const SUB_PAGE_WRITE_PERM = 1 << 23;
|
||||
const PT_USE_GUEST_PYH_ADDR = 1 << 24;
|
||||
const USE_TSC_SCALING = 1 << 25;
|
||||
const ENABLE_USER_WAIT_PAUSE = 1 << 26;
|
||||
const ENABLE_PCONFIG = 1 << 27;
|
||||
const ENABLE_ENCLV_EXITING = 1 << 28;
|
||||
const VMM_BUS_LOCK_DETECTION = 1 << 30;
|
||||
const INST_TIMEOUT = 1 << 31;
|
||||
}
|
||||
|
||||
// (Intel Manual: 25.7.1 VM-Exit Controls)
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct VmxPrimaryExitCtrl: u32 {
|
||||
const SAVE_DBG_CTRLS = 1 << 2;
|
||||
const HOST_ADDR_SPACE_SIZE = 1 << 9; // determines if a virtual processor will be in 64-bit mode after a VM exit
|
||||
const LOAD_IA32_PERF_GLOBAL_CTRL = 1 << 12;
|
||||
const ACK_INTERRUPT_ON_EXIT = 1 << 15;
|
||||
const SAVE_IA32_PAT = 1 << 18;
|
||||
const LOAD_IA32_PAT = 1 << 19;
|
||||
const SAVE_IA32_EFER = 1 << 20;
|
||||
const LOAD_IA32_EFER = 1 << 21;
|
||||
const SAVE_VMX_PREEMPT_TIMER_VALUE = 1 << 22;
|
||||
const CLEAR_IA32_BNDCFGS = 1 << 23;
|
||||
const CONCEAL_VMX_FROM_PT = 1 << 24;
|
||||
const CLEAR_IA32_RTIT_CTL = 1 << 25;
|
||||
const CLEAR_IA32_LBR_CTL = 1 << 26;
|
||||
const CLEAR_UINV = 1 << 27;
|
||||
const LOAD_CET_STATE = 1 << 28;
|
||||
const LOAD_PKRS = 1 << 29;
|
||||
const SAVE_IA32_PERF_GLOBAL_CTL = 1 << 30;
|
||||
const ACTIVATE_SECONDARY_CONTROLS = 1 << 31;
|
||||
}
|
||||
|
||||
// (Intel Manual: 25.8.1 VM-Entry Controls)
|
||||
#[allow(non_camel_case_types)]
|
||||
pub struct VmxEntryCtrl: u32 {
|
||||
const LOAD_DBG_CTRLS = 1 << 2;
|
||||
const IA32E_MODE_GUEST = 1 << 9;
|
||||
const ENTRY_TO_SMM = 1 << 10;
|
||||
const DEACTIVATE_DUAL_MONITOR = 1 << 11;
|
||||
const LOAD_IA32_PERF_GLOBAL_CTRL = 1 << 13;
|
||||
const LOAD_IA32_PAT = 1 << 14;
|
||||
const LOAD_IA32_EFER = 1 << 15;
|
||||
const LOAD_IA32_BNDCFGS = 1 << 16;
|
||||
const CONCEAL_VMX_FROM_PT = 1 << 17;
|
||||
const LOAD_IA32_RTIT_CTL = 1 << 18;
|
||||
const LOAD_UINV = 1 << 19;
|
||||
const LOAD_CET_STATE = 1 << 20;
|
||||
const LOAD_PKRS = 1 << 21;
|
||||
const LOAD_IA32_PERF_GLOBAL_CTL = 1 << 22;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(FromPrimitive)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum VmxExitReason {
|
||||
EXCEPTION_OR_NMI = 0,
|
||||
EXTERNAL_INTERRUPT = 1,
|
||||
TRIPLE_FAULT = 2,
|
||||
INIT_SIGNAL = 3,
|
||||
SIPI = 4,
|
||||
IO_SMI = 5,
|
||||
OTHER_SMI = 6,
|
||||
INTERRUPT_WINDOW = 7,
|
||||
NMI_WINDOW = 8,
|
||||
TASK_SWITCH = 9,
|
||||
CPUID = 10,
|
||||
GETSEC = 11,
|
||||
HLT = 12,
|
||||
INVD = 13,
|
||||
INVLPG = 14,
|
||||
RDPMC = 15,
|
||||
RDTSC = 16,
|
||||
RSM = 17,
|
||||
VMCALL = 18,
|
||||
VMCLEAR = 19,
|
||||
VMLAUNCH = 20,
|
||||
VMPTRLD = 21,
|
||||
VMPTRST = 22,
|
||||
VMREAD = 23,
|
||||
VMRESUME = 24,
|
||||
VMWRITE = 25,
|
||||
VMXOFF = 26,
|
||||
VMXON = 27,
|
||||
CR_ACCESS = 28,
|
||||
DR_ACCESS = 29,
|
||||
IO_INSTRUCTION = 30,
|
||||
RDMSR = 31,
|
||||
WRMSR = 32,
|
||||
VM_ENTRY_FAILURE_INVALID_GUEST_STATE = 33,
|
||||
VM_ENTRY_FAILURE_MSR_LOADING = 34,
|
||||
MWAIT = 36,
|
||||
MONITOR_TRAP_FLAG = 37,
|
||||
MONITOR = 39,
|
||||
PAUSE = 40,
|
||||
VM_ENTRY_FAILURE_MACHINE_CHECK_EVENT = 41,
|
||||
TPR_BELOW_THRESHOLD = 43,
|
||||
APIC_ACCESS = 44,
|
||||
VIRTUALIZED_EOI = 45,
|
||||
ACCESS_GDTR_OR_IDTR = 46,
|
||||
ACCESS_LDTR_OR_TR = 47,
|
||||
EPT_VIOLATION = 48,
|
||||
EPT_MISCONFIG = 49,
|
||||
INVEPT = 50,
|
||||
RDTSCP = 51,
|
||||
VMX_PREEMPTION_TIMER_EXPIRED = 52,
|
||||
INVVPID = 53,
|
||||
WBINVD = 54,
|
||||
XSETBV = 55,
|
||||
APIC_WRITE = 56,
|
||||
RDRAND = 57,
|
||||
INVPCID = 58,
|
||||
VMFUNC = 59,
|
||||
ENCLS = 60,
|
||||
RDSEED = 61,
|
||||
PML_FULL = 62,
|
||||
XSAVES = 63,
|
||||
XRSTORS = 64,
|
||||
}
|
||||
|
||||
impl From<i32> for VmxExitReason {
|
||||
fn from(num: i32) -> Self {
|
||||
match num {
|
||||
0 => VmxExitReason::EXCEPTION_OR_NMI,
|
||||
1 => VmxExitReason::EXTERNAL_INTERRUPT,
|
||||
2 => VmxExitReason::TRIPLE_FAULT,
|
||||
3 => VmxExitReason::INIT_SIGNAL,
|
||||
4 => VmxExitReason::SIPI,
|
||||
5 => VmxExitReason::IO_SMI,
|
||||
6 => VmxExitReason::OTHER_SMI,
|
||||
7 => VmxExitReason::INTERRUPT_WINDOW,
|
||||
8 => VmxExitReason::NMI_WINDOW,
|
||||
9 => VmxExitReason::TASK_SWITCH,
|
||||
10 => VmxExitReason::CPUID,
|
||||
11 => VmxExitReason::GETSEC,
|
||||
12 => VmxExitReason::HLT,
|
||||
13 => VmxExitReason::INVD,
|
||||
14 => VmxExitReason::INVLPG,
|
||||
15 => VmxExitReason::RDPMC,
|
||||
16 => VmxExitReason::RDTSC,
|
||||
17 => VmxExitReason::RSM,
|
||||
18 => VmxExitReason::VMCALL,
|
||||
19 => VmxExitReason::VMCLEAR,
|
||||
20 => VmxExitReason::VMLAUNCH,
|
||||
21 => VmxExitReason::VMPTRLD,
|
||||
22 => VmxExitReason::VMPTRST,
|
||||
23 => VmxExitReason::VMREAD,
|
||||
24 => VmxExitReason::VMRESUME,
|
||||
25 => VmxExitReason::VMWRITE,
|
||||
26 => VmxExitReason::VMXOFF,
|
||||
27 => VmxExitReason::VMXON,
|
||||
28 => VmxExitReason::CR_ACCESS,
|
||||
29 => VmxExitReason::DR_ACCESS,
|
||||
30 => VmxExitReason::IO_INSTRUCTION,
|
||||
31 => VmxExitReason::RDMSR,
|
||||
32 => VmxExitReason::WRMSR,
|
||||
33 => VmxExitReason::VM_ENTRY_FAILURE_INVALID_GUEST_STATE,
|
||||
34 => VmxExitReason::VM_ENTRY_FAILURE_MSR_LOADING,
|
||||
36 => VmxExitReason::MWAIT,
|
||||
37 => VmxExitReason::MONITOR_TRAP_FLAG,
|
||||
39 => VmxExitReason::MONITOR,
|
||||
40 => VmxExitReason::PAUSE,
|
||||
41 => VmxExitReason::VM_ENTRY_FAILURE_MACHINE_CHECK_EVENT,
|
||||
43 => VmxExitReason::TPR_BELOW_THRESHOLD,
|
||||
44 => VmxExitReason::APIC_ACCESS,
|
||||
45 => VmxExitReason::VIRTUALIZED_EOI,
|
||||
46 => VmxExitReason::ACCESS_GDTR_OR_IDTR,
|
||||
47 => VmxExitReason::ACCESS_LDTR_OR_TR,
|
||||
48 => VmxExitReason::EPT_VIOLATION,
|
||||
49 => VmxExitReason::EPT_MISCONFIG,
|
||||
50 => VmxExitReason::INVEPT,
|
||||
51 => VmxExitReason::RDTSCP,
|
||||
52 => VmxExitReason::VMX_PREEMPTION_TIMER_EXPIRED,
|
||||
53 => VmxExitReason::INVVPID,
|
||||
54 => VmxExitReason::WBINVD,
|
||||
55 => VmxExitReason::XSETBV,
|
||||
56 => VmxExitReason::APIC_WRITE,
|
||||
57 => VmxExitReason::RDRAND,
|
||||
58 => VmxExitReason::INVPCID,
|
||||
59 => VmxExitReason::VMFUNC,
|
||||
60 => VmxExitReason::ENCLS,
|
||||
61 => VmxExitReason::RDSEED,
|
||||
62 => VmxExitReason::PML_FULL,
|
||||
63 => VmxExitReason::XSAVES,
|
||||
64 => VmxExitReason::XRSTORS,
|
||||
_ => panic!("Invalid VmxExitReason number: {}", num),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn encode_vmcs_field(
|
||||
access_type: VmcsAccessType,
|
||||
vmcs_type: VmcsType,
|
||||
vmcs_width: VmcsWidth,
|
||||
index: u32,
|
||||
) -> u32 {
|
||||
let mut encoding: u32 = 0;
|
||||
encoding |=
|
||||
(access_type as u32) | (index) << 1 | (vmcs_type as u32) << 10 | (vmcs_width as u32) << 13;
|
||||
return encoding;
|
||||
}
|
||||
|
||||
const fn encode_vmcs_field_full(vmcs_type: VmcsType, vmcs_width: VmcsWidth, index: u32) -> u32 {
|
||||
encode_vmcs_field(VmcsAccessType::FULL, vmcs_type, vmcs_width, index)
|
||||
}
|
||||
|
||||
// fn decode_vmcs_field(field: u32) -> (VmcsAccessType, VmcsType, VmcsWidth, u16){
|
||||
// (FromPrimitive::from_u32(field & 1).unwrap() ,
|
||||
// FromPrimitive::from_u32((field>>10) & 0x3).unwrap(),
|
||||
// FromPrimitive::from_u32((field>>13) & 0x3).unwrap(),
|
||||
// ((field>>1) & 0x1ff) as u16
|
||||
// )
|
||||
// }
|
@ -1,271 +0,0 @@
|
||||
use super::vmcs::{VmcsFields, VmxExitReason};
|
||||
use super::vmx_asm_wrapper::{vmx_vmread, vmx_vmwrite};
|
||||
|
||||
use crate::virt::kvm::vm;
|
||||
use core::arch::asm;
|
||||
use log::debug;
|
||||
use system_error::SystemError;
|
||||
use x86::vmx::vmcs::ro::GUEST_PHYSICAL_ADDR_FULL;
|
||||
|
||||
#[derive(FromPrimitive)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum APICExceptionVectors {
|
||||
EXCEPTION_DIVIDE_ERROR,
|
||||
EXCEPTION_DEBUG_BREAKPOINT,
|
||||
EXCEPTION_NMI,
|
||||
EXCEPTION_BREAKPOINT,
|
||||
EXCEPTION_OVERFLOW,
|
||||
EXCEPTION_BOUND_RANGE_EXCEEDED,
|
||||
EXCEPTION_UNDEFINED_OPCODE,
|
||||
EXCEPTION_NO_MATH_COPROCESSOR,
|
||||
EXCEPTION_DOUBLE_FAULT,
|
||||
EXCEPTION_RESERVED0,
|
||||
EXCEPTION_INVALID_TASK_SEGMENT_SELECTOR,
|
||||
EXCEPTION_SEGMENT_NOT_PRESENT,
|
||||
EXCEPTION_STACK_SEGMENT_FAULT,
|
||||
EXCEPTION_GENERAL_PROTECTION_FAULT,
|
||||
EXCEPTION_PAGE_FAULT,
|
||||
EXCEPTION_RESERVED1,
|
||||
EXCEPTION_MATH_FAULT,
|
||||
EXCEPTION_ALIGNMENT_CHECK,
|
||||
EXCEPTION_MACHINE_CHECK,
|
||||
EXCEPTION_SIMD_FLOATING_POINT_NUMERIC_ERROR,
|
||||
EXCEPTION_VIRTUAL_EXCEPTION,
|
||||
EXCEPTION_RESERVED2,
|
||||
EXCEPTION_RESERVED3,
|
||||
EXCEPTION_RESERVED4,
|
||||
EXCEPTION_RESERVED5,
|
||||
EXCEPTION_RESERVED6,
|
||||
EXCEPTION_RESERVED7,
|
||||
EXCEPTION_RESERVED8,
|
||||
EXCEPTION_RESERVED9,
|
||||
EXCEPTION_RESERVED10,
|
||||
EXCEPTION_RESERVED11,
|
||||
EXCEPTION_RESERVED12,
|
||||
}
|
||||
|
||||
#[derive(FromPrimitive)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum InterruptType {
|
||||
INTERRUPT_TYPE_EXTERNAL_INTERRUPT = 0,
|
||||
INTERRUPT_TYPE_RESERVED = 1,
|
||||
INTERRUPT_TYPE_NMI = 2,
|
||||
INTERRUPT_TYPE_HARDWARE_EXCEPTION = 3,
|
||||
INTERRUPT_TYPE_SOFTWARE_INTERRUPT = 4,
|
||||
INTERRUPT_TYPE_PRIVILEGED_SOFTWARE_INTERRUPT = 5,
|
||||
INTERRUPT_TYPE_SOFTWARE_EXCEPTION = 6,
|
||||
INTERRUPT_TYPE_OTHER_EVENT = 7,
|
||||
}
|
||||
|
||||
pub fn vmexit_vmx_instruction_executed() -> Result<(), SystemError> {
|
||||
let valid: u32 = 1;
|
||||
let vector: u32 = APICExceptionVectors::EXCEPTION_UNDEFINED_OPCODE as u32;
|
||||
let interrupt_type = InterruptType::INTERRUPT_TYPE_HARDWARE_EXCEPTION as u32;
|
||||
let deliver_code: u32 = 0;
|
||||
let interrupt_info = valid << 31 | interrupt_type << 8 | deliver_code << 11 | vector;
|
||||
vmx_vmwrite(
|
||||
VmcsFields::CTRL_VM_ENTRY_INTR_INFO_FIELD as u32,
|
||||
interrupt_info as u64,
|
||||
)?;
|
||||
vmx_vmwrite(VmcsFields::CTRL_VM_ENTRY_INSTR_LEN as u32, 0)?;
|
||||
let rflags: u64 = vmx_vmread(VmcsFields::GUEST_RFLAGS as u32).unwrap() | 0x0001_0000; // set RF flags
|
||||
vmx_vmwrite(VmcsFields::GUEST_RFLAGS as u32, rflags)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// pub fn vmexit_cpuid_handler(guest_cpu_context: &mut GuestCpuContext) -> Result<(), SystemError>{
|
||||
// let rax = guest_cpu_context.rax;
|
||||
// let rcx = guest_cpu_context.rcx;
|
||||
// // let rdx = guest_cpu_context.rdx;
|
||||
// // let rbx = guest_cpu_context.rbx;
|
||||
// cpuid!(rax, rcx);
|
||||
// unsafe{asm!("mov {}, rax", out(reg) guest_cpu_context.rax)};
|
||||
// unsafe{asm!("mov {}, rcx", out(reg) guest_cpu_context.rcx)};
|
||||
// unsafe{asm!("mov {}, rdx", out(reg) guest_cpu_context.rdx)};
|
||||
// unsafe{asm!("mov {}, rbx", out(reg) guest_cpu_context.rbx)};
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
unsafe fn save_rpg() {
|
||||
asm!(
|
||||
"push rax",
|
||||
"push rcx",
|
||||
"push rdx",
|
||||
"push rbx",
|
||||
"push rbp",
|
||||
"push rsi",
|
||||
"push rdi",
|
||||
"push r8",
|
||||
"push r9",
|
||||
"push r10",
|
||||
"push r11",
|
||||
"push r12",
|
||||
"push r13",
|
||||
"push r14",
|
||||
"push r15",
|
||||
);
|
||||
}
|
||||
|
||||
unsafe fn restore_rpg() {
|
||||
asm!(
|
||||
"pop r15",
|
||||
"pop r14",
|
||||
"pop r13",
|
||||
"pop r12",
|
||||
"pop r11",
|
||||
"pop r10",
|
||||
"pop r9",
|
||||
"pop r8",
|
||||
"pop rdi",
|
||||
"pop rsi",
|
||||
"pop rbp",
|
||||
"pop rbx",
|
||||
"pop rdx",
|
||||
"pop rcx",
|
||||
"pop rax",
|
||||
);
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(dead_code)]
|
||||
pub struct GuestCpuContext {
|
||||
pub r15: u64,
|
||||
pub r14: u64,
|
||||
pub r13: u64,
|
||||
pub r12: u64,
|
||||
pub r11: u64,
|
||||
pub r10: u64,
|
||||
pub r9: u64,
|
||||
pub r8: u64,
|
||||
pub rdi: u64,
|
||||
pub rsi: u64,
|
||||
pub rbp: u64,
|
||||
pub rbx: u64,
|
||||
pub rdx: u64,
|
||||
pub rcx: u64,
|
||||
pub rax: u64,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn vmx_return() {
|
||||
debug!("vmx_return!");
|
||||
unsafe { save_rpg() };
|
||||
vmexit_handler();
|
||||
// XMM registers are vector registers. They're renamed onto the FP/SIMD register file
|
||||
// unsafe {asm!(
|
||||
// "sub rsp, 60h",
|
||||
// "movaps xmmword ptr [rsp + 0h], xmm0",
|
||||
// "movaps xmmword ptr [rsp + 10h], xmm1",
|
||||
// "movaps xmmword ptr [rsp + 20h], xmm2",
|
||||
// "movaps xmmword ptr [rsp + 30h], xmm3",
|
||||
// "movaps xmmword ptr [rsp + 40h], xmm4",
|
||||
// "movaps xmmword ptr [rsp + 50h], xmm5",
|
||||
|
||||
// "mov rdi, rsp",
|
||||
// "sub rsp, 20h",
|
||||
// "call vmexit_handler",
|
||||
// "add rsp, 20h",
|
||||
|
||||
// "movaps xmm0, xmmword ptr [rsp + 0h]",
|
||||
// "movaps xmm1, xmmword ptr [rsp + 10h]",
|
||||
// "movaps xmm2, xmmword ptr [rsp + 20h]",
|
||||
// "movaps xmm3, xmmword ptr [rsp + 30h]",
|
||||
// "movaps xmm4, xmmword ptr [rsp + 40h]",
|
||||
// "movaps xmm5, xmmword ptr [rsp + 50h]",
|
||||
// "add rsp, 60h",
|
||||
// clobber_abi("C"),
|
||||
// )};
|
||||
unsafe { restore_rpg() };
|
||||
unsafe { asm!("vmresume",) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn vmexit_handler() {
|
||||
// let guest_cpu_context = unsafe { guest_cpu_context_ptr.as_mut().unwrap() };
|
||||
// debug!("guest_cpu_context_ptr={:p}",guest_cpu_context_ptr);
|
||||
debug!("vmexit handler!");
|
||||
|
||||
let exit_reason = vmx_vmread(VmcsFields::VMEXIT_EXIT_REASON as u32).unwrap() as u32;
|
||||
let exit_basic_reason = exit_reason & 0x0000_ffff;
|
||||
let guest_rip = vmx_vmread(VmcsFields::GUEST_RIP as u32).unwrap();
|
||||
// let guest_rsp = vmx_vmread(VmcsFields::GUEST_RSP as u32).unwrap();
|
||||
debug!("guest_rip={:x}", guest_rip);
|
||||
let _guest_rflags = vmx_vmread(VmcsFields::GUEST_RFLAGS as u32).unwrap();
|
||||
|
||||
match VmxExitReason::from(exit_basic_reason as i32) {
|
||||
VmxExitReason::VMCALL
|
||||
| VmxExitReason::VMCLEAR
|
||||
| VmxExitReason::VMLAUNCH
|
||||
| VmxExitReason::VMPTRLD
|
||||
| VmxExitReason::VMPTRST
|
||||
| VmxExitReason::VMREAD
|
||||
| VmxExitReason::VMRESUME
|
||||
| VmxExitReason::VMWRITE
|
||||
| VmxExitReason::VMXOFF
|
||||
| VmxExitReason::VMXON
|
||||
| VmxExitReason::VMFUNC
|
||||
| VmxExitReason::INVEPT
|
||||
| VmxExitReason::INVVPID => {
|
||||
debug!("vmexit handler: vmx instruction!");
|
||||
vmexit_vmx_instruction_executed().expect("previledge instruction handle error");
|
||||
}
|
||||
VmxExitReason::CPUID => {
|
||||
debug!("vmexit handler: cpuid instruction!");
|
||||
// vmexit_cpuid_handler(guest_cpu_context);
|
||||
adjust_rip(guest_rip).unwrap();
|
||||
}
|
||||
VmxExitReason::RDMSR => {
|
||||
debug!("vmexit handler: rdmsr instruction!");
|
||||
adjust_rip(guest_rip).unwrap();
|
||||
}
|
||||
VmxExitReason::WRMSR => {
|
||||
debug!("vmexit handler: wrmsr instruction!");
|
||||
adjust_rip(guest_rip).unwrap();
|
||||
}
|
||||
VmxExitReason::TRIPLE_FAULT => {
|
||||
debug!("vmexit handler: triple fault!");
|
||||
adjust_rip(guest_rip).unwrap();
|
||||
}
|
||||
VmxExitReason::EPT_VIOLATION => {
|
||||
debug!("vmexit handler: ept violation!");
|
||||
let gpa = vmx_vmread(GUEST_PHYSICAL_ADDR_FULL).unwrap();
|
||||
let exit_qualification = vmx_vmread(VmcsFields::VMEXIT_QUALIFICATION as u32).unwrap();
|
||||
/* It is a write fault? */
|
||||
let mut error_code = exit_qualification & (1 << 1);
|
||||
/* It is a fetch fault? */
|
||||
error_code |= (exit_qualification << 2) & (1 << 4);
|
||||
/* ept page table is present? */
|
||||
error_code |= (exit_qualification >> 3) & (1 << 0);
|
||||
|
||||
let kvm = vm(0).unwrap();
|
||||
let vcpu = kvm.vcpu[0].clone();
|
||||
// Use the data
|
||||
let kvm_ept_page_fault = vcpu.lock().mmu.page_fault.unwrap();
|
||||
kvm_ept_page_fault(&mut vcpu.lock(), gpa, error_code as u32, false)
|
||||
.expect("ept page fault error");
|
||||
}
|
||||
_ => {
|
||||
debug!(
|
||||
"vmexit handler: unhandled vmexit reason: {}!",
|
||||
exit_basic_reason
|
||||
);
|
||||
|
||||
let info = vmx_vmread(VmcsFields::VMEXIT_INSTR_LEN as u32).unwrap() as u32;
|
||||
debug!("vmexit handler: VMEXIT_INSTR_LEN: {}!", info);
|
||||
let info = vmx_vmread(VmcsFields::VMEXIT_INSTR_INFO as u32).unwrap() as u32;
|
||||
debug!("vmexit handler: VMEXIT_INSTR_INFO: {}!", info);
|
||||
let info = vmx_vmread(VmcsFields::CTRL_EXPECTION_BITMAP as u32).unwrap() as u32;
|
||||
debug!("vmexit handler: CTRL_EXPECTION_BITMAP: {}!", info);
|
||||
|
||||
adjust_rip(guest_rip).unwrap();
|
||||
// panic!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn adjust_rip(rip: u64) -> Result<(), SystemError> {
|
||||
let instruction_length = vmx_vmread(VmcsFields::VMEXIT_INSTR_LEN as u32)?;
|
||||
vmx_vmwrite(VmcsFields::GUEST_RIP as u32, rip + instruction_length)?;
|
||||
Ok(())
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
use super::vmcs::VmcsFields;
|
||||
|
||||
use core::arch::asm;
|
||||
use log::debug;
|
||||
use system_error::SystemError;
|
||||
use x86;
|
||||
/// Enable VMX operation.
|
||||
pub fn vmxon(vmxon_pa: u64) -> Result<(), SystemError> {
|
||||
match unsafe { x86::bits64::vmx::vmxon(vmxon_pa) } {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => {
|
||||
debug!("vmxon fail: {:?}", e);
|
||||
Err(SystemError::EVMXONFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Disable VMX operation.
|
||||
pub fn vmxoff() -> Result<(), SystemError> {
|
||||
match unsafe { x86::bits64::vmx::vmxoff() } {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(SystemError::EVMXOFFFailed),
|
||||
}
|
||||
}
|
||||
|
||||
/// vmrite the current VMCS.
|
||||
pub fn vmx_vmwrite(vmcs_field: u32, value: u64) -> Result<(), SystemError> {
|
||||
match unsafe { x86::bits64::vmx::vmwrite(vmcs_field, value) } {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => {
|
||||
debug!("vmx_write fail: {:?}", e);
|
||||
debug!("vmcs_field: {:x}", vmcs_field);
|
||||
Err(SystemError::EVMWRITEFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// vmread the current VMCS.
|
||||
pub fn vmx_vmread(vmcs_field: u32) -> Result<u64, SystemError> {
|
||||
match unsafe { x86::bits64::vmx::vmread(vmcs_field) } {
|
||||
Ok(value) => Ok(value),
|
||||
Err(e) => {
|
||||
debug!("vmx_read fail: {:?}", e);
|
||||
Err(SystemError::EVMREADFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vmx_vmptrld(vmcs_pa: u64) -> Result<(), SystemError> {
|
||||
match unsafe { x86::bits64::vmx::vmptrld(vmcs_pa) } {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(SystemError::EVMPRTLDFailed),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vmx_vmlaunch() -> Result<(), SystemError> {
|
||||
let host_rsp = VmcsFields::HOST_RSP as u32;
|
||||
let host_rip = VmcsFields::HOST_RIP as u32;
|
||||
unsafe {
|
||||
asm!(
|
||||
"push rbp",
|
||||
"push rcx",
|
||||
"push rdx",
|
||||
"push rsi",
|
||||
"push rdi",
|
||||
"vmwrite {0:r}, rsp",
|
||||
"lea rax, 2f[rip]",
|
||||
"vmwrite {1:r}, rax",
|
||||
"vmlaunch",
|
||||
"2:",
|
||||
"pop rdi",
|
||||
"pop rsi",
|
||||
"pop rdx",
|
||||
"pop rcx",
|
||||
"pop rbp",
|
||||
"call vmx_return",
|
||||
in(reg) host_rsp,
|
||||
in(reg) host_rip,
|
||||
clobber_abi("C"),
|
||||
)
|
||||
}
|
||||
Ok(())
|
||||
// match unsafe { x86::bits64::vmx::vmlaunch() } {
|
||||
// Ok(_) => Ok(()),
|
||||
// Err(e) => {
|
||||
// debug!("vmx_launch fail: {:?}", e);
|
||||
// Err(SystemError::EVMLAUNCHFailed)
|
||||
// },
|
||||
// }
|
||||
}
|
||||
|
||||
pub fn vmx_vmclear(vmcs_pa: u64) -> Result<(), SystemError> {
|
||||
match unsafe { x86::bits64::vmx::vmclear(vmcs_pa) } {
|
||||
Ok(_) => Ok(()),
|
||||
Err(_) => Err(SystemError::EVMPRTLDFailed),
|
||||
}
|
||||
}
|
@ -36,9 +36,6 @@ use core::fmt::Debug;
|
||||
|
||||
use core::sync::atomic::{compiler_fence, AtomicBool, Ordering};
|
||||
|
||||
use super::kvm::vmx::vmcs::VmcsFields;
|
||||
use super::kvm::vmx::vmx_asm_wrapper::vmx_vmread;
|
||||
|
||||
pub type PageMapper =
|
||||
crate::mm::page::PageMapper<crate::arch::x86_64::mm::X86_64MMArch, LockedFrameAllocator>;
|
||||
|
||||
@ -199,10 +196,8 @@ impl MemoryManagementArch for X86_64MMArch {
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
return PhysAddr::new(cr3);
|
||||
}
|
||||
PageTableKind::EPT => {
|
||||
let eptp =
|
||||
vmx_vmread(VmcsFields::CTRL_EPTP_PTR as u32).expect("Failed to read eptp");
|
||||
return PhysAddr::new(eptp as usize);
|
||||
_ => {
|
||||
todo!("Unsupported table kind: {:?}", table_kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ pub mod init;
|
||||
pub mod interrupt;
|
||||
pub mod ipc;
|
||||
pub mod kprobe;
|
||||
pub mod kvm;
|
||||
pub mod libs;
|
||||
pub mod mm;
|
||||
pub mod msi;
|
||||
@ -30,7 +29,6 @@ pub use self::mm::X86_64MMArch as MMArch;
|
||||
pub use interrupt::X86_64InterruptArch as CurrentIrqArch;
|
||||
|
||||
pub use crate::arch::asm::pio::X86_64PortIOArch as CurrentPortIOArch;
|
||||
pub use kvm::X86_64KVMArch as KVMArch;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use crate::arch::ipc::signal::X86_64SignalArch as CurrentSignalArch;
|
||||
|
@ -2,7 +2,6 @@ use crate::arch::mm::X86_64MMArch;
|
||||
use crate::arch::vm::asm::VmxAsm;
|
||||
use crate::arch::vm::kvm_host::page::KVM_MIN_FREE_MMU_PAGES;
|
||||
use crate::mm::PhysAddr;
|
||||
use crate::virt::kvm::host_mem::PAGE_SHIFT;
|
||||
use crate::{
|
||||
arch::{mm::LockedFrameAllocator, MMArch, VirtCpuArch},
|
||||
libs::spinlock::{SpinLock, SpinLockGuard},
|
||||
@ -37,7 +36,7 @@ static mut MAX_TDP_LEVEL: usize = 0;
|
||||
static mut SHADOW_ACCESSED_MASK: usize = 0;
|
||||
|
||||
static mut MAX_HUGE_PAGE_LEVEL: PageLevel = PageLevel::None;
|
||||
|
||||
pub const PAGE_SHIFT: u32 = 12;
|
||||
pub const PAGE_SIZE: u64 = 1 << PAGE_SHIFT;
|
||||
|
||||
pub fn is_tdp_mmu_enabled() -> bool {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::mm::page::EntryFlags;
|
||||
use crate::{arch::vm::mmu::kvm_mmu::PAGE_SHIFT, mm::page::EntryFlags};
|
||||
use alloc::sync::Arc;
|
||||
use core::{intrinsics::unlikely, ops::Index};
|
||||
use log::{debug, warn};
|
||||
@ -18,14 +18,11 @@ use crate::{
|
||||
MMArch,
|
||||
},
|
||||
mm::PhysAddr,
|
||||
virt::{
|
||||
kvm::host_mem::PAGE_SHIFT,
|
||||
vm::kvm_host::{
|
||||
mem::{LockedKvmMemSlot, LockedVmMemSlotSet, UserMemRegionFlag, __gfn_to_pfn_memslot},
|
||||
search_memslots,
|
||||
vcpu::VirtCpu,
|
||||
Vm,
|
||||
},
|
||||
virt::vm::kvm_host::{
|
||||
mem::{LockedKvmMemSlot, LockedVmMemSlotSet, UserMemRegionFlag, __gfn_to_pfn_memslot},
|
||||
search_memslots,
|
||||
vcpu::VirtCpu,
|
||||
Vm,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -227,7 +227,7 @@ pub struct EptPageMapper {
|
||||
/// EPT页表映射器
|
||||
//mapper: PageMapper,//PageTableKind::EPT, LockedFrameAllocator
|
||||
/// 标记当前映射器是否为只读
|
||||
readonly: bool,
|
||||
_readonly: bool,
|
||||
// EPT页表根地址
|
||||
root_page_addr: PhysAddr,
|
||||
/// 页分配器
|
||||
@ -273,7 +273,7 @@ impl EptPageMapper {
|
||||
let readonly = prev_count > 0;
|
||||
let root_page_addr = Self::root_page_addr();
|
||||
return Self {
|
||||
readonly,
|
||||
_readonly: readonly,
|
||||
root_page_addr,
|
||||
frame_allocator: LockedFrameAllocator,
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
use alloc::boxed::Box;
|
||||
use core::intrinsics::likely;
|
||||
use core::ops::BitXor;
|
||||
|
||||
@ -116,8 +117,8 @@ pub struct NTtyData {
|
||||
echo_tail: usize,
|
||||
|
||||
/// 写者与读者共享
|
||||
read_buf: [u8; NTTY_BUFSIZE],
|
||||
echo_buf: [u8; NTTY_BUFSIZE],
|
||||
read_buf: Box<[u8; NTTY_BUFSIZE]>,
|
||||
echo_buf: Box<[u8; NTTY_BUFSIZE]>,
|
||||
|
||||
read_flags: StaticBitmap<NTTY_BUFSIZE>,
|
||||
char_map: StaticBitmap<256>,
|
||||
@ -126,6 +127,7 @@ pub struct NTtyData {
|
||||
}
|
||||
|
||||
impl NTtyData {
|
||||
#[inline(never)]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
read_head: 0,
|
||||
@ -147,8 +149,8 @@ impl NTtyData {
|
||||
cursor_column: 0,
|
||||
canon_cursor_column: 0,
|
||||
echo_tail: 0,
|
||||
read_buf: [0; NTTY_BUFSIZE],
|
||||
echo_buf: [0; NTTY_BUFSIZE],
|
||||
read_buf: Box::new([0; NTTY_BUFSIZE]),
|
||||
echo_buf: Box::new([0; NTTY_BUFSIZE]),
|
||||
read_flags: StaticBitmap::new(),
|
||||
char_map: StaticBitmap::new(),
|
||||
tty: Weak::default(),
|
||||
|
@ -15,7 +15,7 @@ use core::{
|
||||
|
||||
use super::{
|
||||
page_frame::{FrameAllocator, PageFrameCount},
|
||||
slab::{slab_init_state, SLABALLOCATOR},
|
||||
slab::SLABALLOCATOR,
|
||||
};
|
||||
|
||||
/// 类kmalloc的分配器应当实现的trait
|
||||
@ -95,7 +95,7 @@ impl LocalAlloc for KernelAllocator {
|
||||
}
|
||||
|
||||
unsafe fn local_dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||
if allocator_select_condition(layout) || ((ptr as usize) % 4096) == 0 {
|
||||
if allocator_select_condition(layout) {
|
||||
self.free_in_buddy(ptr, layout)
|
||||
} else if let Some(ref mut slab) = SLABALLOCATOR {
|
||||
slab.deallocate(ptr, layout).unwrap()
|
||||
@ -137,7 +137,7 @@ unsafe impl GlobalAlloc for KernelAllocator {
|
||||
|
||||
/// 判断选择buddy分配器还是slab分配器
|
||||
fn allocator_select_condition(layout: Layout) -> bool {
|
||||
layout.size() > 2048 || !slab_init_state()
|
||||
layout.size() > 2048
|
||||
}
|
||||
|
||||
fn alloc_debug_log(source: LogSource, layout: Layout, ptr: *mut u8) {
|
||||
|
@ -72,11 +72,6 @@ pub unsafe fn slab_init() {
|
||||
SLABINITSTATE = true.into();
|
||||
}
|
||||
|
||||
// 查看slab初始化状态
|
||||
pub fn slab_init_state() -> bool {
|
||||
unsafe { *SLABINITSTATE.get_mut() }
|
||||
}
|
||||
|
||||
pub unsafe fn slab_usage() -> SlabUsage {
|
||||
if let Some(ref mut slab) = SLABALLOCATOR {
|
||||
slab.zone.usage()
|
||||
|
@ -1,2 +1 @@
|
||||
pub mod kvm;
|
||||
pub mod vm;
|
||||
|
@ -8,17 +8,17 @@ use log::debug;
|
||||
use system_error::SystemError;
|
||||
|
||||
use crate::{
|
||||
arch::{vm::mmu::kvm_mmu::PAGE_SIZE, MMArch},
|
||||
arch::{
|
||||
vm::mmu::kvm_mmu::{PAGE_SHIFT, PAGE_SIZE},
|
||||
MMArch,
|
||||
},
|
||||
libs::{
|
||||
rbtree::RBTree,
|
||||
rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard},
|
||||
spinlock::{SpinLock, SpinLockGuard},
|
||||
},
|
||||
mm::{kernel_mapper::KernelMapper, page::EntryFlags, MemoryManagementArch, VirtAddr},
|
||||
virt::{
|
||||
kvm::host_mem::PAGE_SHIFT,
|
||||
vm::{kvm_host::KVM_ADDRESS_SPACE_NUM, user_api::KvmUserspaceMemoryRegion},
|
||||
},
|
||||
virt::vm::{kvm_host::KVM_ADDRESS_SPACE_NUM, user_api::KvmUserspaceMemoryRegion},
|
||||
};
|
||||
|
||||
use super::{LockedVm, Vm};
|
||||
|
@ -200,17 +200,17 @@ impl Vm {
|
||||
kvm: Some(self.lock_vm_ref.clone()),
|
||||
vcpu_id: id,
|
||||
pid: None,
|
||||
preempted: false,
|
||||
ready: false,
|
||||
last_used_slot: None,
|
||||
stats_id: format!("kvm-{}/vcpu-{}", ProcessManager::current_pid().data(), id),
|
||||
pv_time: GfnToHvaCache::init(self.lock_vm_ref.clone(), PfnCacheUsage::HOST_USES_PFN),
|
||||
_preempted: false,
|
||||
_ready: false,
|
||||
_last_used_slot: None,
|
||||
_stats_id: format!("kvm-{}/vcpu-{}", ProcessManager::current_pid().data(), id),
|
||||
_pv_time: GfnToHvaCache::init(self.lock_vm_ref.clone(), PfnCacheUsage::HOST_USES_PFN),
|
||||
arch: VirtCpuArch::new(),
|
||||
private: None,
|
||||
request: VirtCpuRequest::empty(),
|
||||
guest_debug: GuestDebug::empty(),
|
||||
run: unsafe { Some(Box::new_zeroed().assume_init()) },
|
||||
vcpu_idx: 0,
|
||||
_vcpu_idx: 0,
|
||||
mode: VcpuMode::OutsideGuestMode,
|
||||
stat: Default::default(),
|
||||
};
|
||||
|
@ -56,13 +56,13 @@ pub struct VirtCpu {
|
||||
/// 从用户层获取
|
||||
pub vcpu_id: usize,
|
||||
/// id alloctor获取
|
||||
pub vcpu_idx: usize,
|
||||
pub _vcpu_idx: usize,
|
||||
pub pid: Option<Pid>,
|
||||
pub preempted: bool,
|
||||
pub ready: bool,
|
||||
pub last_used_slot: Option<Arc<KvmMemSlot>>,
|
||||
pub stats_id: String,
|
||||
pub pv_time: GfnToHvaCache,
|
||||
pub _preempted: bool,
|
||||
pub _ready: bool,
|
||||
pub _last_used_slot: Option<Arc<KvmMemSlot>>,
|
||||
pub _stats_id: String,
|
||||
pub _pv_time: GfnToHvaCache,
|
||||
pub arch: VirtCpuArch,
|
||||
pub stat: VirtCpuStat,
|
||||
|
||||
|
1009
tools/Cargo.lock
generated
Normal file
1009
tools/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
764
user/apps/syscall_ebpf/Cargo.lock
generated
Normal file
764
user/apps/syscall_ebpf/Cargo.lock
generated
Normal file
@ -0,0 +1,764 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
|
||||
|
||||
[[package]]
|
||||
name = "assert_matches"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
|
||||
|
||||
[[package]]
|
||||
name = "aya"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d18bc4e506fbb85ab7392ed993a7db4d1a452c71b75a246af4a80ab8c9d2dd50"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"aya-obj",
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"libc",
|
||||
"log",
|
||||
"object",
|
||||
"once_cell",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8dbaf5409a1a0982e5c9bdc0f499a55fe5ead39fe9c846012053faf0d404f73"
|
||||
dependencies = [
|
||||
"aya-ebpf-bindings",
|
||||
"aya-ebpf-cty",
|
||||
"aya-ebpf-macros",
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf-bindings"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "783dc1a82a3d71d83286165381dcc1b1d41643f4b110733d135547527c000a9a"
|
||||
dependencies = [
|
||||
"aya-ebpf-cty",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf-cty"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cce099aaf3abb89f9a1f8594ffe07fa53738ebc2882fac624d10d9ba31a1b10"
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf-macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f47f7b4a75eb5f1d7ba0fb5628d247b1cf20388658899177875dabdda66865"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b600d806c1d07d3b81ab5f4a2a95fd80f479a0d3f1d68f29064d660865f85f02"
|
||||
dependencies = [
|
||||
"aya",
|
||||
"aya-log-common",
|
||||
"bytes",
|
||||
"log",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-common"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "befef9fe882e63164a2ba0161874e954648a72b0e1c4b361f532d590638c4eec"
|
||||
dependencies = [
|
||||
"num_enum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-ebpf"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae348f459df78a79e5cd5e164b6562b927033b97ca3b033605b341a474f44510"
|
||||
dependencies = [
|
||||
"aya-ebpf",
|
||||
"aya-log-common",
|
||||
"aya-log-ebpf-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-ebpf-macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6d8251a75f56077db51892041aa6b77c70ef2723845d7a210979700b2f01bc4"
|
||||
dependencies = [
|
||||
"aya-log-common",
|
||||
"aya-log-parser",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-parser"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14b102eb5c88c9aa0b49102d3fbcee08ecb0dfa81014f39b373311de7a7032cb"
|
||||
dependencies = [
|
||||
"aya-log-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-obj"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c51b96c5a8ed8705b40d655273bc4212cbbf38d4e3be2788f36306f154523ec7"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"core-error",
|
||||
"hashbrown",
|
||||
"log",
|
||||
"object",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
|
||||
|
||||
[[package]]
|
||||
name = "camino"
|
||||
version = "1.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-platform"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "core-error"
|
||||
version = "0.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efcdb2972eb64230b4c50646d8498ff73f5128d196a90c7236eec4cbe8619b8f"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab"
|
||||
dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d"
|
||||
dependencies = [
|
||||
"env_filter",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.167"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"hashbrown",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.215"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.215"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.133"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syscall_ebpf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"aya",
|
||||
"aya-log",
|
||||
"cargo_metadata",
|
||||
"env_logger",
|
||||
"libc",
|
||||
"log",
|
||||
"syscall_ebpf-common",
|
||||
"syscall_ebpf-ebpf",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syscall_ebpf-common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aya",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syscall_ebpf-ebpf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aya-ebpf",
|
||||
"aya-log-ebpf",
|
||||
"syscall_ebpf-common",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.42.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"libc",
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "6.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"rustix",
|
||||
"winsafe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
652
user/apps/test_ebpf/Cargo.lock
generated
Normal file
652
user/apps/test_ebpf/Cargo.lock
generated
Normal file
@ -0,0 +1,652 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "assert_matches"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
|
||||
|
||||
[[package]]
|
||||
name = "aya"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/tiny-aya.git?rev=0689f13#0689f13a7be0d822b3194227c6bee4cb5b0c9bfa"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"aya-obj",
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"object",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log"
|
||||
version = "0.2.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/tiny-aya.git?rev=0689f13#0689f13a7be0d822b3194227c6bee4cb5b0c9bfa"
|
||||
dependencies = [
|
||||
"aya",
|
||||
"aya-log-common",
|
||||
"bytes",
|
||||
"log",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-common"
|
||||
version = "0.1.14"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"num_enum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-obj"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"core-error",
|
||||
"hashbrown 0.14.5",
|
||||
"log",
|
||||
"object",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "core-error"
|
||||
version = "0.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efcdb2972eb64230b4c50646d8498ff73f5128d196a90c7236eec4cbe8619b8f"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"env_filter",
|
||||
"humantime",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"allocator-api2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.15.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.166"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"hashbrown 0.15.2",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "test_ebpf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aya",
|
||||
"aya-log",
|
||||
"env_logger",
|
||||
"log",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.41.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"libc",
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
575
user/apps/test_ebpf/syscall_ebpf/Cargo.lock
generated
Normal file
575
user/apps/test_ebpf/syscall_ebpf/Cargo.lock
generated
Normal file
@ -0,0 +1,575 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
|
||||
|
||||
[[package]]
|
||||
name = "assert_matches"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
|
||||
|
||||
[[package]]
|
||||
name = "aya"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/tiny-aya.git?rev=0689f13#0689f13a7be0d822b3194227c6bee4cb5b0c9bfa"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"aya-obj",
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"object",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-obj"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"core-error",
|
||||
"hashbrown 0.14.5",
|
||||
"log",
|
||||
"object",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
||||
|
||||
[[package]]
|
||||
name = "core-error"
|
||||
version = "0.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efcdb2972eb64230b4c50646d8498ff73f5128d196a90c7236eec4cbe8619b8f"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"allocator-api2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.161"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"hashbrown 0.15.0",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syscall_ebpf-common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aya",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.41.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"libc",
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "xtask"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
179
user/apps/test_ebpf/syscall_ebpf/syscall_ebpf-ebpf/Cargo.lock
generated
Normal file
179
user/apps/test_ebpf/syscall_ebpf/syscall_ebpf-ebpf/Cargo.lock
generated
Normal file
@ -0,0 +1,179 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"aya-ebpf-bindings",
|
||||
"aya-ebpf-cty",
|
||||
"aya-ebpf-macros",
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf-bindings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"aya-ebpf-cty",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf-cty"
|
||||
version = "0.2.1"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
|
||||
[[package]]
|
||||
name = "aya-ebpf-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-common"
|
||||
version = "0.1.14"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"num_enum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-ebpf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"aya-ebpf",
|
||||
"aya-log-common",
|
||||
"aya-log-ebpf-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-ebpf-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"aya-log-common",
|
||||
"aya-log-parser",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aya-log-parser"
|
||||
version = "0.1.13"
|
||||
source = "git+https://git.mirrors.dragonos.org.cn/DragonOS-Community/aya.git?rev=3d57d35#3d57d358e40591acf23dfde740697fbfff026410"
|
||||
dependencies = [
|
||||
"aya-log-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syscall_ebpf-common"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "syscall_ebpf-ebpf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aya-ebpf",
|
||||
"aya-log-ebpf",
|
||||
"syscall_ebpf-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
Loading…
x
Reference in New Issue
Block a user