mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
Compare commits
271 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9a39cf5b5 | ||
|
|
f6326df68b | ||
|
|
7571e93a69 | ||
|
|
ab6e1bd2d8 | ||
|
|
517ea00bd9 | ||
|
|
ea6d5a04fa | ||
|
|
799336459d | ||
|
|
f934e142ba | ||
|
|
0cde3df44a | ||
|
|
7585e16f9d | ||
|
|
ab575a54b9 | ||
|
|
d2ca7b0e87 | ||
|
|
dd9bce31e8 | ||
|
|
a6370b74d9 | ||
|
|
d172a5dddb | ||
|
|
d46517559b | ||
|
|
0463f4f156 | ||
|
|
fff62d9302 | ||
|
|
5db92f79bf | ||
|
|
06f3049d24 | ||
|
|
28e0a95450 | ||
|
|
a615c809eb | ||
|
|
a3dcaedf7e | ||
|
|
eb0b14f70e | ||
|
|
80e66657cc | ||
|
|
fd5cfb75f3 | ||
|
|
8696bc6604 | ||
|
|
93b599e59e | ||
|
|
01761c2596 | ||
|
|
a212343908 | ||
|
|
d1a406143d | ||
|
|
38380198e1 | ||
|
|
0e40a50407 | ||
|
|
262984f8fc | ||
|
|
dce82a34d0 | ||
|
|
1454d39b28 | ||
|
|
2588fc9e42 | ||
|
|
67793ca375 | ||
|
|
96deca9dc9 | ||
|
|
78b0f68b21 | ||
|
|
a007b750ff | ||
|
|
b2993fb2fa | ||
|
|
8d11bf7979 | ||
|
|
d4718a9bc8 | ||
|
|
05968f5c2c | ||
|
|
71a36e0c69 | ||
|
|
2da5e10689 | ||
|
|
a647d7863c | ||
|
|
a23d4b7cf2 | ||
|
|
f3209e4f78 | ||
|
|
596d6453c5 | ||
|
|
1307d31ede | ||
|
|
2f21827430 | ||
|
|
8da7c13e26 | ||
|
|
aaf86ef209 | ||
|
|
59f98a2edc | ||
|
|
cb52cf91df | ||
|
|
5814193722 | ||
|
|
10ee003d66 | ||
|
|
8f402687ce | ||
|
|
f72f16ee50 | ||
|
|
034aa514d7 | ||
|
|
4e48f429eb | ||
|
|
50b0493371 | ||
|
|
df418a2153 | ||
|
|
a072b9a356 | ||
|
|
691fe0ca68 | ||
|
|
aaa3a114dd | ||
|
|
77e042237d | ||
|
|
f16d45e86e | ||
|
|
3eb6b69dd2 | ||
|
|
fa2b5ca12b | ||
|
|
eac44e6af0 | ||
|
|
40055595ff | ||
|
|
149c08981b | ||
|
|
f1f6814774 | ||
|
|
58f71b0c44 | ||
|
|
1968805ba2 | ||
|
|
d0225fe68f | ||
|
|
87007a288f | ||
|
|
f67484a714 | ||
|
|
3c63779302 | ||
|
|
1c22c4a57b | ||
|
|
4af98f4cb2 | ||
|
|
c58c686f3e | ||
|
|
9b13d63f28 | ||
|
|
b5aeb1f63c | ||
|
|
af2ce3e0cc | ||
|
|
7fd1b9a284 | ||
|
|
e69acd1dc3 | ||
|
|
de764456ce | ||
|
|
0095556847 | ||
|
|
a0065452d8 | ||
|
|
56ca26e72c | ||
|
|
21b9806cad | ||
|
|
d374101f38 | ||
|
|
461e31e6d8 | ||
|
|
d22e7e2638 | ||
|
|
960d702255 | ||
|
|
1105243aca | ||
|
|
317f8002d7 | ||
|
|
278b57ba49 | ||
|
|
d7f87425cd | ||
|
|
573868c035 | ||
|
|
2798286278 | ||
|
|
bcc314eb8b | ||
|
|
af28569611 | ||
|
|
1a5dcc5e70 | ||
|
|
29b089296d | ||
|
|
6e4bf84383 | ||
|
|
226ecf47bb | ||
|
|
0e3733e938 | ||
|
|
f811e36443 | ||
|
|
a64ba04e78 | ||
|
|
b686a5bb24 | ||
|
|
ea4693a091 | ||
|
|
3698b8e74c | ||
|
|
6bb33601d0 | ||
|
|
3d88996e5b | ||
|
|
3899cd0e30 | ||
|
|
9d93df4c8f | ||
|
|
4c27572b87 | ||
|
|
19fea1ad88 | ||
|
|
9a96ea44be | ||
|
|
e11b9d6449 | ||
|
|
ce5fe7f89d | ||
|
|
0dd0364bf8 | ||
|
|
3081d01fc3 | ||
|
|
fa58b725cb | ||
|
|
a38b4c7f17 | ||
|
|
5aa1540c5d | ||
|
|
7da8ae9c0f | ||
|
|
108e8f9dff | ||
|
|
5ab2feae70 | ||
|
|
c99660a8f9 | ||
|
|
08c1bb4b00 | ||
|
|
5bd177dde8 | ||
|
|
52ed1082fb | ||
|
|
03a23309b9 | ||
|
|
fa0965a11a | ||
|
|
524f26abef | ||
|
|
846d0976e3 | ||
|
|
4718dc1b72 | ||
|
|
0a9895e009 | ||
|
|
297b41d615 | ||
|
|
396aba7a52 | ||
|
|
35aaa1333a | ||
|
|
6768a13d95 | ||
|
|
0d50d0b257 | ||
|
|
f5a2f8473b | ||
|
|
03bb59db69 | ||
|
|
9e1fb3bfa1 | ||
|
|
4de422ad69 | ||
|
|
c441bb2968 | ||
|
|
5cb5115456 | ||
|
|
0fbba66b21 | ||
|
|
5388fa1ced | ||
|
|
655d512523 | ||
|
|
7d45473ff7 | ||
|
|
294d5fbb08 | ||
|
|
8c796e6d5d | ||
|
|
630f5c1f14 | ||
|
|
5cbf907200 | ||
|
|
bfeab76059 | ||
|
|
12143ca72f | ||
|
|
ba05bdd085 | ||
|
|
171b28ce52 | ||
|
|
5b929cb277 | ||
|
|
ee0b0d43d8 | ||
|
|
061482340e | ||
|
|
c43ae1dc9d | ||
|
|
7db3002e1d | ||
|
|
07b7457c2e | ||
|
|
dc9142f86c | ||
|
|
6fa7c84d2e | ||
|
|
cc734e2e44 | ||
|
|
e3e83362d6 | ||
|
|
730cf1e944 | ||
|
|
1caa69d0cc | ||
|
|
abcbf43433 | ||
|
|
af74de2779 | ||
|
|
dfebc8929d | ||
|
|
9988379f6b | ||
|
|
4d12192490 | ||
|
|
9f9cfeb5be | ||
|
|
3fa1e77adc | ||
|
|
b8424ea506 | ||
|
|
0c2fe29f61 | ||
|
|
b445d219ca | ||
|
|
6de283f42c | ||
|
|
f892789481 | ||
|
|
f96554cbe9 | ||
|
|
3509b5bf4a | ||
|
|
cf463b88b7 | ||
|
|
ca8eda5399 | ||
|
|
45b770ea9f | ||
|
|
d2c4ceb99a | ||
|
|
caf7cae2fa | ||
|
|
81eca69b40 | ||
|
|
8c07294691 | ||
|
|
2f9436bc12 | ||
|
|
62fade97d1 | ||
|
|
5a8df3622c | ||
|
|
27fda753e1 | ||
|
|
74ca38f7a9 | ||
|
|
fa686fdfc7 | ||
|
|
c827a1c009 | ||
|
|
eefd7fcaaf | ||
|
|
62303d8c33 | ||
|
|
293cf90e3d | ||
|
|
8f98fabd0b | ||
|
|
07821c08c0 | ||
|
|
0cb2c86ff4 | ||
|
|
d359c8cdce | ||
|
|
c801929fd1 | ||
|
|
66da3b9970 | ||
|
|
6ddbd60d9d | ||
|
|
2fc4de6c65 | ||
|
|
03eeb36b74 | ||
|
|
2fe7f54ece | ||
|
|
1cc540c880 | ||
|
|
a1af4238ae | ||
|
|
d2e798944a | ||
|
|
d99f294281 | ||
|
|
44c9ce598d | ||
|
|
5b42aa0bcf | ||
|
|
703e0cab04 | ||
|
|
abb88cf47f | ||
|
|
2e22b8bc3a | ||
|
|
778c05d678 | ||
|
|
5b29eba636 | ||
|
|
e6e78e5986 | ||
|
|
a2df4d7660 | ||
|
|
bc4a1fd16c | ||
|
|
463c9b8e56 | ||
|
|
835847bea5 | ||
|
|
3e4ed5621e | ||
|
|
2624f17ffe | ||
|
|
21f05ebb4f | ||
|
|
1485e17268 | ||
|
|
b57cc3d79f | ||
|
|
a322e2d6f4 | ||
|
|
dd0b95ba5c | ||
|
|
b6667f948e | ||
|
|
4f22f67307 | ||
|
|
eeae63b459 | ||
|
|
abf5748f64 | ||
|
|
23b5f7b1c5 | ||
|
|
a66fef407c | ||
|
|
7c39f37855 | ||
|
|
fe24a7a24f | ||
|
|
73e1451a12 | ||
|
|
1180f757b3 | ||
|
|
2932658acd | ||
|
|
1f7b809619 | ||
|
|
32482f6634 | ||
|
|
6fd5b0f696 | ||
|
|
ef88b2778e | ||
|
|
8b55d1e2d4 | ||
|
|
2df285effd | ||
|
|
4ea4391f45 | ||
|
|
8f8d3c0139 | ||
|
|
408467a05f | ||
|
|
f27b028c18 | ||
|
|
eaa2194699 | ||
|
|
9973d28849 | ||
|
|
1cdb91a40f | ||
|
|
57e331db0e | ||
|
|
090fcebfec | ||
|
|
b2f40afc69 | ||
|
|
72452707ee |
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
- "1.77.0"
|
- "1.83.0"
|
||||||
target:
|
target:
|
||||||
- x86_64-unknown-linux-gnu
|
- x86_64-unknown-linux-gnu
|
||||||
- x86_64-unknown-linux-musl
|
- x86_64-unknown-linux-musl
|
||||||
|
|||||||
14
.github/workflows/docker-image.yaml
vendored
14
.github/workflows/docker-image.yaml
vendored
@@ -21,13 +21,13 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to ghcr
|
- name: Login to ghcr
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -36,17 +36,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
# generate Docker tags based on the following events/attributes
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=20241022-0
|
type=raw,value=20250412-0
|
||||||
type=sha
|
type=sha
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
file: ./resources/Dockerfile
|
file: ./resources/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build only
|
- name: Build only
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
file: ./resources/Dockerfile
|
file: ./resources/Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|||||||
11
.github/workflows/integration-metrics.yaml
vendored
11
.github/workflows/integration-metrics.yaml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Tests (Metrics)
|
name: Tests (Metrics)
|
||||||
runs-on: garm-jammy-16
|
runs-on: bare-metal-9950x
|
||||||
env:
|
env:
|
||||||
METRICS_PUBLISH_KEY: ${{ secrets.METRICS_PUBLISH_KEY }}
|
METRICS_PUBLISH_KEY: ${{ secrets.METRICS_PUBLISH_KEY }}
|
||||||
steps:
|
steps:
|
||||||
@@ -15,15 +15,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Docker
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install ca-certificates curl gnupg
|
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
||||||
sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg
|
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt install -y docker-ce docker-ce-cli
|
|
||||||
- name: Run metrics tests
|
- name: Run metrics tests
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
run: scripts/dev_cli.sh tests --metrics -- -- --report-file /root/workloads/metrics.json
|
run: scripts/dev_cli.sh tests --metrics -- -- --report-file /root/workloads/metrics.json
|
||||||
|
|||||||
12
.github/workflows/integration-rate-limiter.yaml
vendored
12
.github/workflows/integration-rate-limiter.yaml
vendored
@@ -7,7 +7,7 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Tests (Rate-Limiter)
|
name: Tests (Rate-Limiter)
|
||||||
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'garm-jammy-16' }}
|
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'bare-metal-9950x' }}
|
||||||
env:
|
env:
|
||||||
AUTH_DOWNLOAD_TOKEN: ${{ secrets.AUTH_DOWNLOAD_TOKEN }}
|
AUTH_DOWNLOAD_TOKEN: ${{ secrets.AUTH_DOWNLOAD_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
@@ -16,16 +16,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Docker
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install ca-certificates curl gnupg
|
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
||||||
sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg
|
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt install -y docker-ce docker-ce-cli
|
|
||||||
- name: Run rate-limiter integration tests
|
- name: Run rate-limiter integration tests
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|||||||
16
.github/workflows/lychee.yaml
vendored
Normal file
16
.github/workflows/lychee.yaml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: Link Check (lychee)
|
||||||
|
on:
|
||||||
|
pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
link_check:
|
||||||
|
name: Link Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Code checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Link Availability Check
|
||||||
|
uses: lycheeverse/lychee-action@master
|
||||||
|
with:
|
||||||
|
args: --verbose --config .lychee.toml .
|
||||||
2
.github/workflows/preview-riscv64.yaml
vendored
2
.github/workflows/preview-riscv64.yaml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
run: /opt/scripts/exec-in-qemu.sh rustup default 1.77.0
|
run: /opt/scripts/exec-in-qemu.sh rustup default 1.83.0
|
||||||
|
|
||||||
- name: Build ${{ matrix.module }} Module (kvm)
|
- name: Build ${{ matrix.module }} Module (kvm)
|
||||||
run: /opt/scripts/exec-in-qemu.sh cargo rustc --locked -p ${{ matrix.module }} --no-default-features --features "kvm" -- -D warnings -D clippy::undocumented_unsafe_blocks -W clippy::assertions_on_result_states
|
run: /opt/scripts/exec-in-qemu.sh cargo rustc --locked -p ${{ matrix.module }} --no-default-features --features "kvm" -- -D warnings -D clippy::undocumented_unsafe_blocks -W clippy::assertions_on_result_states
|
||||||
|
|||||||
14
.github/workflows/quality.yaml
vendored
14
.github/workflows/quality.yaml
vendored
@@ -56,6 +56,20 @@ jobs:
|
|||||||
command: clippy
|
command: clippy
|
||||||
args: --target=${{ matrix.target }} --locked --all --all-targets --no-default-features --tests --examples --features "kvm" -- -D warnings -D clippy::undocumented_unsafe_blocks -W clippy::assertions_on_result_states
|
args: --target=${{ matrix.target }} --locked --all --all-targets --no-default-features --tests --examples --features "kvm" -- -D warnings -D clippy::undocumented_unsafe_blocks -W clippy::assertions_on_result_states
|
||||||
|
|
||||||
|
- name: Clippy (mshv)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
|
||||||
|
command: clippy
|
||||||
|
args: --target=${{ matrix.target }} --locked --all --all-targets --no-default-features --tests --examples --features "mshv" -- -D warnings -D clippy::undocumented_unsafe_blocks -W clippy::assertions_on_result_states
|
||||||
|
|
||||||
|
- name: Clippy (mshv + kvm)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
|
||||||
|
command: clippy
|
||||||
|
args: --target=${{ matrix.target }} --locked --all --all-targets --no-default-features --tests --examples --features "mshv,kvm" -- -D warnings -D clippy::undocumented_unsafe_blocks -W clippy::assertions_on_result_states
|
||||||
|
|
||||||
- name: Clippy (default features)
|
- name: Clippy (default features)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
6
.github/workflows/release.yaml
vendored
6
.github/workflows/release.yaml
vendored
@@ -45,7 +45,7 @@ jobs:
|
|||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
args: ${{ matrix.platform.args }}
|
args: ${{ matrix.platform.args }}
|
||||||
strip: true
|
strip: true
|
||||||
toolchain: "1.77.0"
|
toolchain: "1.83.0"
|
||||||
- name: Copy Release Binaries
|
- name: Copy Release Binaries
|
||||||
if: github.event_name == 'create' && github.event.ref_type == 'tag'
|
if: github.event_name == 'create' && github.event.ref_type == 'tag'
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
cp target/${{ matrix.platform.target }}/release/ch-remote ./${{ matrix.platform.name_ch_remote }}
|
cp target/${{ matrix.platform.target }}/release/ch-remote ./${{ matrix.platform.name_ch_remote }}
|
||||||
- name: Upload Release Artifacts
|
- name: Upload Release Artifacts
|
||||||
if: github.event_name == 'create' && github.event.ref_type == 'tag'
|
if: github.event_name == 'create' && github.event.ref_type == 'tag'
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Artifacts for ${{ matrix.platform.target }}
|
name: Artifacts for ${{ matrix.platform.target }}
|
||||||
path: |
|
path: |
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
github.event_name == 'create' && github.event.ref_type == 'tag' &&
|
github.event_name == 'create' && github.event.ref_type == 'tag' &&
|
||||||
matrix.platform.target == 'x86_64-unknown-linux-gnu'
|
matrix.platform.target == 'x86_64-unknown-linux-gnu'
|
||||||
id: upload-release-cloud-hypervisor-vendored-sources
|
id: upload-release-cloud-hypervisor-vendored-sources
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: cloud-hypervisor-${{ github.event.ref }}.tar.xz
|
path: cloud-hypervisor-${{ github.event.ref }}.tar.xz
|
||||||
name: cloud-hypervisor-${{ github.event.ref }}.tar.xz
|
name: cloud-hypervisor-${{ github.event.ref }}.tar.xz
|
||||||
|
|||||||
6
.gitlint
6
.gitlint
@@ -1,6 +1,7 @@
|
|||||||
[general]
|
[general]
|
||||||
extra-path=scripts/gitlint/rules.py
|
extra-path=scripts/gitlint/rules
|
||||||
regex-style-search=true
|
regex-style-search=true
|
||||||
|
ignore=body-max-line-length
|
||||||
|
|
||||||
[ignore-by-author-name]
|
[ignore-by-author-name]
|
||||||
regex=dependabot
|
regex=dependabot
|
||||||
@@ -10,6 +11,3 @@ ignore=all
|
|||||||
[title-max-length]
|
[title-max-length]
|
||||||
line-length=72
|
line-length=72
|
||||||
|
|
||||||
# default 80
|
|
||||||
[body-max-line-length]
|
|
||||||
line-length=72
|
|
||||||
|
|||||||
21
.lychee.toml
Normal file
21
.lychee.toml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
verbose = "info"
|
||||||
|
|
||||||
|
exclude = [
|
||||||
|
# Availability of links below should be manually verified.
|
||||||
|
# Page for intel SGX support, returns 403 while querying.
|
||||||
|
'^https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html',
|
||||||
|
# Page for intel TDX support, returns 403 while querying.
|
||||||
|
'^https://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/overview.html',
|
||||||
|
# Page for TPM, returns 403 while querying.
|
||||||
|
'^https://trustedcomputinggroup.org/wp-content/uploads/PC-Client-Specific-Platform-TPM-Profile-for-TPM-2p0-v1p05p_r14_pub.pdf',
|
||||||
|
|
||||||
|
# GitHub user smibarber referenced in `CREDITS.md` no longer exist
|
||||||
|
'^https://github.com/smibarber',
|
||||||
|
|
||||||
|
# OSDev has added bot protection and accesses my result in 403 Forbidden.
|
||||||
|
'^https://wiki.osdev.org',
|
||||||
|
]
|
||||||
|
|
||||||
|
max_retries = 3
|
||||||
|
|
||||||
|
retry_wait_time = 5
|
||||||
@@ -15,6 +15,7 @@ EXTINT = "EXTINT"
|
|||||||
INOUT = "INOUT"
|
INOUT = "INOUT"
|
||||||
liness = "liness"
|
liness = "liness"
|
||||||
outout = "outout"
|
outout = "outout"
|
||||||
|
TRANSLATER = "TRANSLATER"
|
||||||
|
|
||||||
[default.extend-identifiers]
|
[default.extend-identifiers]
|
||||||
fo = "fo"
|
fo = "fo"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ License](https://opensource.org/licenses/Apache-2.0).
|
|||||||
|
|
||||||
## Coding Style
|
## Coding Style
|
||||||
|
|
||||||
We follow the [Rust Style](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md)
|
We follow the [Rust Style](https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src)
|
||||||
convention and enforce it through the Continuous Integration (CI) process calling into `rustfmt`
|
convention and enforce it through the Continuous Integration (CI) process calling into `rustfmt`
|
||||||
for each submitted Pull Request (PR).
|
for each submitted Pull Request (PR).
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ commit you make.
|
|||||||
|
|
||||||
## Certificate of Origin
|
## Certificate of Origin
|
||||||
|
|
||||||
In order to get a clear contribution chain of trust we use the [signed-off-by language](https://01.org/community/signed-process)
|
In order to get a clear contribution chain of trust we use the [signed-off-by language](https://web.archive.org/web/20230406041855/https://01.org/community/signed-process)
|
||||||
used by the Linux kernel project.
|
used by the Linux kernel project.
|
||||||
|
|
||||||
## Patch format
|
## Patch format
|
||||||
@@ -79,12 +79,12 @@ you want to merge your changes to `cloud-hypervisor`:
|
|||||||
|
|
||||||
1. Fork the [cloud-hypervisor](https://github.com/cloud-hypervisor/cloud-hypervisor) project
|
1. Fork the [cloud-hypervisor](https://github.com/cloud-hypervisor/cloud-hypervisor) project
|
||||||
into your github organization.
|
into your github organization.
|
||||||
2. Within your fork, create a branch for your contribution.
|
1. Within your fork, create a branch for your contribution.
|
||||||
3. [Create a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)
|
1. [Create a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)
|
||||||
against the main branch of the Cloud Hypervisor repository.
|
against the main branch of the Cloud Hypervisor repository.
|
||||||
4. To update your pull request amend existing commits whenever applicable and
|
1. To update your pull request amend existing commits whenever applicable and
|
||||||
then push the new changes to your pull request branch.
|
then push the new changes to your pull request branch.
|
||||||
5. Once the pull request is approved it can be integrated.
|
1. Once the pull request is approved it can be integrated.
|
||||||
|
|
||||||
## Issue tracking
|
## Issue tracking
|
||||||
|
|
||||||
|
|||||||
337
Cargo.lock
generated
337
Cargo.lock
generated
@@ -1,13 +1,13 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "acpi_tables"
|
name = "acpi_tables"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/rust-vmm/acpi_tables?branch=main#e268627630839bd22f1c13e7e81ec70c7e9b73d6"
|
source = "git+https://github.com/rust-vmm/acpi_tables?branch=main#e08a3f0b0a59b98859dbf59f5aa7fd4d2eb4018a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy 0.7.35",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -66,21 +66,21 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-query"
|
name = "anstyle-query"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-wincon"
|
name = "anstyle-wincon"
|
||||||
version = "3.0.4"
|
version = "3.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -93,7 +93,7 @@ checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
|
|||||||
name = "api_client"
|
name = "api_client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ dependencies = [
|
|||||||
"linux-loader",
|
"linux-loader",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vm-fdt",
|
"vm-fdt",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -137,12 +137,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-channel"
|
name = "async-channel"
|
||||||
version = "2.3.0"
|
version = "2.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f2776ead772134d55b62dd45e59a79e21612d85d0af729b8b7d3967d601a62a"
|
checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"event-listener",
|
|
||||||
"event-listener-strategy",
|
"event-listener-strategy",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
@@ -150,9 +149,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-executor"
|
name = "async-executor"
|
||||||
version = "1.11.0"
|
version = "1.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a"
|
checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-task",
|
"async-task",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
@@ -258,9 +257,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.83"
|
version = "0.1.86"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
|
checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -275,9 +274,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
@@ -296,9 +295,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitfield-struct"
|
name = "bitfield-struct"
|
||||||
version = "0.7.0"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c2ce686adbebce0ee484a502c440b4657739adbad65eadf06d64f5816ee9765"
|
checksum = "2be5a46ba01b60005ae2c51a36a29cfe134bcacae2dd5cedcd4615fbaad1494b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -313,9 +312,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.6.0"
|
version = "2.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block"
|
name = "block"
|
||||||
@@ -329,7 +328,7 @@ dependencies = [
|
|||||||
"remain",
|
"remain",
|
||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"uuid",
|
"uuid",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
"virtio-queue",
|
"virtio-queue",
|
||||||
@@ -374,9 +373,12 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.99"
|
version = "1.2.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695"
|
checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766"
|
||||||
|
dependencies = [
|
||||||
|
"shlex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
@@ -414,13 +416,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.7.2"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cloud-hypervisor"
|
name = "cloud-hypervisor"
|
||||||
version = "43.0.0"
|
version = "46.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"api_client",
|
"api_client",
|
||||||
@@ -439,7 +441,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"signal-hook",
|
"signal-hook",
|
||||||
"test_infra",
|
"test_infra",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"tpm",
|
"tpm",
|
||||||
"tracer",
|
"tracer",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -451,9 +453,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colorchoice"
|
name = "colorchoice"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concat-idents"
|
name = "concat-idents"
|
||||||
@@ -565,7 +567,7 @@ dependencies = [
|
|||||||
"acpi_tables",
|
"acpi_tables",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arch",
|
"arch",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"event_monitor",
|
"event_monitor",
|
||||||
"hypervisor",
|
"hypervisor",
|
||||||
@@ -574,7 +576,7 @@ dependencies = [
|
|||||||
"num_enum",
|
"num_enum",
|
||||||
"pci",
|
"pci",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"tpm",
|
"tpm",
|
||||||
"vm-allocator",
|
"vm-allocator",
|
||||||
"vm-device",
|
"vm-device",
|
||||||
@@ -611,23 +613,23 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "5.0.1"
|
version = "6.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys"
|
name = "dirs-sys"
|
||||||
version = "0.4.1"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"option-ext",
|
"option-ext",
|
||||||
"redox_users",
|
"redox_users",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -686,15 +688,15 @@ version = "4.3.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74351c3392ea1ff6cd2628e0042d268ac2371cb613252ff383b6dfa50d22fa79"
|
checksum = "74351c3392ea1ff6cd2628e0042d268ac2371cb613252ff383b6dfa50d22fa79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
@@ -740,9 +742,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.2.0"
|
version = "2.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fdt"
|
name = "fdt"
|
||||||
@@ -770,9 +772,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures"
|
name = "futures"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
|
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
@@ -785,9 +787,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-channel"
|
name = "futures-channel"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
@@ -801,9 +803,9 @@ checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-executor"
|
name = "futures-executor"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
|
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
@@ -812,9 +814,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-io"
|
name = "futures-io"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-lite"
|
name = "futures-lite"
|
||||||
@@ -831,9 +833,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-macro"
|
name = "futures-macro"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -848,15 +850,15 @@ checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-task"
|
name = "futures-task"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
|
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-util"
|
name = "futures-util"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
@@ -876,7 +878,7 @@ version = "0.7.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6341b3480afbb34eaefc7f92713bc92f2d83e338aaa1c44192f9c2956f4a4903"
|
checksum = "6341b3480afbb34eaefc7f92713bc92f2d83e338aaa1c44192f9c2956f4a4903"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"log",
|
"log",
|
||||||
"managed",
|
"managed",
|
||||||
@@ -913,10 +915,22 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi 0.13.3+wasi-0.2.2",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gimli"
|
name = "gimli"
|
||||||
version = "0.31.1"
|
version = "0.31.1"
|
||||||
@@ -931,9 +945,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.14.5"
|
version = "0.15.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
@@ -959,6 +973,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
|
"bitfield-struct",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"concat-idents",
|
"concat-idents",
|
||||||
@@ -972,12 +987,15 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"mshv-bindings",
|
"mshv-bindings",
|
||||||
"mshv-ioctls",
|
"mshv-ioctls",
|
||||||
|
"open-enum",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -997,9 +1015,8 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "igvm"
|
name = "igvm"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/microsoft/igvm?branch=main#01daa631a596459cb4de58505881007dd13d4410"
|
||||||
checksum = "7984b10433b50e06a06bd50c69bca4888a5d7de8975f64ea4c2a7687eb99b09d"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitfield-struct",
|
"bitfield-struct",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
@@ -1007,28 +1024,28 @@ dependencies = [
|
|||||||
"igvm_defs",
|
"igvm_defs",
|
||||||
"open-enum",
|
"open-enum",
|
||||||
"range_map_vec",
|
"range_map_vec",
|
||||||
"thiserror 1.0.62",
|
"static_assertions",
|
||||||
|
"thiserror 2.0.6",
|
||||||
"tracing",
|
"tracing",
|
||||||
"zerocopy 0.7.35",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "igvm_defs"
|
name = "igvm_defs"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/microsoft/igvm?branch=main#01daa631a596459cb4de58505881007dd13d4410"
|
||||||
checksum = "b64ec5588c475372ae830475d3ee9a7bd255407dcb9f03faf6d493556eb6105a"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitfield-struct",
|
"bitfield-struct",
|
||||||
"open-enum",
|
"open-enum",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"zerocopy 0.7.35",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.2.6"
|
version = "2.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -1096,11 +1113,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kvm-ioctls"
|
name = "kvm-ioctls"
|
||||||
version = "0.19.0"
|
version = "0.19.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "337d1afa126368bbd6a5c328048f71a69a737e9afe7e436b392a8f8d770c9171"
|
checksum = "e013ae7fcd2c6a8f384104d16afe7ea02969301ea2bb2a56e44b011ebc907cab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"kvm-bindings",
|
"kvm-bindings",
|
||||||
"libc",
|
"libc",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -1135,7 +1152,7 @@ version = "0.1.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1176,9 +1193,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.14"
|
version = "0.4.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
@@ -1220,7 +1237,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "micro_http"
|
name = "micro_http"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/firecracker-microvm/micro-http?branch=main#ef43cef7162a55a6790d528a5e76b4fe2da22de0"
|
source = "git+https://github.com/firecracker-microvm/micro-http?branch=main#4f621532e81ee2ad096a9c9592fdacc40d19de48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -1228,9 +1245,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.8.0"
|
version = "0.8.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler2",
|
"adler2",
|
||||||
]
|
]
|
||||||
@@ -1243,23 +1260,23 @@ checksum = "9bec4598fddb13cc7b528819e697852653252b760f1228b7642679bf2ff2cd07"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mshv-bindings"
|
name = "mshv-bindings"
|
||||||
version = "0.3.2"
|
version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e0cb5031f3243a7459b7c13d960d25420980874eebda816db24ce6077e21d43"
|
checksum = "909de5fd4a5a3347a6c62872f6816e6279efd8615a753f10a3bc4daaef8a72ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
"zerocopy 0.8.8",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mshv-ioctls"
|
name = "mshv-ioctls"
|
||||||
version = "0.3.2"
|
version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89abe853221fa6f14ad4066affb9abda241a03d65622887d5794e1422d0bd75a"
|
checksum = "8c7d94972588d562bd349b916de6a43f2ee268e6e9c91cfb5b30549ed4ea2751"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"mshv-bindings",
|
"mshv-bindings",
|
||||||
@@ -1273,7 +1290,7 @@ version = "0.7.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
|
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.2.15",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1288,7 +1305,7 @@ name = "net_util"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"epoll",
|
"epoll",
|
||||||
"getrandom",
|
"getrandom 0.3.1",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"net_gen",
|
"net_gen",
|
||||||
@@ -1298,7 +1315,7 @@ dependencies = [
|
|||||||
"rate_limiter",
|
"rate_limiter",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
"virtio-queue",
|
"virtio-queue",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -1312,7 +1329,7 @@ version = "0.29.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cfg_aliases",
|
"cfg_aliases",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -1421,6 +1438,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "option_parser"
|
name = "option_parser"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror 2.0.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ordered-stream"
|
name = "ordered-stream"
|
||||||
@@ -1502,7 +1522,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vfio-bindings",
|
"vfio-bindings",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"vfio_user",
|
"vfio_user",
|
||||||
@@ -1522,7 +1542,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"test_infra",
|
"test_infra",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"wait-timeout",
|
"wait-timeout",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1672,18 +1692,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "3.1.0"
|
version = "3.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284"
|
checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"toml_edit",
|
"toml_edit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.86"
|
version = "1.0.93"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -1724,7 +1744,7 @@ version = "0.6.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.2.15",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1740,7 +1760,7 @@ dependencies = [
|
|||||||
"epoll",
|
"epoll",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1764,13 +1784,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
version = "0.4.6"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.2.15",
|
||||||
"libredox",
|
"libredox",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1831,7 +1851,7 @@ version = "0.38.34"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
@@ -1840,9 +1860,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.18"
|
version = "1.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
@@ -1852,9 +1872,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "seccompiler"
|
name = "seccompiler"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "345a3e4dddf721a478089d4697b83c6c0a8f5bf16086f6c13397e4534eb6e2e5"
|
checksum = "a4ae55de56877481d112a559bbc12667635fdaf5e005712fd4e2b2fa50ffc884"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
@@ -1940,10 +1960,16 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signal-hook"
|
name = "shlex"
|
||||||
version = "0.3.17"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "signal-hook"
|
||||||
|
version = "0.3.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
@@ -2019,15 +2045,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.11.0"
|
version = "3.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53"
|
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2051,6 +2077,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"ssh2",
|
"ssh2",
|
||||||
|
"thiserror 2.0.6",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
"wait-timeout",
|
"wait-timeout",
|
||||||
]
|
]
|
||||||
@@ -2103,15 +2130,15 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "0.6.5"
|
version = "0.6.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
|
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.21.1"
|
version = "0.22.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
|
checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
@@ -2127,7 +2154,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"net_gen",
|
"net_gen",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2192,9 +2219,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.12"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
@@ -2204,20 +2231,20 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.8.0"
|
version = "1.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0"
|
checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.2.15",
|
||||||
"rand",
|
"rand",
|
||||||
"uuid-macro-internal",
|
"uuid-macro-internal",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid-macro-internal"
|
name = "uuid-macro-internal"
|
||||||
version = "1.10.0"
|
version = "1.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee1cd046f83ea2c4e920d6ee9f7c3537ef928d75dce5d84a87c2c5d6b3999a3a"
|
checksum = "f8a86d88347b61a0e17b9908a67efcc594130830bf1045653784358dd023e294"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2239,15 +2266,15 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "vfio-bindings"
|
name = "vfio-bindings"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/rust-vmm/vfio?branch=main#e71efe41d59adf23377f7066a49903c6c19f5ac3"
|
source = "git+https://github.com/rust-vmm/vfio?branch=main#3d158a14460cac7ca3c99c2effa0a46880935cb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vfio-ioctls"
|
name = "vfio-ioctls"
|
||||||
version = "0.2.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/rust-vmm/vfio?branch=main#e71efe41d59adf23377f7066a49903c6c19f5ac3"
|
source = "git+https://github.com/rust-vmm/vfio?branch=main#3d158a14460cac7ca3c99c2effa0a46880935cb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"kvm-bindings",
|
"kvm-bindings",
|
||||||
@@ -2284,7 +2311,7 @@ name = "vhost"
|
|||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "git+https://github.com/rust-vmm/vhost?rev=d983ae0#d983ae07f78663b7d24059667376992460b571a2"
|
source = "git+https://github.com/rust-vmm/vhost?rev=d983ae0#d983ae07f78663b7d24059667376992460b571a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -2316,6 +2343,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"option_parser",
|
"option_parser",
|
||||||
|
"thiserror 2.0.6",
|
||||||
"vhost",
|
"vhost",
|
||||||
"vhost-user-backend",
|
"vhost-user-backend",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
@@ -2335,6 +2363,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"net_util",
|
"net_util",
|
||||||
"option_parser",
|
"option_parser",
|
||||||
|
"thiserror 2.0.6",
|
||||||
"vhost",
|
"vhost",
|
||||||
"vhost-user-backend",
|
"vhost-user-backend",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
@@ -2370,7 +2399,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"serial_buffer",
|
"serial_buffer",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vhost",
|
"vhost",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
"virtio-queue",
|
"virtio-queue",
|
||||||
@@ -2410,7 +2439,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"hypervisor",
|
"hypervisor",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -2440,7 +2469,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2461,7 +2490,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
"arch",
|
"arch",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"block",
|
"block",
|
||||||
"blocking",
|
"blocking",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -2495,7 +2524,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serial_buffer",
|
"serial_buffer",
|
||||||
"signal-hook",
|
"signal-hook",
|
||||||
"thiserror 1.0.62",
|
"thiserror 2.0.6",
|
||||||
"tracer",
|
"tracer",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
@@ -2509,7 +2538,7 @@ dependencies = [
|
|||||||
"vm-virtio",
|
"vm-virtio",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
"zbus",
|
"zbus",
|
||||||
"zerocopy 0.7.35",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2539,6 +2568,15 @@ version = "0.11.0+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.13.3+wasi-0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen-rt",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.92"
|
version = "0.2.92"
|
||||||
@@ -2765,13 +2803,22 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.5.40"
|
version = "0.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
|
checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen-rt"
|
||||||
|
version = "0.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.9.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xdg-home"
|
name = "xdg-home"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
@@ -2856,11 +2903,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.8"
|
version = "0.8.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a4e33e6dce36f2adba29746927f8e848ba70989fdb61c772773bbdda8b5d6a7"
|
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive 0.8.8",
|
"zerocopy-derive 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2876,9 +2923,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.8.8"
|
version = "0.8.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3cd137b4cc21bde6ecce3bbbb3350130872cda0be2c6888874279ea76e17d4c1"
|
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|||||||
33
Cargo.toml
33
Cargo.toml
@@ -7,15 +7,15 @@ edition = "2021"
|
|||||||
homepage = "https://github.com/cloud-hypervisor/cloud-hypervisor"
|
homepage = "https://github.com/cloud-hypervisor/cloud-hypervisor"
|
||||||
license = "Apache-2.0 AND BSD-3-Clause"
|
license = "Apache-2.0 AND BSD-3-Clause"
|
||||||
name = "cloud-hypervisor"
|
name = "cloud-hypervisor"
|
||||||
version = "43.0.0"
|
version = "46.0.0"
|
||||||
# Minimum buildable version:
|
# Minimum buildable version:
|
||||||
# Keep in sync with version in .github/workflows/build.yaml
|
# Keep in sync with version in .github/workflows/build.yaml
|
||||||
# Policy on MSRV (see #4318):
|
# Policy on MSRV (see #4318):
|
||||||
# Can only be bumped by:
|
# Can only be bumped if satisfying any of the following:
|
||||||
# a.) A dependency requires it,
|
# a.) A dependency requires it,
|
||||||
# b.) If we want to use a new feature and that MSRV is at least 6 months old,
|
# b.) If we want to use a new feature and that MSRV is at least 6 months old,
|
||||||
# c.) There is a security issue that is addressed by the toolchain update.
|
# c.) There is a security issue that is addressed by the toolchain update.
|
||||||
rust-version = "1.77.0"
|
rust-version = "1.83.0"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
@@ -40,9 +40,9 @@ libc = "0.2.167"
|
|||||||
log = { version = "0.4.22", features = ["std"] }
|
log = { version = "0.4.22", features = ["std"] }
|
||||||
option_parser = { path = "option_parser" }
|
option_parser = { path = "option_parser" }
|
||||||
seccompiler = { workspace = true }
|
seccompiler = { workspace = true }
|
||||||
serde_json = "1.0.120"
|
serde_json = { workspace = true }
|
||||||
signal-hook = "0.3.17"
|
signal-hook = "0.3.18"
|
||||||
thiserror = "1.0.62"
|
thiserror = "2.0.6"
|
||||||
tpm = { path = "tpm" }
|
tpm = { path = "tpm" }
|
||||||
tracer = { path = "tracer" }
|
tracer = { path = "tracer" }
|
||||||
vm-memory = { workspace = true }
|
vm-memory = { workspace = true }
|
||||||
@@ -51,10 +51,10 @@ vmm-sys-util = { workspace = true }
|
|||||||
zbus = { version = "4.4.0", optional = true }
|
zbus = { version = "4.4.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
dirs = "5.0.1"
|
dirs = "6.0.0"
|
||||||
net_util = { path = "net_util" }
|
net_util = { path = "net_util" }
|
||||||
once_cell = "1.20.2"
|
once_cell = "1.20.2"
|
||||||
serde_json = "1.0.120"
|
serde_json = { workspace = true }
|
||||||
test_infra = { path = "test_infra" }
|
test_infra = { path = "test_infra" }
|
||||||
wait-timeout = "0.2.0"
|
wait-timeout = "0.2.0"
|
||||||
|
|
||||||
@@ -102,13 +102,14 @@ members = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
# rust-vmm crates
|
||||||
acpi_tables = { git = "https://github.com/rust-vmm/acpi_tables", branch = "main" }
|
acpi_tables = { git = "https://github.com/rust-vmm/acpi_tables", branch = "main" }
|
||||||
kvm-bindings = "0.10.0"
|
kvm-bindings = "0.10.0"
|
||||||
kvm-ioctls = "0.19.0"
|
kvm-ioctls = "0.19.1"
|
||||||
linux-loader = "0.13.0"
|
linux-loader = "0.13.0"
|
||||||
mshv-bindings = "0.3.2"
|
mshv-bindings = "0.5.1"
|
||||||
mshv-ioctls = "0.3.2"
|
mshv-ioctls = "0.5.1"
|
||||||
seccompiler = "0.4.0"
|
seccompiler = "0.5.0"
|
||||||
vfio-bindings = { git = "https://github.com/rust-vmm/vfio", branch = "main" }
|
vfio-bindings = { git = "https://github.com/rust-vmm/vfio", branch = "main" }
|
||||||
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio", branch = "main", default-features = false }
|
vfio-ioctls = { git = "https://github.com/rust-vmm/vfio", branch = "main", default-features = false }
|
||||||
vfio_user = { git = "https://github.com/rust-vmm/vfio-user", branch = "main" }
|
vfio_user = { git = "https://github.com/rust-vmm/vfio-user", branch = "main" }
|
||||||
@@ -119,3 +120,11 @@ virtio-queue = "0.14.0"
|
|||||||
vm-fdt = { git = "https://github.com/rust-vmm/vm-fdt", branch = "main" }
|
vm-fdt = { git = "https://github.com/rust-vmm/vm-fdt", branch = "main" }
|
||||||
vm-memory = "0.16.1"
|
vm-memory = "0.16.1"
|
||||||
vmm-sys-util = "0.12.1"
|
vmm-sys-util = "0.12.1"
|
||||||
|
|
||||||
|
# igvm crates
|
||||||
|
# TODO: bump to 0.3.5 release
|
||||||
|
igvm = { git = "https://github.com/microsoft/igvm", branch = "main" }
|
||||||
|
igvm_defs = { git = "https://github.com/microsoft/igvm", branch = "main" }
|
||||||
|
|
||||||
|
# serde crates
|
||||||
|
serde_json = "1.0.120"
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -59,9 +59,13 @@ based on the [Rust VMM](https://github.com/rust-vmm) crates.
|
|||||||
|
|
||||||
### Architectures
|
### Architectures
|
||||||
|
|
||||||
Cloud Hypervisor supports the `x86-64` and `AArch64` architectures. There are
|
Cloud Hypervisor supports the `x86-64`, `AArch64` and `riscv64`
|
||||||
minor differences in functionality between the two architectures
|
architectures, with functionality varying across these platforms. The
|
||||||
(see [#1125](https://github.com/cloud-hypervisor/cloud-hypervisor/issues/1125)).
|
functionality differences between `x86-64` and `AArch64` are documented
|
||||||
|
in [#1125](https://github.com/cloud-hypervisor/cloud-hypervisor/issues/1125).
|
||||||
|
The `riscv64` architecture support is experimental and offers limited
|
||||||
|
functionality. For more details and instructions, please refer to [riscv
|
||||||
|
documentation](docs/riscv.md).
|
||||||
|
|
||||||
### Guest OS
|
### Guest OS
|
||||||
|
|
||||||
@@ -181,14 +185,9 @@ To build the kernel:
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Clone the Cloud Hypervisor Linux branch
|
# Clone the Cloud Hypervisor Linux branch
|
||||||
$ git clone --depth 1 https://github.com/cloud-hypervisor/linux.git -b ch-6.2 linux-cloud-hypervisor
|
$ git clone --depth 1 https://github.com/cloud-hypervisor/linux.git -b ch-6.12.8 linux-cloud-hypervisor
|
||||||
$ pushd linux-cloud-hypervisor
|
$ pushd linux-cloud-hypervisor
|
||||||
# Use the x86-64 cloud-hypervisor kernel config to build your kernel for x86-64
|
$ make ch_defconfig
|
||||||
$ wget https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/main/resources/linux-config-x86_64
|
|
||||||
# Use the AArch64 cloud-hypervisor kernel config to build your kernel for AArch64
|
|
||||||
$ wget https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/main/resources/linux-config-aarch64
|
|
||||||
$ cp linux-config-x86_64 .config # x86-64
|
|
||||||
$ cp linux-config-aarch64 .config # AArch64
|
|
||||||
# Do native build of the x86-64 kernel
|
# Do native build of the x86-64 kernel
|
||||||
$ KCFLAGS="-Wa,-mx86-used-note=no" make bzImage -j `nproc`
|
$ KCFLAGS="-Wa,-mx86-used-note=no" make bzImage -j `nproc`
|
||||||
# Do native build of the AArch64 kernel
|
# Do native build of the AArch64 kernel
|
||||||
@@ -302,8 +301,9 @@ Further details can be found in the [release documentation](docs/releases.md).
|
|||||||
As of 2023-01-03, the following cloud images are supported:
|
As of 2023-01-03, the following cloud images are supported:
|
||||||
|
|
||||||
- [Ubuntu Focal](https://cloud-images.ubuntu.com/focal/current/) (focal-server-cloudimg-{amd64,arm64}.img)
|
- [Ubuntu Focal](https://cloud-images.ubuntu.com/focal/current/) (focal-server-cloudimg-{amd64,arm64}.img)
|
||||||
- [Ubuntu Jammy](https://cloud-images.ubuntu.com/jammy/current/) (jammy-server-cloudimg-{amd64,arm64}.img )
|
- [Ubuntu Jammy](https://cloud-images.ubuntu.com/jammy/current/) (jammy-server-cloudimg-{amd64,arm64}.img)
|
||||||
- [Fedora 36](https://fedora.mirrorservice.org/fedora/linux/releases/36/Cloud/) ([Fedora-Cloud-Base-36-1.5.x86_64.raw.xz](https://fedora.mirrorservice.org/fedora/linux/releases/36/Cloud/x86_64/images/) / [Fedora-Cloud-Base-36-1.5.aarch64.raw.xz](https://fedora.mirrorservice.org/fedora/linux/releases/36/Cloud/aarch64/images/))
|
- [Ubuntu Noble](https://cloud-images.ubuntu.com/noble/current/) (noble-server-cloudimg-{amd64,arm64}.img)
|
||||||
|
- [Fedora 36](https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Cloud/) ([Fedora-Cloud-Base-36-1.5.x86_64.raw.xz](https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Cloud/x86_64/images/) / [Fedora-Cloud-Base-36-1.5.aarch64.raw.xz](https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Cloud/aarch64/images/))
|
||||||
|
|
||||||
Direct kernel boot to userspace should work with a rootfs from most
|
Direct kernel boot to userspace should work with a rootfs from most
|
||||||
distributions although you may need to enable exotic filesystem types in the
|
distributions although you may need to enable exotic filesystem types in the
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ name = "api_client"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1.0.62"
|
thiserror = "2.0.6"
|
||||||
vmm-sys-util = { workspace = true }
|
vmm-sys-util = { workspace = true }
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ use vmm_sys_util::sock_ctrl_msg::ScmSocket;
|
|||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Error writing to or reading from HTTP socket: {0}")]
|
#[error("Error writing to or reading from HTTP socket: {0}")]
|
||||||
Socket(std::io::Error),
|
Socket(#[source] std::io::Error),
|
||||||
#[error("Error sending file descriptors: {0}")]
|
#[error("Error sending file descriptors: {0}")]
|
||||||
SocketSendFds(vmm_sys_util::errno::Error),
|
SocketSendFds(#[source] vmm_sys_util::errno::Error),
|
||||||
#[error("Error parsing HTTP status code: {0}")]
|
#[error("Error parsing HTTP status code: {0}")]
|
||||||
StatusCodeParsing(std::num::ParseIntError),
|
StatusCodeParsing(#[source] std::num::ParseIntError),
|
||||||
#[error("HTTP output is missing protocol statement")]
|
#[error("HTTP output is missing protocol statement")]
|
||||||
MissingProtocol,
|
MissingProtocol,
|
||||||
#[error("Error parsing HTTP Content-Length field: {0}")]
|
#[error("Error parsing HTTP Content-Length field: {0}")]
|
||||||
ContentLengthParsing(std::num::ParseIntError),
|
ContentLengthParsing(#[source] std::num::ParseIntError),
|
||||||
#[error("Server responded with an error: {0:?}: {1:?}")]
|
#[error("Server responded with an error: {0:?}: {1:?}")]
|
||||||
ServerResponse(StatusCode, Option<String>),
|
ServerResponse(StatusCode, Option<String>),
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ pub enum StatusCode {
|
|||||||
NoContent,
|
NoContent,
|
||||||
BadRequest,
|
BadRequest,
|
||||||
NotFound,
|
NotFound,
|
||||||
|
TooManyRequests,
|
||||||
InternalServerError,
|
InternalServerError,
|
||||||
NotImplemented,
|
NotImplemented,
|
||||||
Unknown,
|
Unknown,
|
||||||
@@ -45,6 +46,7 @@ impl StatusCode {
|
|||||||
204 => StatusCode::NoContent,
|
204 => StatusCode::NoContent,
|
||||||
400 => StatusCode::BadRequest,
|
400 => StatusCode::BadRequest,
|
||||||
404 => StatusCode::NotFound,
|
404 => StatusCode::NotFound,
|
||||||
|
429 => StatusCode::TooManyRequests,
|
||||||
500 => StatusCode::InternalServerError,
|
500 => StatusCode::InternalServerError,
|
||||||
501 => StatusCode::NotImplemented,
|
501 => StatusCode::NotImplemented,
|
||||||
_ => StatusCode::Unknown,
|
_ => StatusCode::Unknown,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ libc = "0.2.167"
|
|||||||
linux-loader = { workspace = true, features = ["bzimage", "elf", "pe"] }
|
linux-loader = { workspace = true, features = ["bzimage", "elf", "pe"] }
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
serde = { version = "1.0.208", features = ["derive", "rc"] }
|
serde = { version = "1.0.208", features = ["derive", "rc"] }
|
||||||
thiserror = "1.0.62"
|
thiserror = "2.0.6"
|
||||||
uuid = "1.8.0"
|
uuid = "1.12.1"
|
||||||
vm-memory = { workspace = true, features = ["backend-bitmap", "backend-mmap"] }
|
vm-memory = { workspace = true, features = ["backend-bitmap", "backend-mmap"] }
|
||||||
vm-migration = { path = "../vm-migration" }
|
vm-migration = { path = "../vm-migration" }
|
||||||
vmm-sys-util = { workspace = true, features = ["with-serde"] }
|
vmm-sys-util = { workspace = true, features = ["with-serde"] }
|
||||||
|
|||||||
@@ -15,14 +15,18 @@ use std::{cmp, fs, result, str};
|
|||||||
|
|
||||||
use byteorder::{BigEndian, ByteOrder};
|
use byteorder::{BigEndian, ByteOrder};
|
||||||
use hypervisor::arch::aarch64::gic::Vgic;
|
use hypervisor::arch::aarch64::gic::Vgic;
|
||||||
|
use hypervisor::arch::aarch64::regs::{
|
||||||
|
AARCH64_ARCH_TIMER_HYP_IRQ, AARCH64_ARCH_TIMER_PHYS_NONSECURE_IRQ,
|
||||||
|
AARCH64_ARCH_TIMER_PHYS_SECURE_IRQ, AARCH64_ARCH_TIMER_VIRT_IRQ, AARCH64_PMU_IRQ,
|
||||||
|
};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use vm_fdt::{FdtWriter, FdtWriterResult};
|
use vm_fdt::{FdtWriter, FdtWriterResult};
|
||||||
use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryRegion};
|
use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryRegion};
|
||||||
|
|
||||||
use super::super::{DeviceType, GuestMemoryMmap, InitramfsConfig};
|
use super::super::{DeviceType, GuestMemoryMmap, InitramfsConfig};
|
||||||
use super::layout::{
|
use super::layout::{
|
||||||
IRQ_BASE, MEM_32BIT_DEVICES_SIZE, MEM_32BIT_DEVICES_START, MEM_PCI_IO_SIZE, MEM_PCI_IO_START,
|
GIC_V2M_COMPATIBLE, IRQ_BASE, MEM_32BIT_DEVICES_SIZE, MEM_32BIT_DEVICES_START, MEM_PCI_IO_SIZE,
|
||||||
PCI_HIGH_BASE, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT,
|
MEM_PCI_IO_START, PCI_HIGH_BASE, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, SPI_BASE, SPI_NUM,
|
||||||
};
|
};
|
||||||
use crate::{NumaNodes, PciSpaceInfo};
|
use crate::{NumaNodes, PciSpaceInfo};
|
||||||
|
|
||||||
@@ -59,9 +63,6 @@ const GIC_FDT_IRQ_TYPE_PPI: u32 = 1;
|
|||||||
const IRQ_TYPE_EDGE_RISING: u32 = 1;
|
const IRQ_TYPE_EDGE_RISING: u32 = 1;
|
||||||
const IRQ_TYPE_LEVEL_HI: u32 = 4;
|
const IRQ_TYPE_LEVEL_HI: u32 = 4;
|
||||||
|
|
||||||
// PMU PPI interrupt number
|
|
||||||
pub const AARCH64_PMU_IRQ: u32 = 7;
|
|
||||||
|
|
||||||
// Keys and Buttons
|
// Keys and Buttons
|
||||||
// System Power Down
|
// System Power Down
|
||||||
const KEY_POWER: u32 = 116;
|
const KEY_POWER: u32 = 116;
|
||||||
@@ -81,7 +82,7 @@ pub trait DeviceInfoForFdt {
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failure in writing FDT in memory.
|
/// Failure in writing FDT in memory.
|
||||||
#[error("Failure in writing FDT in memory: {0}")]
|
#[error("Failure in writing FDT in memory: {0}")]
|
||||||
WriteFdtToMemory(GuestMemoryError),
|
WriteFdtToMemory(#[source] GuestMemoryError),
|
||||||
}
|
}
|
||||||
type Result<T> = result::Result<T, Error>;
|
type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
@@ -585,15 +586,14 @@ fn create_memory_node(
|
|||||||
&& (first_region_end <= &mem_32bit_reserved_start))
|
&& (first_region_end <= &mem_32bit_reserved_start))
|
||||||
{
|
{
|
||||||
panic!(
|
panic!(
|
||||||
"Unexpected first memory region layout: (start: 0x{:08x}, end: 0x{:08x}).
|
"Unexpected first memory region layout: (start: 0x{first_region_start:08x}, end: 0x{first_region_end:08x}).
|
||||||
ram_start: 0x{:08x}, mem_32bit_reserved_start: 0x{:08x}",
|
ram_start: 0x{ram_start:08x}, mem_32bit_reserved_start: 0x{mem_32bit_reserved_start:08x}"
|
||||||
first_region_start, first_region_end, ram_start, mem_32bit_reserved_start
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mem_size = first_region_end - ram_start;
|
let mem_size = first_region_end - ram_start;
|
||||||
let mem_reg_prop = [ram_start, mem_size];
|
let mem_reg_prop = [ram_start, mem_size];
|
||||||
let memory_node_name = format!("memory@{:x}", ram_start);
|
let memory_node_name = format!("memory@{ram_start:x}");
|
||||||
let memory_node = fdt.begin_node(&memory_node_name)?;
|
let memory_node = fdt.begin_node(&memory_node_name)?;
|
||||||
fdt.property_string("device_type", "memory")?;
|
fdt.property_string("device_type", "memory")?;
|
||||||
fdt.property_array_u64("reg", &mem_reg_prop)?;
|
fdt.property_array_u64("reg", &mem_reg_prop)?;
|
||||||
@@ -606,14 +606,13 @@ fn create_memory_node(
|
|||||||
|
|
||||||
if second_region_start != &ram_64bit_start {
|
if second_region_start != &ram_64bit_start {
|
||||||
panic!(
|
panic!(
|
||||||
"Unexpected second memory region layout: start: 0x{:08x}, ram_64bit_start: 0x{:08x}",
|
"Unexpected second memory region layout: start: 0x{second_region_start:08x}, ram_64bit_start: 0x{ram_64bit_start:08x}"
|
||||||
second_region_start, ram_64bit_start
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mem_size = second_region_end - ram_64bit_start;
|
let mem_size = second_region_end - ram_64bit_start;
|
||||||
let mem_reg_prop = [ram_64bit_start, mem_size];
|
let mem_reg_prop = [ram_64bit_start, mem_size];
|
||||||
let memory_node_name = format!("memory@{:x}", ram_64bit_start);
|
let memory_node_name = format!("memory@{ram_64bit_start:x}");
|
||||||
let memory_node = fdt.begin_node(&memory_node_name)?;
|
let memory_node = fdt.begin_node(&memory_node_name)?;
|
||||||
fdt.property_string("device_type", "memory")?;
|
fdt.property_string("device_type", "memory")?;
|
||||||
fdt.property_array_u64("reg", &mem_reg_prop)?;
|
fdt.property_array_u64("reg", &mem_reg_prop)?;
|
||||||
@@ -670,11 +669,19 @@ fn create_gic_node(fdt: &mut FdtWriter, gic_device: &Arc<Mutex<dyn Vgic>>) -> Fd
|
|||||||
|
|
||||||
if gic_device.lock().unwrap().msi_compatible() {
|
if gic_device.lock().unwrap().msi_compatible() {
|
||||||
let msic_node = fdt.begin_node("msic")?;
|
let msic_node = fdt.begin_node("msic")?;
|
||||||
fdt.property_string("compatible", gic_device.lock().unwrap().msi_compatibility())?;
|
let msi_compatibility = gic_device.lock().unwrap().msi_compatibility().to_string();
|
||||||
|
|
||||||
|
fdt.property_string("compatible", msi_compatibility.as_str())?;
|
||||||
fdt.property_null("msi-controller")?;
|
fdt.property_null("msi-controller")?;
|
||||||
fdt.property_u32("phandle", MSI_PHANDLE)?;
|
fdt.property_u32("phandle", MSI_PHANDLE)?;
|
||||||
let msi_reg_prop = gic_device.lock().unwrap().msi_properties();
|
let msi_reg_prop = gic_device.lock().unwrap().msi_properties();
|
||||||
fdt.property_array_u64("reg", &msi_reg_prop)?;
|
fdt.property_array_u64("reg", &msi_reg_prop)?;
|
||||||
|
|
||||||
|
if msi_compatibility == GIC_V2M_COMPATIBLE {
|
||||||
|
fdt.property_u32("arm,msi-base-spi", SPI_BASE)?;
|
||||||
|
fdt.property_u32("arm,msi-num-spis", SPI_NUM)?;
|
||||||
|
}
|
||||||
|
|
||||||
fdt.end_node(msic_node)?;
|
fdt.end_node(msic_node)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,9 +708,14 @@ fn create_clock_node(fdt: &mut FdtWriter) -> FdtWriterResult<()> {
|
|||||||
|
|
||||||
fn create_timer_node(fdt: &mut FdtWriter) -> FdtWriterResult<()> {
|
fn create_timer_node(fdt: &mut FdtWriter) -> FdtWriterResult<()> {
|
||||||
// See
|
// See
|
||||||
// https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/interrupt-controller/arch_timer.txt
|
// https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/timer/arm%2Carch_timer.yaml
|
||||||
// These are fixed interrupt numbers for the timer device.
|
// These are fixed interrupt numbers for the timer device.
|
||||||
let irqs = [13, 14, 11, 10];
|
let irqs = [
|
||||||
|
AARCH64_ARCH_TIMER_PHYS_SECURE_IRQ,
|
||||||
|
AARCH64_ARCH_TIMER_PHYS_NONSECURE_IRQ,
|
||||||
|
AARCH64_ARCH_TIMER_VIRT_IRQ,
|
||||||
|
AARCH64_ARCH_TIMER_HYP_IRQ,
|
||||||
|
];
|
||||||
let compatible = "arm,armv8-timer";
|
let compatible = "arm,armv8-timer";
|
||||||
|
|
||||||
let mut timer_reg_cells: Vec<u32> = Vec::new();
|
let mut timer_reg_cells: Vec<u32> = Vec::new();
|
||||||
@@ -1109,10 +1121,7 @@ fn print_node(node: fdt_parser::node::FdtNode<'_, '_>, n_spaces: usize) {
|
|||||||
// - At first, try to convert it to CStr and print,
|
// - At first, try to convert it to CStr and print,
|
||||||
// - If failed, print it as u32 array.
|
// - If failed, print it as u32 array.
|
||||||
let value_result = match CStr::from_bytes_with_nul(value) {
|
let value_result = match CStr::from_bytes_with_nul(value) {
|
||||||
Ok(value_cstr) => match value_cstr.to_str() {
|
Ok(value_cstr) => value_cstr.to_str().ok(),
|
||||||
Ok(value_str) => Some(value_str),
|
|
||||||
Err(_e) => None,
|
|
||||||
},
|
|
||||||
Err(_e) => None,
|
Err(_e) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -138,3 +138,12 @@ pub const IRQ_BASE: u32 = 32;
|
|||||||
|
|
||||||
/// Number of supported interrupts
|
/// Number of supported interrupts
|
||||||
pub const IRQ_NUM: u32 = 256;
|
pub const IRQ_NUM: u32 = 256;
|
||||||
|
|
||||||
|
/// Base SPI interrupt number
|
||||||
|
pub const SPI_BASE: u32 = 32;
|
||||||
|
|
||||||
|
/// Total number of SPIs
|
||||||
|
pub const SPI_NUM: u32 = 64;
|
||||||
|
|
||||||
|
/// GICv2M compatible string
|
||||||
|
pub const GIC_V2M_COMPATIBLE: &str = "arm,gic-v2m-frame";
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
pub mod fdt;
|
pub mod fdt;
|
||||||
/// Layout for this aarch64 system.
|
/// Layout for this aarch64 system.
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
/// Module for system registers definition
|
|
||||||
pub mod regs;
|
|
||||||
/// Module for loading UEFI binary.
|
/// Module for loading UEFI binary.
|
||||||
pub mod uefi;
|
pub mod uefi;
|
||||||
|
|
||||||
@@ -16,6 +14,7 @@ use std::fmt::Debug;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use hypervisor::arch::aarch64::gic::Vgic;
|
use hypervisor::arch::aarch64::gic::Vgic;
|
||||||
|
use hypervisor::arch::aarch64::regs::MPIDR_EL1;
|
||||||
use log::{log_enabled, Level};
|
use log::{log_enabled, Level};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use vm_memory::{Address, GuestAddress, GuestMemory, GuestMemoryAtomic};
|
use vm_memory::{Address, GuestAddress, GuestMemory, GuestMemoryAtomic};
|
||||||
@@ -34,7 +33,7 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Failed to write FDT to memory.
|
/// Failed to write FDT to memory.
|
||||||
#[error("Failed to write FDT to memory: {0}")]
|
#[error("Failed to write FDT to memory: {0}")]
|
||||||
WriteFdtToMemory(fdt::Error),
|
WriteFdtToMemory(#[source] fdt::Error),
|
||||||
|
|
||||||
/// Failed to create a GIC.
|
/// Failed to create a GIC.
|
||||||
#[error("Failed to create a GIC")]
|
#[error("Failed to create a GIC")]
|
||||||
@@ -46,11 +45,11 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Error configuring the general purpose registers
|
/// Error configuring the general purpose registers
|
||||||
#[error("Error configuring the general purpose registers: {0}")]
|
#[error("Error configuring the general purpose registers: {0}")]
|
||||||
RegsConfiguration(hypervisor::HypervisorCpuError),
|
RegsConfiguration(#[source] hypervisor::HypervisorCpuError),
|
||||||
|
|
||||||
/// Error configuring the MPIDR register
|
/// Error configuring the MPIDR register
|
||||||
#[error("Error configuring the MPIDR register: {0}")]
|
#[error("Error configuring the MPIDR register: {0}")]
|
||||||
VcpuRegMpidr(hypervisor::HypervisorCpuError),
|
VcpuRegMpidr(#[source] hypervisor::HypervisorCpuError),
|
||||||
|
|
||||||
/// Error initializing PMU for vcpu
|
/// Error initializing PMU for vcpu
|
||||||
#[error("Error initializing PMU for vcpu")]
|
#[error("Error initializing PMU for vcpu")]
|
||||||
@@ -86,9 +85,7 @@ pub fn configure_vcpu(
|
|||||||
.map_err(Error::RegsConfiguration)?;
|
.map_err(Error::RegsConfiguration)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mpidr = vcpu
|
let mpidr = vcpu.get_sys_reg(MPIDR_EL1).map_err(Error::VcpuRegMpidr)?;
|
||||||
.get_sys_reg(regs::MPIDR_EL1)
|
|
||||||
.map_err(Error::VcpuRegMpidr)?;
|
|
||||||
Ok(mpidr)
|
Ok(mpidr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
// Copyright 2022 Arm Limited (or its affiliates). All rights reserved.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
// AArch64 system register encoding:
|
|
||||||
// See https://developer.arm.com/documentation/ddi0487 (chapter D12)
|
|
||||||
//
|
|
||||||
// 31 22 21 20 19 18 16 15 12 11 8 7 5 4 0
|
|
||||||
// +----------+---+-----+-----+-----+-----+-----+----+
|
|
||||||
// |1101010100| L | op0 | op1 | CRn | CRm | op2 | Rt |
|
|
||||||
// +----------+---+-----+-----+-----+-----+-----+----+
|
|
||||||
//
|
|
||||||
// Notes:
|
|
||||||
// - L and Rt are reserved as implementation defined fields, ignored.
|
|
||||||
|
|
||||||
const SYSREG_HEAD: u32 = 0b1101010100u32 << 22;
|
|
||||||
const SYSREG_OP0_SHIFT: u32 = 19;
|
|
||||||
const SYSREG_OP0_MASK: u32 = 0b11u32 << 19;
|
|
||||||
const SYSREG_OP1_SHIFT: u32 = 16;
|
|
||||||
const SYSREG_OP1_MASK: u32 = 0b111u32 << 16;
|
|
||||||
const SYSREG_CRN_SHIFT: u32 = 12;
|
|
||||||
const SYSREG_CRN_MASK: u32 = 0b1111u32 << 12;
|
|
||||||
const SYSREG_CRM_SHIFT: u32 = 8;
|
|
||||||
const SYSREG_CRM_MASK: u32 = 0b1111u32 << 8;
|
|
||||||
const SYSREG_OP2_SHIFT: u32 = 5;
|
|
||||||
const SYSREG_OP2_MASK: u32 = 0b111u32 << 5;
|
|
||||||
|
|
||||||
/// Define the ID of system registers
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! arm64_sys_reg {
|
|
||||||
($name: tt, $op0: tt, $op1: tt, $crn: tt, $crm: tt, $op2: tt) => {
|
|
||||||
pub const $name: u32 = SYSREG_HEAD
|
|
||||||
| ((($op0 as u32) << SYSREG_OP0_SHIFT) & SYSREG_OP0_MASK as u32)
|
|
||||||
| ((($op1 as u32) << SYSREG_OP1_SHIFT) & SYSREG_OP1_MASK as u32)
|
|
||||||
| ((($crn as u32) << SYSREG_CRN_SHIFT) & SYSREG_CRN_MASK as u32)
|
|
||||||
| ((($crm as u32) << SYSREG_CRM_SHIFT) & SYSREG_CRM_MASK as u32)
|
|
||||||
| ((($op2 as u32) << SYSREG_OP2_SHIFT) & SYSREG_OP2_MASK as u32);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
arm64_sys_reg!(MPIDR_EL1, 3, 0, 0, 0, 5);
|
|
||||||
arm64_sys_reg!(ID_AA64MMFR0_EL1, 3, 0, 0, 7, 0);
|
|
||||||
arm64_sys_reg!(TTBR1_EL1, 3, 0, 2, 0, 1);
|
|
||||||
arm64_sys_reg!(TCR_EL1, 3, 0, 2, 0, 2);
|
|
||||||
@@ -28,14 +28,14 @@ type GuestRegionMmap = vm_memory::GuestRegionMmap<vm_memory::bitmap::AtomicBitma
|
|||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
#[error("Platform specific error (x86_64): {0:?}")]
|
#[error("Platform specific error (x86_64): {0}")]
|
||||||
PlatformSpecific(x86_64::Error),
|
PlatformSpecific(#[source] x86_64::Error),
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[error("Platform specific error (aarch64): {0:?}")]
|
#[error("Platform specific error (aarch64): {0:?}")]
|
||||||
PlatformSpecific(aarch64::Error),
|
PlatformSpecific(#[source] aarch64::Error),
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
#[error("Platform specific error (riscv64): {0:?}")]
|
#[error("Platform specific error (riscv64): {0:?}")]
|
||||||
PlatformSpecific(riscv64::Error),
|
PlatformSpecific(#[source] riscv64::Error),
|
||||||
#[error("The memory map table extends past the end of guest memory")]
|
#[error("The memory map table extends past the end of guest memory")]
|
||||||
MemmapTablePastRamEnd,
|
MemmapTablePastRamEnd,
|
||||||
#[error("Error writing memory map table to guest memory")]
|
#[error("Error writing memory map table to guest memory")]
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ pub trait DeviceInfoForFdt {
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failure in writing FDT in memory.
|
/// Failure in writing FDT in memory.
|
||||||
#[error("Failure in writing FDT in memory: {0}")]
|
#[error("Failure in writing FDT in memory: {0}")]
|
||||||
WriteFdtToMemory(GuestMemoryError),
|
WriteFdtToMemory(#[source] GuestMemoryError),
|
||||||
}
|
}
|
||||||
type Result<T> = result::Result<T, Error>;
|
type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ fn create_cpu_nodes(fdt: &mut FdtWriter, num_cpus: u32) -> FdtWriterResult<()> {
|
|||||||
let intc_node = fdt.begin_node("interrupt-controller")?;
|
let intc_node = fdt.begin_node("interrupt-controller")?;
|
||||||
fdt.property_string("compatible", "riscv,cpu-intc")?;
|
fdt.property_string("compatible", "riscv,cpu-intc")?;
|
||||||
fdt.property_u32("#interrupt-cells", 1u32)?;
|
fdt.property_u32("#interrupt-cells", 1u32)?;
|
||||||
fdt.property_null("#interrupt-controller")?;
|
fdt.property_null("interrupt-controller")?;
|
||||||
fdt.property_u32("phandle", CPU_INTC_BASE_PHANDLE + cpu_index)?;
|
fdt.property_u32("phandle", CPU_INTC_BASE_PHANDLE + cpu_index)?;
|
||||||
fdt.end_node(intc_node)?;
|
fdt.end_node(intc_node)?;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Failed to write FDT to memory.
|
/// Failed to write FDT to memory.
|
||||||
#[error("Failed to write FDT to memory: {0}")]
|
#[error("Failed to write FDT to memory: {0}")]
|
||||||
WriteFdtToMemory(fdt::Error),
|
WriteFdtToMemory(#[source] fdt::Error),
|
||||||
|
|
||||||
/// Failed to create a AIA.
|
/// Failed to create a AIA.
|
||||||
#[error("Failed to create a AIA")]
|
#[error("Failed to create a AIA")]
|
||||||
@@ -43,7 +43,7 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Error configuring the general purpose registers
|
/// Error configuring the general purpose registers
|
||||||
#[error("Error configuring the general purpose registers: {0}")]
|
#[error("Error configuring the general purpose registers: {0}")]
|
||||||
RegsConfiguration(hypervisor::HypervisorCpuError),
|
RegsConfiguration(#[source] hypervisor::HypervisorCpuError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Error> for super::Error {
|
impl From<Error> for super::Error {
|
||||||
|
|||||||
@@ -133,35 +133,35 @@ pub struct CpuidConfig {
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Error writing MP table to memory.
|
/// Error writing MP table to memory.
|
||||||
#[error("Error writing MP table to memory: {0}")]
|
#[error("Error writing MP table to memory: {0}")]
|
||||||
MpTableSetup(mptable::Error),
|
MpTableSetup(#[source] mptable::Error),
|
||||||
|
|
||||||
/// Error configuring the general purpose registers
|
/// Error configuring the general purpose registers
|
||||||
#[error("Error configuring the general purpose registers: {0}")]
|
#[error("Error configuring the general purpose registers: {0}")]
|
||||||
RegsConfiguration(regs::Error),
|
RegsConfiguration(#[source] regs::Error),
|
||||||
|
|
||||||
/// Error configuring the special registers
|
/// Error configuring the special registers
|
||||||
#[error("Error configuring the special registers: {0}")]
|
#[error("Error configuring the special registers: {0}")]
|
||||||
SregsConfiguration(regs::Error),
|
SregsConfiguration(#[source] regs::Error),
|
||||||
|
|
||||||
/// Error configuring the floating point related registers
|
/// Error configuring the floating point related registers
|
||||||
#[error("Error configuring the floating point related registers: {0}")]
|
#[error("Error configuring the floating point related registers: {0}")]
|
||||||
FpuConfiguration(regs::Error),
|
FpuConfiguration(#[source] regs::Error),
|
||||||
|
|
||||||
/// Error configuring the MSR registers
|
/// Error configuring the MSR registers
|
||||||
#[error("Error configuring the MSR registers: {0}")]
|
#[error("Error configuring the MSR registers: {0}")]
|
||||||
MsrsConfiguration(regs::Error),
|
MsrsConfiguration(#[source] regs::Error),
|
||||||
|
|
||||||
/// Failed to set supported CPUs.
|
/// Failed to set supported CPUs.
|
||||||
#[error("Failed to set supported CPUs: {0}")]
|
#[error("Failed to set supported CPUs: {0}")]
|
||||||
SetSupportedCpusFailed(anyhow::Error),
|
SetSupportedCpusFailed(#[source] anyhow::Error),
|
||||||
|
|
||||||
/// Cannot set the local interruption due to bad configuration.
|
/// Cannot set the local interruption due to bad configuration.
|
||||||
#[error("Cannot set the local interruption due to bad configuration: {0}")]
|
#[error("Cannot set the local interruption due to bad configuration: {0}")]
|
||||||
LocalIntConfiguration(anyhow::Error),
|
LocalIntConfiguration(#[source] anyhow::Error),
|
||||||
|
|
||||||
/// Error setting up SMBIOS table
|
/// Error setting up SMBIOS table
|
||||||
#[error("Error setting up SMBIOS table: {0}")]
|
#[error("Error setting up SMBIOS table: {0}")]
|
||||||
SmbiosSetup(smbios::Error),
|
SmbiosSetup(#[source] smbios::Error),
|
||||||
|
|
||||||
/// Could not find any SGX EPC section
|
/// Could not find any SGX EPC section
|
||||||
#[error("Could not find any SGX EPC section")]
|
#[error("Could not find any SGX EPC section")]
|
||||||
@@ -177,15 +177,15 @@ pub enum Error {
|
|||||||
|
|
||||||
/// Error getting supported CPUID through the hypervisor (kvm/mshv) API
|
/// Error getting supported CPUID through the hypervisor (kvm/mshv) API
|
||||||
#[error("Error getting supported CPUID through the hypervisor API: {0}")]
|
#[error("Error getting supported CPUID through the hypervisor API: {0}")]
|
||||||
CpuidGetSupported(HypervisorError),
|
CpuidGetSupported(#[source] HypervisorError),
|
||||||
|
|
||||||
/// Error populating CPUID with KVM HyperV emulation details
|
/// Error populating CPUID with KVM HyperV emulation details
|
||||||
#[error("Error populating CPUID with KVM HyperV emulation details: {0}")]
|
#[error("Error populating CPUID with KVM HyperV emulation details: {0}")]
|
||||||
CpuidKvmHyperV(vmm_sys_util::fam::Error),
|
CpuidKvmHyperV(#[source] vmm_sys_util::fam::Error),
|
||||||
|
|
||||||
/// Error populating CPUID with CPU identification
|
/// Error populating CPUID with CPU identification
|
||||||
#[error("Error populating CPUID with CPU identification: {0}")]
|
#[error("Error populating CPUID with CPU identification: {0}")]
|
||||||
CpuidIdentification(vmm_sys_util::fam::Error),
|
CpuidIdentification(#[source] vmm_sys_util::fam::Error),
|
||||||
|
|
||||||
/// Error checking CPUID compatibility
|
/// Error checking CPUID compatibility
|
||||||
#[error("Error checking CPUID compatibility")]
|
#[error("Error checking CPUID compatibility")]
|
||||||
@@ -193,16 +193,16 @@ pub enum Error {
|
|||||||
|
|
||||||
// Error writing EBDA address
|
// Error writing EBDA address
|
||||||
#[error("Error writing EBDA address: {0}")]
|
#[error("Error writing EBDA address: {0}")]
|
||||||
EbdaSetup(vm_memory::GuestMemoryError),
|
EbdaSetup(#[source] vm_memory::GuestMemoryError),
|
||||||
|
|
||||||
// Error getting CPU TSC frequency
|
// Error getting CPU TSC frequency
|
||||||
#[error("Error getting CPU TSC frequency: {0}")]
|
#[error("Error getting CPU TSC frequency: {0}")]
|
||||||
GetTscFrequency(HypervisorCpuError),
|
GetTscFrequency(#[source] HypervisorCpuError),
|
||||||
|
|
||||||
/// Error retrieving TDX capabilities through the hypervisor (kvm/mshv) API
|
/// Error retrieving TDX capabilities through the hypervisor (kvm/mshv) API
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
#[error("Error retrieving TDX capabilities through the hypervisor API: {0}")]
|
#[error("Error retrieving TDX capabilities through the hypervisor API: {0}")]
|
||||||
TdxCapabilities(HypervisorError),
|
TdxCapabilities(#[source] HypervisorError),
|
||||||
|
|
||||||
/// Failed to configure E820 map for bzImage
|
/// Failed to configure E820 map for bzImage
|
||||||
#[error("Failed to configure E820 map for bzImage")]
|
#[error("Failed to configure E820 map for bzImage")]
|
||||||
@@ -601,7 +601,7 @@ pub fn generate_common_cpuid(
|
|||||||
config: &CpuidConfig,
|
config: &CpuidConfig,
|
||||||
) -> super::Result<Vec<CpuIdEntry>> {
|
) -> super::Result<Vec<CpuIdEntry>> {
|
||||||
// SAFETY: cpuid called with valid leaves
|
// SAFETY: cpuid called with valid leaves
|
||||||
if unsafe { x86_64::__cpuid(1) }.ecx & 1 << HYPERVISOR_ECX_BIT == 1 << HYPERVISOR_ECX_BIT {
|
if unsafe { x86_64::__cpuid(1) }.ecx & (1 << HYPERVISOR_ECX_BIT) == 1 << HYPERVISOR_ECX_BIT {
|
||||||
// SAFETY: cpuid called with valid leaves
|
// SAFETY: cpuid called with valid leaves
|
||||||
let hypervisor_cpuid = unsafe { x86_64::__cpuid(0x4000_0000) };
|
let hypervisor_cpuid = unsafe { x86_64::__cpuid(0x4000_0000) };
|
||||||
|
|
||||||
@@ -689,7 +689,7 @@ pub fn generate_common_cpuid(
|
|||||||
// Clear AMX related bits if the AMX feature is not enabled
|
// Clear AMX related bits if the AMX feature is not enabled
|
||||||
0x7 => {
|
0x7 => {
|
||||||
if !config.amx && entry.index == 0 {
|
if !config.amx && entry.index == 0 {
|
||||||
entry.edx &= !(1 << AMX_BF16 | 1 << AMX_TILE | 1 << AMX_INT8)
|
entry.edx &= !((1 << AMX_BF16) | (1 << AMX_TILE) | (1 << AMX_INT8))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0xd =>
|
0xd =>
|
||||||
@@ -747,12 +747,12 @@ pub fn generate_common_cpuid(
|
|||||||
// These features are not supported by TDX
|
// These features are not supported by TDX
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
if config.tdx {
|
if config.tdx {
|
||||||
entry.eax &= !(1 << KVM_FEATURE_CLOCKSOURCE_BIT
|
entry.eax &= !((1 << KVM_FEATURE_CLOCKSOURCE_BIT)
|
||||||
| 1 << KVM_FEATURE_CLOCKSOURCE2_BIT
|
| (1 << KVM_FEATURE_CLOCKSOURCE2_BIT)
|
||||||
| 1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
|
| (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT)
|
||||||
| 1 << KVM_FEATURE_ASYNC_PF_BIT
|
| (1 << KVM_FEATURE_ASYNC_PF_BIT)
|
||||||
| 1 << KVM_FEATURE_ASYNC_PF_VMEXIT_BIT
|
| (1 << KVM_FEATURE_ASYNC_PF_VMEXIT_BIT)
|
||||||
| 1 << KVM_FEATURE_STEAL_TIME_BIT)
|
| (1 << KVM_FEATURE_STEAL_TIME_BIT))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -801,10 +801,10 @@ pub fn generate_common_cpuid(
|
|||||||
});
|
});
|
||||||
cpuid.push(CpuIdEntry {
|
cpuid.push(CpuIdEntry {
|
||||||
function: 0x4000_0003,
|
function: 0x4000_0003,
|
||||||
eax: 1 << 1 // AccessPartitionReferenceCounter
|
eax: (1 << 1) // AccessPartitionReferenceCounter
|
||||||
| 1 << 2 // AccessSynicRegs
|
| (1 << 2) // AccessSynicRegs
|
||||||
| 1 << 3 // AccessSyntheticTimerRegs
|
| (1 << 3) // AccessSyntheticTimerRegs
|
||||||
| 1 << 9, // AccessPartitionReferenceTsc
|
| (1 << 9), // AccessPartitionReferenceTsc
|
||||||
edx: 1 << 3, // CPU dynamic partitioning
|
edx: 1 << 3, // CPU dynamic partitioning
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
@@ -887,6 +887,10 @@ pub fn configure_vcpu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for c in &cpuid {
|
||||||
|
info!("{}", c);
|
||||||
|
}
|
||||||
|
|
||||||
vcpu.set_cpuid2(&cpuid)
|
vcpu.set_cpuid2(&cpuid)
|
||||||
.map_err(|e| Error::SetSupportedCpusFailed(e.into()))?;
|
.map_err(|e| Error::SetSupportedCpusFailed(e.into()))?;
|
||||||
|
|
||||||
@@ -1380,7 +1384,7 @@ fn update_cpuid_topology(
|
|||||||
|
|
||||||
let mut cpu_ebx = CpuidPatch::get_cpuid_reg(cpuid, 0x1, None, CpuidReg::EBX).unwrap_or(0);
|
let mut cpu_ebx = CpuidPatch::get_cpuid_reg(cpuid, 0x1, None, CpuidReg::EBX).unwrap_or(0);
|
||||||
cpu_ebx |= ((dies_per_package as u32) * (cores_per_die as u32) * (threads_per_core as u32))
|
cpu_ebx |= ((dies_per_package as u32) * (cores_per_die as u32) * (threads_per_core as u32))
|
||||||
& 0xff << 16;
|
& (0xff << 16);
|
||||||
CpuidPatch::set_cpuid_reg(cpuid, 0x1, None, CpuidReg::EBX, cpu_ebx);
|
CpuidPatch::set_cpuid_reg(cpuid, 0x1, None, CpuidReg::EBX, cpu_ebx);
|
||||||
|
|
||||||
let mut cpu_edx = CpuidPatch::get_cpuid_reg(cpuid, 0x1, None, CpuidReg::EDX).unwrap_or(0);
|
let mut cpu_edx = CpuidPatch::get_cpuid_reg(cpuid, 0x1, None, CpuidReg::EDX).unwrap_or(0);
|
||||||
@@ -1407,6 +1411,7 @@ fn update_cpuid_topology(
|
|||||||
u32::from(dies_per_package * cores_per_die * threads_per_core),
|
u32::from(dies_per_package * cores_per_die * threads_per_core),
|
||||||
);
|
);
|
||||||
CpuidPatch::set_cpuid_reg(cpuid, 0xb, Some(1), CpuidReg::ECX, 2 << 8);
|
CpuidPatch::set_cpuid_reg(cpuid, 0xb, Some(1), CpuidReg::ECX, 2 << 8);
|
||||||
|
CpuidPatch::set_cpuid_reg(cpuid, 0xb, Some(1), CpuidReg::EDX, x2apic_id);
|
||||||
|
|
||||||
// CPU Topology leaf 0x1f
|
// CPU Topology leaf 0x1f
|
||||||
CpuidPatch::set_cpuid_reg(cpuid, 0x1f, Some(0), CpuidReg::EAX, thread_width);
|
CpuidPatch::set_cpuid_reg(cpuid, 0x1f, Some(0), CpuidReg::EAX, thread_width);
|
||||||
|
|||||||
@@ -60,31 +60,31 @@ pub enum Error {
|
|||||||
AddressOverflow,
|
AddressOverflow,
|
||||||
/// Failure while zeroing out the memory for the MP table.
|
/// Failure while zeroing out the memory for the MP table.
|
||||||
#[error("Failure while zeroing out the memory for the MP table: {0}")]
|
#[error("Failure while zeroing out the memory for the MP table: {0}")]
|
||||||
Clear(GuestMemoryError),
|
Clear(#[source] GuestMemoryError),
|
||||||
/// Number of CPUs exceeds the maximum supported CPUs
|
/// Number of CPUs exceeds the maximum supported CPUs
|
||||||
#[error("Number of CPUs exceeds the maximum supported CPUs")]
|
#[error("Number of CPUs exceeds the maximum supported CPUs")]
|
||||||
TooManyCpus,
|
TooManyCpus,
|
||||||
/// Failure to write the MP floating pointer.
|
/// Failure to write the MP floating pointer.
|
||||||
#[error("Failure to write the MP floating pointer: {0}")]
|
#[error("Failure to write the MP floating pointer: {0}")]
|
||||||
WriteMpfIntel(GuestMemoryError),
|
WriteMpfIntel(#[source] GuestMemoryError),
|
||||||
/// Failure to write MP CPU entry.
|
/// Failure to write MP CPU entry.
|
||||||
#[error("Failure to write MP CPU entry: {0}")]
|
#[error("Failure to write MP CPU entry: {0}")]
|
||||||
WriteMpcCpu(GuestMemoryError),
|
WriteMpcCpu(#[source] GuestMemoryError),
|
||||||
/// Failure to write MP ioapic entry.
|
/// Failure to write MP ioapic entry.
|
||||||
#[error("Failure to write MP ioapic entry: {0}")]
|
#[error("Failure to write MP ioapic entry: {0}")]
|
||||||
WriteMpcIoapic(GuestMemoryError),
|
WriteMpcIoapic(#[source] GuestMemoryError),
|
||||||
/// Failure to write MP bus entry.
|
/// Failure to write MP bus entry.
|
||||||
#[error("Failure to write MP bus entry: {0}")]
|
#[error("Failure to write MP bus entry: {0}")]
|
||||||
WriteMpcBus(GuestMemoryError),
|
WriteMpcBus(#[source] GuestMemoryError),
|
||||||
/// Failure to write MP interrupt source entry.
|
/// Failure to write MP interrupt source entry.
|
||||||
#[error("Failure to write MP interrupt source entry: {0}")]
|
#[error("Failure to write MP interrupt source entry: {0}")]
|
||||||
WriteMpcIntsrc(GuestMemoryError),
|
WriteMpcIntsrc(#[source] GuestMemoryError),
|
||||||
/// Failure to write MP local interrupt source entry.
|
/// Failure to write MP local interrupt source entry.
|
||||||
#[error("Failure to write MP local interrupt source entry: {0}")]
|
#[error("Failure to write MP local interrupt source entry: {0}")]
|
||||||
WriteMpcLintsrc(GuestMemoryError),
|
WriteMpcLintsrc(#[source] GuestMemoryError),
|
||||||
/// Failure to write MP table header.
|
/// Failure to write MP table header.
|
||||||
#[error("Failure to write MP table header: {0}")]
|
#[error("Failure to write MP table header: {0}")]
|
||||||
WriteMpcTable(GuestMemoryError),
|
WriteMpcTable(#[source] GuestMemoryError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|||||||
@@ -24,40 +24,40 @@ use crate::{EntryPoint, GuestMemoryMmap};
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to get SREGs for this CPU.
|
/// Failed to get SREGs for this CPU.
|
||||||
#[error("Failed to get SREGs for this CPU: {0}")]
|
#[error("Failed to get SREGs for this CPU: {0}")]
|
||||||
GetStatusRegisters(hypervisor::HypervisorCpuError),
|
GetStatusRegisters(#[source] hypervisor::HypervisorCpuError),
|
||||||
/// Failed to set base registers for this CPU.
|
/// Failed to set base registers for this CPU.
|
||||||
#[error("Failed to set base registers for this CPU: {0}")]
|
#[error("Failed to set base registers for this CPU: {0}")]
|
||||||
SetBaseRegisters(hypervisor::HypervisorCpuError),
|
SetBaseRegisters(#[source] hypervisor::HypervisorCpuError),
|
||||||
/// Failed to configure the FPU.
|
/// Failed to configure the FPU.
|
||||||
#[error("Failed to configure the FPU: {0}")]
|
#[error("Failed to configure the FPU: {0}")]
|
||||||
SetFpuRegisters(hypervisor::HypervisorCpuError),
|
SetFpuRegisters(#[source] hypervisor::HypervisorCpuError),
|
||||||
/// Setting up MSRs failed.
|
/// Setting up MSRs failed.
|
||||||
#[error("Setting up MSRs failed: {0}")]
|
#[error("Setting up MSRs failed: {0}")]
|
||||||
SetModelSpecificRegisters(hypervisor::HypervisorCpuError),
|
SetModelSpecificRegisters(#[source] hypervisor::HypervisorCpuError),
|
||||||
/// Failed to set SREGs for this CPU.
|
/// Failed to set SREGs for this CPU.
|
||||||
#[error("Failed to set SREGs for this CPU: {0}")]
|
#[error("Failed to set SREGs for this CPU: {0}")]
|
||||||
SetStatusRegisters(hypervisor::HypervisorCpuError),
|
SetStatusRegisters(#[source] hypervisor::HypervisorCpuError),
|
||||||
/// Checking the GDT address failed.
|
/// Checking the GDT address failed.
|
||||||
#[error("Checking the GDT address failed")]
|
#[error("Checking the GDT address failed")]
|
||||||
CheckGdtAddr,
|
CheckGdtAddr,
|
||||||
/// Writing the GDT to RAM failed.
|
/// Writing the GDT to RAM failed.
|
||||||
#[error("Writing the GDT to RAM failed: {0}")]
|
#[error("Writing the GDT to RAM failed: {0}")]
|
||||||
WriteGdt(GuestMemoryError),
|
WriteGdt(#[source] GuestMemoryError),
|
||||||
/// Writing the IDT to RAM failed.
|
/// Writing the IDT to RAM failed.
|
||||||
#[error("Writing the IDT to RAM failed: {0}")]
|
#[error("Writing the IDT to RAM failed: {0}")]
|
||||||
WriteIdt(GuestMemoryError),
|
WriteIdt(#[source] GuestMemoryError),
|
||||||
/// Writing PDPTE to RAM failed.
|
/// Writing PDPTE to RAM failed.
|
||||||
#[error("Writing PDPTE to RAM failed: {0}")]
|
#[error("Writing PDPTE to RAM failed: {0}")]
|
||||||
WritePdpteAddress(GuestMemoryError),
|
WritePdpteAddress(#[source] GuestMemoryError),
|
||||||
/// Writing PDE to RAM failed.
|
/// Writing PDE to RAM failed.
|
||||||
#[error("Writing PDE to RAM failed: {0}")]
|
#[error("Writing PDE to RAM failed: {0}")]
|
||||||
WritePdeAddress(GuestMemoryError),
|
WritePdeAddress(#[source] GuestMemoryError),
|
||||||
/// Writing PML4 to RAM failed.
|
/// Writing PML4 to RAM failed.
|
||||||
#[error("Writing PML4 to RAM failed: {0}")]
|
#[error("Writing PML4 to RAM failed: {0}")]
|
||||||
WritePml4Address(GuestMemoryError),
|
WritePml4Address(#[source] GuestMemoryError),
|
||||||
/// Writing PML5 to RAM failed.
|
/// Writing PML5 to RAM failed.
|
||||||
#[error("Writing PML5 to RAM failed: {0}")]
|
#[error("Writing PML5 to RAM failed: {0}")]
|
||||||
WritePml5Address(GuestMemoryError),
|
WritePml5Address(#[source] GuestMemoryError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub enum Error {
|
|||||||
WriteData,
|
WriteData,
|
||||||
/// Failure to parse uuid, uuid format may be error
|
/// Failure to parse uuid, uuid format may be error
|
||||||
#[error("Failure to parse uuid: {0}")]
|
#[error("Failure to parse uuid: {0}")]
|
||||||
ParseUuid(uuid::Error),
|
ParseUuid(#[source] uuid::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const TABLE_FOOTER_GUID: &str = "96b582de-1fb2-45f7-baea-a366c55a082d";
|
|||||||
const TDVF_METADATA_OFFSET_GUID: &str = "e47a6535-984a-4798-865e-4685a7bf8ec2";
|
const TDVF_METADATA_OFFSET_GUID: &str = "e47a6535-984a-4798-865e-4685a7bf8ec2";
|
||||||
|
|
||||||
// TDVF_DESCRIPTOR
|
// TDVF_DESCRIPTOR
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TdvfDescriptor {
|
pub struct TdvfDescriptor {
|
||||||
signature: [u8; 4],
|
signature: [u8; 4],
|
||||||
@@ -45,7 +45,7 @@ pub struct TdvfDescriptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TDVF_SECTION
|
// TDVF_SECTION
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Clone, Copy, Default, Debug)]
|
#[derive(Clone, Copy, Default, Debug)]
|
||||||
pub struct TdvfSection {
|
pub struct TdvfSection {
|
||||||
pub data_offset: u32,
|
pub data_offset: u32,
|
||||||
@@ -209,7 +209,7 @@ enum HobType {
|
|||||||
EndOfHobList = 0xffff,
|
EndOfHobList = 0xffff,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
struct HobHeader {
|
struct HobHeader {
|
||||||
r#type: HobType,
|
r#type: HobType,
|
||||||
@@ -217,7 +217,7 @@ struct HobHeader {
|
|||||||
reserved: u32,
|
reserved: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
struct HobHandoffInfoTable {
|
struct HobHandoffInfoTable {
|
||||||
header: HobHeader,
|
header: HobHeader,
|
||||||
@@ -230,7 +230,7 @@ struct HobHandoffInfoTable {
|
|||||||
efi_end_of_hob_list: u64,
|
efi_end_of_hob_list: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
struct EfiGuid {
|
struct EfiGuid {
|
||||||
data1: u32,
|
data1: u32,
|
||||||
@@ -239,7 +239,7 @@ struct EfiGuid {
|
|||||||
data4: [u8; 8],
|
data4: [u8; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
struct HobResourceDescriptor {
|
struct HobResourceDescriptor {
|
||||||
header: HobHeader,
|
header: HobHeader,
|
||||||
@@ -250,7 +250,7 @@ struct HobResourceDescriptor {
|
|||||||
resource_length: u64,
|
resource_length: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
struct HobGuidType {
|
struct HobGuidType {
|
||||||
header: HobHeader,
|
header: HobHeader,
|
||||||
@@ -266,14 +266,14 @@ pub enum PayloadImageType {
|
|||||||
RawVmLinux,
|
RawVmLinux,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
pub struct PayloadInfo {
|
pub struct PayloadInfo {
|
||||||
pub image_type: PayloadImageType,
|
pub image_type: PayloadImageType,
|
||||||
pub entry_point: u64,
|
pub entry_point: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C, packed)]
|
||||||
#[derive(Copy, Clone, Default, Debug)]
|
#[derive(Copy, Clone, Default, Debug)]
|
||||||
struct TdPayload {
|
struct TdPayload {
|
||||||
guid_type: HobGuidType,
|
guid_type: HobGuidType,
|
||||||
@@ -299,7 +299,7 @@ pub struct TdHob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn align_hob(v: u64) -> u64 {
|
fn align_hob(v: u64) -> u64 {
|
||||||
(v + 7) / 8 * 8
|
v.div_ceil(8) * 8
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TdHob {
|
impl TdHob {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ log = "0.4.22"
|
|||||||
remain = "0.2.14"
|
remain = "0.2.14"
|
||||||
serde = { version = "1.0.208", features = ["derive"] }
|
serde = { version = "1.0.208", features = ["derive"] }
|
||||||
smallvec = "1.13.2"
|
smallvec = "1.13.2"
|
||||||
thiserror = "1.0.62"
|
thiserror = "2.0.6"
|
||||||
uuid = { version = "1.8.0", features = ["v4"] }
|
uuid = { version = "1.12.1", features = ["v4"] }
|
||||||
virtio-bindings = { workspace = true, features = ["virtio-v5_0_0"] }
|
virtio-bindings = { workspace = true, features = ["virtio-v5_0_0"] }
|
||||||
virtio-queue = { workspace = true }
|
virtio-queue = { workspace = true }
|
||||||
vm-memory = { workspace = true, features = [
|
vm-memory = { workspace = true, features = [
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||||
|
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
@@ -19,12 +22,50 @@ pub enum DiskFileError {
|
|||||||
|
|
||||||
pub type DiskFileResult<T> = std::result::Result<T, DiskFileError>;
|
pub type DiskFileResult<T> = std::result::Result<T, DiskFileError>;
|
||||||
|
|
||||||
|
/// A wrapper for [`RawFd`] capturing the lifetime of a corresponding [`DiskFile`].
|
||||||
|
///
|
||||||
|
/// This fulfills the same role as [`BorrowedFd`] but is tailored to the limitations
|
||||||
|
/// by some implementations of [`DiskFile`], which wrap the effective [`File`]
|
||||||
|
/// in an `Arc<Mutex<T>>`, making the use of [`BorrowedFd`] impossible.
|
||||||
|
///
|
||||||
|
/// [`BorrowedFd`]: std::os::fd::BorrowedFd
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
pub struct BorrowedDiskFd<'fd> {
|
||||||
|
raw_fd: RawFd,
|
||||||
|
_lifetime: PhantomData<&'fd OwnedFd>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BorrowedDiskFd<'_> {
|
||||||
|
pub(super) fn new(raw_fd: RawFd) -> Self {
|
||||||
|
Self {
|
||||||
|
raw_fd,
|
||||||
|
_lifetime: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRawFd for BorrowedDiskFd<'_> {
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.raw_fd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Abstraction over the effective [`File`] backing up a block device,
|
||||||
|
/// with support for synchronous and asynchronous I/O.
|
||||||
|
///
|
||||||
|
/// This allows abstracting over raw image formats as well as structured
|
||||||
|
/// image formats.
|
||||||
pub trait DiskFile: Send {
|
pub trait DiskFile: Send {
|
||||||
fn size(&mut self) -> DiskFileResult<u64>;
|
fn size(&mut self) -> DiskFileResult<u64>;
|
||||||
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>>;
|
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>>;
|
||||||
fn topology(&mut self) -> DiskTopology {
|
fn topology(&mut self) -> DiskTopology {
|
||||||
DiskTopology::default()
|
DiskTopology::default()
|
||||||
}
|
}
|
||||||
|
/// Returns the file descriptor of the underlying disk image file.
|
||||||
|
///
|
||||||
|
/// The file descriptor is supposed to be used for `fcntl()` calls but no
|
||||||
|
/// other operation.
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
|||||||
173
block/src/fcntl.rs
Normal file
173
block/src/fcntl.rs
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
// Copyright © 2025 Cyberus Technology GmbH
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
//! Helpers for advisory file locking.
|
||||||
|
//!
|
||||||
|
//! Under the hood, the implementation uses OFD locks for the entire file,
|
||||||
|
//! as described in [[0]]. The advantage over `F_SETLKW` (currently used by
|
||||||
|
//! Rust std: `File::try_lock()`) is that only the very last `close()` on a
|
||||||
|
//! file descriptor releases the lock. This prevents mistakes and unexpected
|
||||||
|
//! behavior.
|
||||||
|
//!
|
||||||
|
//! [0]: <https://apenwarr.ca/log/20101213>.
|
||||||
|
|
||||||
|
use std::fmt::Debug;
|
||||||
|
use std::io;
|
||||||
|
use std::os::fd::{AsRawFd, RawFd};
|
||||||
|
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
/// Errors that can happen when working with file locks.
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum LockError {
|
||||||
|
/// The file is already locked.
|
||||||
|
///
|
||||||
|
/// A call to [`get_lock_state`] can help to identify the reason.
|
||||||
|
#[error("The file is already locked")]
|
||||||
|
AlreadyLocked,
|
||||||
|
/// IO error.
|
||||||
|
#[error("The lock state could not be checked or set: {0}")]
|
||||||
|
Io(#[source] io::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Commands for use with [`fcntl`].
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
enum FcntlArg<'a> {
|
||||||
|
/// Set an OFD lock from the given lock description.
|
||||||
|
F_OFD_SETLK(&'a libc::flock),
|
||||||
|
/// Get the first OFD lock for the given lock description.
|
||||||
|
F_OFD_GETLK(&'a mut libc::flock),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wrapper for [`libc::fcntl`] that properly sets the function arguments.
|
||||||
|
fn fcntl(fd: RawFd, arg: FcntlArg) -> libc::c_int {
|
||||||
|
// SAFETY: We use a valid FD.
|
||||||
|
unsafe {
|
||||||
|
match arg {
|
||||||
|
FcntlArg::F_OFD_SETLK(flock) => libc::fcntl(fd, libc::F_OFD_SETLK, flock),
|
||||||
|
FcntlArg::F_OFD_GETLK(flock) => libc::fcntl(fd, libc::F_OFD_GETLK, flock),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Describes the type of lock you want to set.
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
pub enum LockType {
|
||||||
|
/// Clear a lock.
|
||||||
|
Unlock,
|
||||||
|
/// Set a write lock (exclusive).
|
||||||
|
Write,
|
||||||
|
/// Set a read lock (shared).
|
||||||
|
Read,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LockType {
|
||||||
|
pub const fn to_libc_val(self) -> libc::c_int {
|
||||||
|
match self {
|
||||||
|
Self::Unlock => libc::F_UNLCK as libc::c_int,
|
||||||
|
Self::Write => libc::F_WRLCK as libc::c_int,
|
||||||
|
Self::Read => libc::F_RDLCK as libc::c_int,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Describes the current state of a lock.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum LockState {
|
||||||
|
/// No lock set.
|
||||||
|
Unlocked,
|
||||||
|
/// Locked for reading (non-exclusive).
|
||||||
|
SharedRead,
|
||||||
|
/// Locked for writing (exclusive mode).
|
||||||
|
ExclusiveWrite,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LockState {
|
||||||
|
fn new(value: libc::c_int) -> Self {
|
||||||
|
const F_UNLCK: libc::c_int = libc::F_UNLCK as libc::c_int;
|
||||||
|
const F_WRLCK: libc::c_int = libc::F_WRLCK as libc::c_int;
|
||||||
|
const F_RDLCK: libc::c_int = libc::F_RDLCK as libc::c_int;
|
||||||
|
match value {
|
||||||
|
F_UNLCK => Self::Unlocked,
|
||||||
|
F_WRLCK => Self::ExclusiveWrite,
|
||||||
|
F_RDLCK => Self::SharedRead,
|
||||||
|
// This is so unlikely that we want to avoid the complexity of
|
||||||
|
// coping with this error case. Can only fail if either Linux
|
||||||
|
// is broken or memory is messed up.
|
||||||
|
other => panic!("Unexpected lock state: {other}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a [`struct@libc::flock`] structure for the whole file.
|
||||||
|
const fn get_flock(lock_type: LockType) -> libc::flock {
|
||||||
|
libc::flock {
|
||||||
|
l_type: lock_type.to_libc_val() as libc::c_short,
|
||||||
|
l_whence: libc::SEEK_SET as libc::c_short,
|
||||||
|
l_start: 0,
|
||||||
|
l_len: 0, /* EOF */
|
||||||
|
l_pid: 0, /* filled by callee */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tries to acquire a lock using [`fcntl`] with respect to the given
|
||||||
|
/// parameters.
|
||||||
|
///
|
||||||
|
/// Please note that `fcntl()` OFD locks are **advisory locks**, which do not
|
||||||
|
/// prevent to `open()` a file if a lock is already placed.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
/// - `file`: The file to acquire a lock for [`LockType`]. The file's state will
|
||||||
|
/// be logically mutated, but not technically.
|
||||||
|
/// - `lock_type`: The [`LockType`]
|
||||||
|
pub fn try_acquire_lock<Fd: AsRawFd>(file: Fd, lock_type: LockType) -> Result<(), LockError> {
|
||||||
|
let flock = get_flock(lock_type);
|
||||||
|
|
||||||
|
let res = fcntl(file.as_raw_fd(), FcntlArg::F_OFD_SETLK(&flock));
|
||||||
|
match res {
|
||||||
|
0 => Ok(()),
|
||||||
|
-1 => {
|
||||||
|
let io_error = io::Error::last_os_error();
|
||||||
|
let errno = io_error.raw_os_error().unwrap();
|
||||||
|
match errno {
|
||||||
|
// See man page for error code:
|
||||||
|
// <https://man7.org/linux/man-pages/man2/fcntl.2.html>
|
||||||
|
libc::EAGAIN | libc::EACCES => Err(LockError::AlreadyLocked),
|
||||||
|
_ => Err(LockError::Io(io_error)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val => panic!("Unexpected return value from fcntl(): {val}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clears a lock.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
/// - `file`: The file to clear all locks for [`LockType`].
|
||||||
|
pub fn clear_lock<Fd: AsRawFd>(file: Fd) -> Result<(), LockError> {
|
||||||
|
try_acquire_lock(file, LockType::Unlock)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the current lock state using [`fcntl`] with respect to the given
|
||||||
|
/// parameters.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
/// - `file`: The file for which to get the lock state.
|
||||||
|
pub fn get_lock_state<Fd: AsRawFd>(file: Fd) -> Result<LockState, LockError> {
|
||||||
|
let mut flock = get_flock(LockType::Write);
|
||||||
|
let res = fcntl(file.as_raw_fd(), FcntlArg::F_OFD_GETLK(&mut flock));
|
||||||
|
match res {
|
||||||
|
0 => {
|
||||||
|
let state = flock.l_type as libc::c_int;
|
||||||
|
let state = LockState::new(state);
|
||||||
|
Ok(state)
|
||||||
|
}
|
||||||
|
-1 => {
|
||||||
|
let io_error = io::Error::last_os_error();
|
||||||
|
Err(LockError::Io(io_error))
|
||||||
|
}
|
||||||
|
val => panic!("Unexpected return value from fcntl(): {val}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
|||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{
|
use crate::async_io::{
|
||||||
AsyncIo, AsyncIoError, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult,
|
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
};
|
};
|
||||||
use crate::fixed_vhd::FixedVhd;
|
use crate::fixed_vhd::FixedVhd;
|
||||||
use crate::raw_async::RawFileAsync;
|
use crate::raw_async::RawFileAsync;
|
||||||
@@ -33,6 +33,10 @@ impl DiskFile for FixedVhdDiskAsync {
|
|||||||
.map_err(DiskFileError::NewAsyncIo)?,
|
.map_err(DiskFileError::NewAsyncIo)?,
|
||||||
) as Box<dyn AsyncIo>)
|
) as Box<dyn AsyncIo>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
BorrowedDiskFd::new(self.0.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FixedVhdAsync {
|
pub struct FixedVhdAsync {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
|||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{
|
use crate::async_io::{
|
||||||
AsyncIo, AsyncIoError, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult,
|
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
};
|
};
|
||||||
use crate::fixed_vhd::FixedVhd;
|
use crate::fixed_vhd::FixedVhd;
|
||||||
use crate::raw_sync::RawFileSync;
|
use crate::raw_sync::RawFileSync;
|
||||||
@@ -33,6 +33,10 @@ impl DiskFile for FixedVhdDiskSync {
|
|||||||
.map_err(DiskFileError::NewAsyncIo)?,
|
.map_err(DiskFileError::NewAsyncIo)?,
|
||||||
) as Box<dyn AsyncIo>)
|
) as Box<dyn AsyncIo>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
BorrowedDiskFd::new(self.0.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FixedVhdSync {
|
pub struct FixedVhdSync {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
pub mod async_io;
|
pub mod async_io;
|
||||||
|
pub mod fcntl;
|
||||||
pub mod fixed_vhd;
|
pub mod fixed_vhd;
|
||||||
#[cfg(feature = "io_uring")]
|
#[cfg(feature = "io_uring")]
|
||||||
/// Enabled with the `"io_uring"` feature
|
/// Enabled with the `"io_uring"` feature
|
||||||
@@ -59,9 +60,7 @@ use vmm_sys_util::eventfd::EventFd;
|
|||||||
use vmm_sys_util::{aio, ioctl_io_nr, ioctl_ioc_nr};
|
use vmm_sys_util::{aio, ioctl_io_nr, ioctl_ioc_nr};
|
||||||
|
|
||||||
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult};
|
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult};
|
||||||
use crate::fixed_vhd::FixedVhd;
|
use crate::vhdx::VhdxError;
|
||||||
use crate::qcow::{QcowFile, RawFile};
|
|
||||||
use crate::vhdx::{Vhdx, VhdxError};
|
|
||||||
|
|
||||||
const SECTOR_SHIFT: u8 = 9;
|
const SECTOR_SHIFT: u8 = 9;
|
||||||
pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT;
|
pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT;
|
||||||
@@ -69,9 +68,9 @@ pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT;
|
|||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Guest gave us bad memory addresses")]
|
#[error("Guest gave us bad memory addresses")]
|
||||||
GuestMemory(GuestMemoryError),
|
GuestMemory(#[source] GuestMemoryError),
|
||||||
#[error("Guest gave us offsets that would have overflowed a usize")]
|
#[error("Guest gave us offsets that would have overflowed a usize")]
|
||||||
CheckedOffset(GuestAddress, usize),
|
CheckedOffset(GuestAddress, usize /* sector offset */),
|
||||||
#[error("Guest gave us a write only descriptor that protocol says to read from")]
|
#[error("Guest gave us a write only descriptor that protocol says to read from")]
|
||||||
UnexpectedWriteOnlyDescriptor,
|
UnexpectedWriteOnlyDescriptor,
|
||||||
#[error("Guest gave us a read only descriptor that protocol says to write to")]
|
#[error("Guest gave us a read only descriptor that protocol says to write to")]
|
||||||
@@ -81,21 +80,21 @@ pub enum Error {
|
|||||||
#[error("Guest gave us a descriptor that was too short to use")]
|
#[error("Guest gave us a descriptor that was too short to use")]
|
||||||
DescriptorLengthTooSmall,
|
DescriptorLengthTooSmall,
|
||||||
#[error("Failed to detect image type: {0}")]
|
#[error("Failed to detect image type: {0}")]
|
||||||
DetectImageType(std::io::Error),
|
DetectImageType(#[source] std::io::Error),
|
||||||
#[error("Failure in fixed vhd: {0}")]
|
#[error("Failure in fixed vhd: {0}")]
|
||||||
FixedVhdError(std::io::Error),
|
FixedVhdError(#[source] std::io::Error),
|
||||||
#[error("Getting a block's metadata fails for any reason")]
|
#[error("Getting a block's metadata fails for any reason")]
|
||||||
GetFileMetadata,
|
GetFileMetadata,
|
||||||
#[error("The requested operation would cause a seek beyond disk end")]
|
#[error("The requested operation would cause a seek beyond disk end")]
|
||||||
InvalidOffset,
|
InvalidOffset,
|
||||||
#[error("Failure in qcow: {0}")]
|
#[error("Failure in qcow: {0}")]
|
||||||
QcowError(qcow::Error),
|
QcowError(#[source] qcow::Error),
|
||||||
#[error("Failure in raw file: {0}")]
|
#[error("Failure in raw file: {0}")]
|
||||||
RawFileError(std::io::Error),
|
RawFileError(#[source] std::io::Error),
|
||||||
#[error("The requested operation does not support multiple descriptors")]
|
#[error("The requested operation does not support multiple descriptors")]
|
||||||
TooManyDescriptors,
|
TooManyDescriptors,
|
||||||
#[error("Failure in vhdx: {0}")]
|
#[error("Failure in vhdx: {0}")]
|
||||||
VhdxError(VhdxError),
|
VhdxError(#[source] VhdxError),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_device_id(disk_path: &Path) -> result::Result<String, Error> {
|
fn build_device_id(disk_path: &Path) -> result::Result<String, Error> {
|
||||||
@@ -133,33 +132,33 @@ pub fn build_serial(disk_path: &Path) -> Vec<u8> {
|
|||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ExecuteError {
|
pub enum ExecuteError {
|
||||||
#[error("Bad request: {0}")]
|
#[error("Bad request: {0}")]
|
||||||
BadRequest(Error),
|
BadRequest(#[source] Error),
|
||||||
#[error("Failed to flush: {0}")]
|
#[error("Failed to flush: {0}")]
|
||||||
Flush(io::Error),
|
Flush(#[source] io::Error),
|
||||||
#[error("Failed to read: {0}")]
|
#[error("Failed to read: {0}")]
|
||||||
Read(GuestMemoryError),
|
Read(#[source] GuestMemoryError),
|
||||||
#[error("Failed to read_exact: {0}")]
|
#[error("Failed to read_exact: {0}")]
|
||||||
ReadExact(io::Error),
|
ReadExact(#[source] io::Error),
|
||||||
#[error("Failed to seek: {0}")]
|
#[error("Failed to seek: {0}")]
|
||||||
Seek(io::Error),
|
Seek(#[source] io::Error),
|
||||||
#[error("Failed to write: {0}")]
|
#[error("Failed to write: {0}")]
|
||||||
Write(GuestMemoryError),
|
Write(#[source] GuestMemoryError),
|
||||||
#[error("Failed to write_all: {0}")]
|
#[error("Failed to write_all: {0}")]
|
||||||
WriteAll(io::Error),
|
WriteAll(#[source] io::Error),
|
||||||
#[error("Unsupported request: {0}")]
|
#[error("Unsupported request: {0}")]
|
||||||
Unsupported(u32),
|
Unsupported(u32),
|
||||||
#[error("Failed to submit io uring: {0}")]
|
#[error("Failed to submit io uring: {0}")]
|
||||||
SubmitIoUring(io::Error),
|
SubmitIoUring(#[source] io::Error),
|
||||||
#[error("Failed to get guest address: {0}")]
|
#[error("Failed to get guest address: {0}")]
|
||||||
GetHostAddress(GuestMemoryError),
|
GetHostAddress(#[source] GuestMemoryError),
|
||||||
#[error("Failed to async read: {0}")]
|
#[error("Failed to async read: {0}")]
|
||||||
AsyncRead(AsyncIoError),
|
AsyncRead(#[source] AsyncIoError),
|
||||||
#[error("Failed to async write: {0}")]
|
#[error("Failed to async write: {0}")]
|
||||||
AsyncWrite(AsyncIoError),
|
AsyncWrite(#[source] AsyncIoError),
|
||||||
#[error("failed to async flush: {0}")]
|
#[error("failed to async flush: {0}")]
|
||||||
AsyncFlush(AsyncIoError),
|
AsyncFlush(#[source] AsyncIoError),
|
||||||
#[error("Failed allocating a temporary buffer: {0}")]
|
#[error("Failed allocating a temporary buffer: {0}")]
|
||||||
TemporaryBufferAllocation(io::Error),
|
TemporaryBufferAllocation(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExecuteError {
|
impl ExecuteError {
|
||||||
@@ -220,6 +219,8 @@ fn sector<B: Bitmap + 'static>(
|
|||||||
mem.read_obj(addr).map_err(Error::GuestMemory)
|
mem.read_obj(addr).map_err(Error::GuestMemory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_DESCRIPTOR_VEC_SIZE: usize = 32;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AlignedOperation {
|
pub struct AlignedOperation {
|
||||||
origin_ptr: u64,
|
origin_ptr: u64,
|
||||||
@@ -232,10 +233,10 @@ pub struct AlignedOperation {
|
|||||||
pub struct Request {
|
pub struct Request {
|
||||||
pub request_type: RequestType,
|
pub request_type: RequestType,
|
||||||
pub sector: u64,
|
pub sector: u64,
|
||||||
pub data_descriptors: SmallVec<[(GuestAddress, u32); 1]>,
|
pub data_descriptors: SmallVec<[(GuestAddress, u32); DEFAULT_DESCRIPTOR_VEC_SIZE]>,
|
||||||
pub status_addr: GuestAddress,
|
pub status_addr: GuestAddress,
|
||||||
pub writeback: bool,
|
pub writeback: bool,
|
||||||
pub aligned_operations: SmallVec<[AlignedOperation; 1]>,
|
pub aligned_operations: SmallVec<[AlignedOperation; DEFAULT_DESCRIPTOR_VEC_SIZE]>,
|
||||||
pub start: Instant,
|
pub start: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,10 +264,10 @@ impl Request {
|
|||||||
let mut req = Request {
|
let mut req = Request {
|
||||||
request_type: request_type(desc_chain.memory(), hdr_desc_addr)?,
|
request_type: request_type(desc_chain.memory(), hdr_desc_addr)?,
|
||||||
sector: sector(desc_chain.memory(), hdr_desc_addr)?,
|
sector: sector(desc_chain.memory(), hdr_desc_addr)?,
|
||||||
data_descriptors: SmallVec::with_capacity(1),
|
data_descriptors: SmallVec::with_capacity(DEFAULT_DESCRIPTOR_VEC_SIZE),
|
||||||
status_addr: GuestAddress(0),
|
status_addr: GuestAddress(0),
|
||||||
writeback: true,
|
writeback: true,
|
||||||
aligned_operations: SmallVec::with_capacity(1),
|
aligned_operations: SmallVec::with_capacity(DEFAULT_DESCRIPTOR_VEC_SIZE),
|
||||||
start: Instant::now(),
|
start: Instant::now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -398,7 +399,7 @@ impl Request {
|
|||||||
let request_type = self.request_type;
|
let request_type = self.request_type;
|
||||||
let offset = (sector << SECTOR_SHIFT) as libc::off_t;
|
let offset = (sector << SECTOR_SHIFT) as libc::off_t;
|
||||||
|
|
||||||
let mut iovecs: SmallVec<[libc::iovec; 1]> =
|
let mut iovecs: SmallVec<[libc::iovec; DEFAULT_DESCRIPTOR_VEC_SIZE]> =
|
||||||
SmallVec::with_capacity(self.data_descriptors.len());
|
SmallVec::with_capacity(self.data_descriptors.len());
|
||||||
for (data_addr, data_len) in &self.data_descriptors {
|
for (data_addr, data_len) in &self.data_descriptors {
|
||||||
if *data_len == 0 {
|
if *data_len == 0 {
|
||||||
@@ -653,7 +654,8 @@ where
|
|||||||
completion_list: &mut VecDeque<(u64, i32)>,
|
completion_list: &mut VecDeque<(u64, i32)>,
|
||||||
) -> AsyncIoResult<()> {
|
) -> AsyncIoResult<()> {
|
||||||
// Convert libc::iovec into IoSliceMut
|
// Convert libc::iovec into IoSliceMut
|
||||||
let mut slices: SmallVec<[IoSliceMut; 1]> = SmallVec::with_capacity(iovecs.len());
|
let mut slices: SmallVec<[IoSliceMut; DEFAULT_DESCRIPTOR_VEC_SIZE]> =
|
||||||
|
SmallVec::with_capacity(iovecs.len());
|
||||||
for iovec in iovecs.iter() {
|
for iovec in iovecs.iter() {
|
||||||
// SAFETY: on Linux IoSliceMut wraps around libc::iovec
|
// SAFETY: on Linux IoSliceMut wraps around libc::iovec
|
||||||
slices.push(IoSliceMut::new(unsafe {
|
slices.push(IoSliceMut::new(unsafe {
|
||||||
@@ -668,9 +670,11 @@ where
|
|||||||
file.seek(SeekFrom::Start(offset as u64))
|
file.seek(SeekFrom::Start(offset as u64))
|
||||||
.map_err(AsyncIoError::ReadVectored)?;
|
.map_err(AsyncIoError::ReadVectored)?;
|
||||||
|
|
||||||
// Read vectored
|
let mut r = 0;
|
||||||
file.read_vectored(slices.as_mut_slice())
|
for b in slices.iter_mut() {
|
||||||
.map_err(AsyncIoError::ReadVectored)?
|
r += file.read(b).map_err(AsyncIoError::ReadVectored)?;
|
||||||
|
}
|
||||||
|
r
|
||||||
};
|
};
|
||||||
|
|
||||||
completion_list.push_back((user_data, result as i32));
|
completion_list.push_back((user_data, result as i32));
|
||||||
@@ -688,7 +692,8 @@ where
|
|||||||
completion_list: &mut VecDeque<(u64, i32)>,
|
completion_list: &mut VecDeque<(u64, i32)>,
|
||||||
) -> AsyncIoResult<()> {
|
) -> AsyncIoResult<()> {
|
||||||
// Convert libc::iovec into IoSlice
|
// Convert libc::iovec into IoSlice
|
||||||
let mut slices: SmallVec<[IoSlice; 1]> = SmallVec::with_capacity(iovecs.len());
|
let mut slices: SmallVec<[IoSlice; DEFAULT_DESCRIPTOR_VEC_SIZE]> =
|
||||||
|
SmallVec::with_capacity(iovecs.len());
|
||||||
for iovec in iovecs.iter() {
|
for iovec in iovecs.iter() {
|
||||||
// SAFETY: on Linux IoSlice wraps around libc::iovec
|
// SAFETY: on Linux IoSlice wraps around libc::iovec
|
||||||
slices.push(IoSlice::new(unsafe {
|
slices.push(IoSlice::new(unsafe {
|
||||||
@@ -703,9 +708,11 @@ where
|
|||||||
file.seek(SeekFrom::Start(offset as u64))
|
file.seek(SeekFrom::Start(offset as u64))
|
||||||
.map_err(AsyncIoError::WriteVectored)?;
|
.map_err(AsyncIoError::WriteVectored)?;
|
||||||
|
|
||||||
// Write vectored
|
let mut r = 0;
|
||||||
file.write_vectored(slices.as_slice())
|
for b in slices.iter() {
|
||||||
.map_err(AsyncIoError::WriteVectored)?
|
r += file.write(b).map_err(AsyncIoError::WriteVectored)?;
|
||||||
|
}
|
||||||
|
r
|
||||||
};
|
};
|
||||||
|
|
||||||
completion_list.push_back((user_data, result as i32));
|
completion_list.push_back((user_data, result as i32));
|
||||||
@@ -789,25 +796,6 @@ pub trait BlockBackend: Read + Write + Seek + Send + Debug {
|
|||||||
fn size(&self) -> Result<u64, Error>;
|
fn size(&self) -> Result<u64, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inspect the image file type and create an appropriate disk file to match it.
|
|
||||||
pub fn create_disk_file(mut file: File, direct_io: bool) -> Result<Box<dyn BlockBackend>, Error> {
|
|
||||||
let image_type = detect_image_type(&mut file).map_err(Error::DetectImageType)?;
|
|
||||||
|
|
||||||
Ok(match image_type {
|
|
||||||
ImageType::Qcow2 => {
|
|
||||||
Box::new(QcowFile::from(RawFile::new(file, direct_io)).map_err(Error::QcowError)?)
|
|
||||||
as Box<dyn BlockBackend>
|
|
||||||
}
|
|
||||||
ImageType::FixedVhd => {
|
|
||||||
Box::new(FixedVhd::new(file).map_err(Error::FixedVhdError)?) as Box<dyn BlockBackend>
|
|
||||||
}
|
|
||||||
ImageType::Vhdx => {
|
|
||||||
Box::new(Vhdx::new(file).map_err(Error::VhdxError)?) as Box<dyn BlockBackend>
|
|
||||||
}
|
|
||||||
ImageType::Raw => Box::new(RawFile::new(file, direct_io)) as Box<dyn BlockBackend>,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DiskTopology {
|
pub struct DiskTopology {
|
||||||
pub logical_block_size: u64,
|
pub logical_block_size: u64,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use std::cmp::{max, min};
|
|||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::{self, Read, Seek, SeekFrom, Write};
|
use std::io::{self, Read, Seek, SeekFrom, Write};
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
use std::os::fd::{AsRawFd, RawFd};
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
@@ -36,23 +37,23 @@ const MAX_NESTING_DEPTH: u32 = 10;
|
|||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Backing file io error: {0}")]
|
#[error("Backing file io error: {0}")]
|
||||||
BackingFileIo(io::Error),
|
BackingFileIo(#[source] io::Error),
|
||||||
#[error("Backing file open error: {0}")]
|
#[error("Backing file open error: {0}")]
|
||||||
BackingFileOpen(Box<Error>),
|
BackingFileOpen(#[source] Box<Error>),
|
||||||
#[error("Backing file name is too long: {0} bytes over")]
|
#[error("Backing file name is too long: {0} bytes over")]
|
||||||
BackingFileTooLong(usize),
|
BackingFileTooLong(usize),
|
||||||
#[error("Compressed blocks not supported")]
|
#[error("Compressed blocks not supported")]
|
||||||
CompressedBlocksNotSupported,
|
CompressedBlocksNotSupported,
|
||||||
#[error("Failed to evict cache: {0}")]
|
#[error("Failed to evict cache: {0}")]
|
||||||
EvictingCache(io::Error),
|
EvictingCache(#[source] io::Error),
|
||||||
#[error("File larger than max of {}: {0}", MAX_QCOW_FILE_SIZE)]
|
#[error("File larger than max of {MAX_QCOW_FILE_SIZE}: {0}")]
|
||||||
FileTooBig(u64),
|
FileTooBig(u64),
|
||||||
#[error("Failed to get file size: {0}")]
|
#[error("Failed to get file size: {0}")]
|
||||||
GettingFileSize(io::Error),
|
GettingFileSize(#[source] io::Error),
|
||||||
#[error("Failed to get refcount: {0}")]
|
#[error("Failed to get refcount: {0}")]
|
||||||
GettingRefcount(refcount::Error),
|
GettingRefcount(#[source] refcount::Error),
|
||||||
#[error("Failed to parse filename: {0}")]
|
#[error("Failed to parse filename: {0}")]
|
||||||
InvalidBackingFileName(str::Utf8Error),
|
InvalidBackingFileName(#[source] str::Utf8Error),
|
||||||
#[error("Invalid cluster index")]
|
#[error("Invalid cluster index")]
|
||||||
InvalidClusterIndex,
|
InvalidClusterIndex,
|
||||||
#[error("Invalid cluster size")]
|
#[error("Invalid cluster size")]
|
||||||
@@ -80,29 +81,29 @@ pub enum Error {
|
|||||||
#[error("Not enough space for refcounts")]
|
#[error("Not enough space for refcounts")]
|
||||||
NotEnoughSpaceForRefcounts,
|
NotEnoughSpaceForRefcounts,
|
||||||
#[error("Failed to open file {0}")]
|
#[error("Failed to open file {0}")]
|
||||||
OpeningFile(io::Error),
|
OpeningFile(#[source] io::Error),
|
||||||
#[error("Failed to read data: {0}")]
|
#[error("Failed to read data: {0}")]
|
||||||
ReadingData(io::Error),
|
ReadingData(#[source] io::Error),
|
||||||
#[error("Failed to read header: {0}")]
|
#[error("Failed to read header: {0}")]
|
||||||
ReadingHeader(io::Error),
|
ReadingHeader(#[source] io::Error),
|
||||||
#[error("Failed to read pointers: {0}")]
|
#[error("Failed to read pointers: {0}")]
|
||||||
ReadingPointers(io::Error),
|
ReadingPointers(#[source] io::Error),
|
||||||
#[error("Failed to read ref count block: {0}")]
|
#[error("Failed to read ref count block: {0}")]
|
||||||
ReadingRefCountBlock(refcount::Error),
|
ReadingRefCountBlock(#[source] refcount::Error),
|
||||||
#[error("Failed to read ref counts: {0}")]
|
#[error("Failed to read ref counts: {0}")]
|
||||||
ReadingRefCounts(io::Error),
|
ReadingRefCounts(#[source] io::Error),
|
||||||
#[error("Failed to rebuild ref counts: {0}")]
|
#[error("Failed to rebuild ref counts: {0}")]
|
||||||
RebuildingRefCounts(io::Error),
|
RebuildingRefCounts(#[source] io::Error),
|
||||||
#[error("Refcount table offset past file end")]
|
#[error("Refcount table offset past file end")]
|
||||||
RefcountTableOffEnd,
|
RefcountTableOffEnd,
|
||||||
#[error("Too many clusters specified for refcount")]
|
#[error("Too many clusters specified for refcount")]
|
||||||
RefcountTableTooLarge,
|
RefcountTableTooLarge,
|
||||||
#[error("Failed to seek file: {0}")]
|
#[error("Failed to seek file: {0}")]
|
||||||
SeekingFile(io::Error),
|
SeekingFile(#[source] io::Error),
|
||||||
#[error("Failed to set file size: {0}")]
|
#[error("Failed to set file size: {0}")]
|
||||||
SettingFileSize(io::Error),
|
SettingFileSize(#[source] io::Error),
|
||||||
#[error("Failed to set refcount refcount: {0}")]
|
#[error("Failed to set refcount refcount: {0}")]
|
||||||
SettingRefcountRefcount(io::Error),
|
SettingRefcountRefcount(#[source] io::Error),
|
||||||
#[error("Size too small for number of clusters")]
|
#[error("Size too small for number of clusters")]
|
||||||
SizeTooSmallForNumberOfClusters,
|
SizeTooSmallForNumberOfClusters,
|
||||||
#[error("L1 entry table too large: {0}")]
|
#[error("L1 entry table too large: {0}")]
|
||||||
@@ -114,9 +115,9 @@ pub enum Error {
|
|||||||
#[error("Unsupported version: {0}")]
|
#[error("Unsupported version: {0}")]
|
||||||
UnsupportedVersion(u32),
|
UnsupportedVersion(u32),
|
||||||
#[error("Failed to write data: {0}")]
|
#[error("Failed to write data: {0}")]
|
||||||
WritingData(io::Error),
|
WritingData(#[source] io::Error),
|
||||||
#[error("Failed to write header: {0}")]
|
#[error("Failed to write header: {0}")]
|
||||||
WritingHeader(io::Error),
|
WritingHeader(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
@@ -378,7 +379,7 @@ impl QcowHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(backing_file_path) = self.backing_file_path.as_ref() {
|
if let Some(backing_file_path) = self.backing_file_path.as_ref() {
|
||||||
write!(file, "{}", backing_file_path).map_err(Error::WritingHeader)?;
|
write!(file, "{backing_file_path}").map_err(Error::WritingHeader)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the file length by seeking and writing a zero to the last byte. This avoids needing
|
// Set the file length by seeking and writing a zero to the last byte. This avoids needing
|
||||||
@@ -502,7 +503,7 @@ impl QcowFile {
|
|||||||
if refcount_bits != 16 {
|
if refcount_bits != 16 {
|
||||||
return Err(Error::UnsupportedRefcountOrder);
|
return Err(Error::UnsupportedRefcountOrder);
|
||||||
}
|
}
|
||||||
let refcount_bytes = (refcount_bits + 7) / 8;
|
let refcount_bytes = refcount_bits.div_ceil(8);
|
||||||
|
|
||||||
// Need at least one refcount cluster
|
// Need at least one refcount cluster
|
||||||
if header.refcount_table_clusters == 0 {
|
if header.refcount_table_clusters == 0 {
|
||||||
@@ -1516,6 +1517,12 @@ impl QcowFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRawFd for QcowFile {
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.raw_file.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for QcowFile {
|
impl Drop for QcowFile {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let _ = self.sync_caches();
|
let _ = self.sync_caches();
|
||||||
@@ -1625,8 +1632,7 @@ impl FileSync for QcowFile {
|
|||||||
|
|
||||||
impl FileSetLen for QcowFile {
|
impl FileSetLen for QcowFile {
|
||||||
fn set_len(&self, _len: u64) -> std::io::Result<()> {
|
fn set_len(&self, _len: u64) -> std::io::Result<()> {
|
||||||
Err(std::io::Error::new(
|
Err(std::io::Error::other(
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
"set_len() not supported for QcowFile",
|
"set_len() not supported for QcowFile",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
use std::io::{self, BufWriter, Seek, SeekFrom, Write};
|
use std::io::{self, BufWriter, Seek, SeekFrom, Write};
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
use std::os::fd::{AsRawFd, RawFd};
|
||||||
|
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use vmm_sys_util::write_zeroes::WriteZeroes;
|
use vmm_sys_util::write_zeroes::WriteZeroes;
|
||||||
@@ -159,3 +160,9 @@ impl Clone for QcowRawFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRawFd for QcowRawFile {
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.file.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -369,3 +369,9 @@ impl Clone for RawFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRawFd for RawFile {
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.file.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache};
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// `EvictingCache` - Error writing a refblock from the cache to disk.
|
/// `EvictingCache` - Error writing a refblock from the cache to disk.
|
||||||
#[error("Failed to write a refblock from the cache to disk: {0}")]
|
#[error("Failed to write a refblock from the cache to disk: {0}")]
|
||||||
EvictingRefCounts(io::Error),
|
EvictingRefCounts(#[source] io::Error),
|
||||||
/// `InvalidIndex` - Address requested isn't within the range of the disk.
|
/// `InvalidIndex` - Address requested isn't within the range of the disk.
|
||||||
#[error("Address requested is not within the range of the disk")]
|
#[error("Address requested is not within the range of the disk")]
|
||||||
InvalidIndex,
|
InvalidIndex,
|
||||||
@@ -28,7 +28,7 @@ pub enum Error {
|
|||||||
NeedNewCluster,
|
NeedNewCluster,
|
||||||
/// `ReadingRefCounts` - Error reading the file into the refcount cache.
|
/// `ReadingRefCounts` - Error reading the file into the refcount cache.
|
||||||
#[error("Failed to read the file into the refcount cache: {0}")]
|
#[error("Failed to read the file into the refcount cache: {0}")]
|
||||||
ReadingRefCounts(io::Error),
|
ReadingRefCounts(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|||||||
@@ -5,11 +5,14 @@
|
|||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Seek, SeekFrom};
|
use std::io::{Seek, SeekFrom};
|
||||||
|
use std::os::fd::AsRawFd;
|
||||||
use std::sync::{Arc, Mutex, MutexGuard};
|
use std::sync::{Arc, Mutex, MutexGuard};
|
||||||
|
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{AsyncIo, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult};
|
use crate::async_io::{
|
||||||
|
AsyncIo, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
|
};
|
||||||
use crate::qcow::{QcowFile, RawFile, Result as QcowResult};
|
use crate::qcow::{QcowFile, RawFile, Result as QcowResult};
|
||||||
use crate::AsyncAdaptor;
|
use crate::AsyncAdaptor;
|
||||||
|
|
||||||
@@ -35,6 +38,11 @@ impl DiskFile for QcowDiskSync {
|
|||||||
fn new_async_io(&self, _ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
fn new_async_io(&self, _ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
||||||
Ok(Box::new(QcowSync::new(self.qcow_file.clone())) as Box<dyn AsyncIo>)
|
Ok(Box::new(QcowSync::new(self.qcow_file.clone())) as Box<dyn AsyncIo>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
let lock = self.qcow_file.lock().unwrap();
|
||||||
|
BorrowedDiskFd::new(lock.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct QcowSync {
|
pub struct QcowSync {
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Seek, SeekFrom};
|
use std::io::{Error, Seek, SeekFrom};
|
||||||
use std::os::unix::io::{AsRawFd, RawFd};
|
use std::os::unix::io::{AsRawFd, RawFd};
|
||||||
|
|
||||||
use io_uring::{opcode, squeue, types, IoUring};
|
use io_uring::{opcode, types, IoUring};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{
|
use crate::async_io::{
|
||||||
AsyncIo, AsyncIoError, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult,
|
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
};
|
};
|
||||||
use crate::DiskTopology;
|
use crate::DiskTopology;
|
||||||
|
|
||||||
@@ -46,6 +46,10 @@ impl DiskFile for RawFileDisk {
|
|||||||
DiskTopology::default()
|
DiskTopology::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
BorrowedDiskFd::new(self.file.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RawFileAsync {
|
pub struct RawFileAsync {
|
||||||
@@ -86,14 +90,14 @@ impl AsyncIo for RawFileAsync {
|
|||||||
|
|
||||||
// SAFETY: we know the file descriptor is valid and we
|
// SAFETY: we know the file descriptor is valid and we
|
||||||
// relied on vm-memory to provide the buffer address.
|
// relied on vm-memory to provide the buffer address.
|
||||||
let _ = unsafe {
|
unsafe {
|
||||||
sq.push(
|
sq.push(
|
||||||
&opcode::Readv::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32)
|
&opcode::Readv::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32)
|
||||||
.offset(offset.try_into().unwrap())
|
.offset(offset.try_into().unwrap())
|
||||||
.build()
|
.build()
|
||||||
.flags(squeue::Flags::ASYNC)
|
|
||||||
.user_data(user_data),
|
.user_data(user_data),
|
||||||
)
|
)
|
||||||
|
.map_err(|_| AsyncIoError::ReadVectored(Error::other("Submission queue is full")))?
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the submission queue and submit new operations to the
|
// Update the submission queue and submit new operations to the
|
||||||
@@ -114,14 +118,14 @@ impl AsyncIo for RawFileAsync {
|
|||||||
|
|
||||||
// SAFETY: we know the file descriptor is valid and we
|
// SAFETY: we know the file descriptor is valid and we
|
||||||
// relied on vm-memory to provide the buffer address.
|
// relied on vm-memory to provide the buffer address.
|
||||||
let _ = unsafe {
|
unsafe {
|
||||||
sq.push(
|
sq.push(
|
||||||
&opcode::Writev::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32)
|
&opcode::Writev::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32)
|
||||||
.offset(offset.try_into().unwrap())
|
.offset(offset.try_into().unwrap())
|
||||||
.build()
|
.build()
|
||||||
.flags(squeue::Flags::ASYNC)
|
|
||||||
.user_data(user_data),
|
.user_data(user_data),
|
||||||
)
|
)
|
||||||
|
.map_err(|_| AsyncIoError::WriteVectored(Error::other("Submission queue is full")))?
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the submission queue and submit new operations to the
|
// Update the submission queue and submit new operations to the
|
||||||
@@ -137,13 +141,13 @@ impl AsyncIo for RawFileAsync {
|
|||||||
let (submitter, mut sq, _) = self.io_uring.split();
|
let (submitter, mut sq, _) = self.io_uring.split();
|
||||||
|
|
||||||
// SAFETY: we know the file descriptor is valid.
|
// SAFETY: we know the file descriptor is valid.
|
||||||
let _ = unsafe {
|
unsafe {
|
||||||
sq.push(
|
sq.push(
|
||||||
&opcode::Fsync::new(types::Fd(self.fd))
|
&opcode::Fsync::new(types::Fd(self.fd))
|
||||||
.build()
|
.build()
|
||||||
.flags(squeue::Flags::ASYNC)
|
|
||||||
.user_data(user_data),
|
.user_data(user_data),
|
||||||
)
|
)
|
||||||
|
.map_err(|_| AsyncIoError::Fsync(Error::other("Submission queue is full")))?
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the submission queue and submit new operations to the
|
// Update the submission queue and submit new operations to the
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use vmm_sys_util::aio;
|
|||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{
|
use crate::async_io::{
|
||||||
AsyncIo, AsyncIoError, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult,
|
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
};
|
};
|
||||||
use crate::DiskTopology;
|
use crate::DiskTopology;
|
||||||
|
|
||||||
@@ -49,6 +49,10 @@ impl DiskFile for RawFileDiskAio {
|
|||||||
DiskTopology::default()
|
DiskTopology::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
BorrowedDiskFd::new(self.file.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RawFileAsyncAio {
|
pub struct RawFileAsyncAio {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
|||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{
|
use crate::async_io::{
|
||||||
AsyncIo, AsyncIoError, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult,
|
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
};
|
};
|
||||||
use crate::DiskTopology;
|
use crate::DiskTopology;
|
||||||
|
|
||||||
@@ -43,6 +43,10 @@ impl DiskFile for RawFileDiskSync {
|
|||||||
DiskTopology::default()
|
DiskTopology::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
BorrowedDiskFd::new(self.file.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RawFileSync {
|
pub struct RawFileSync {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use std::collections::btree_map::BTreeMap;
|
use std::collections::btree_map::BTreeMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
|
use std::os::fd::{AsRawFd, RawFd};
|
||||||
|
|
||||||
use byteorder::{BigEndian, ByteOrder};
|
use byteorder::{BigEndian, ByteOrder};
|
||||||
use remain::sorted;
|
use remain::sorted;
|
||||||
@@ -25,19 +26,19 @@ mod vhdx_metadata;
|
|||||||
#[sorted]
|
#[sorted]
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum VhdxError {
|
pub enum VhdxError {
|
||||||
#[error("Not a VHDx file {0}")]
|
#[error("Not a VHDx file: {0}")]
|
||||||
NotVhdx(#[source] VhdxHeaderError),
|
NotVhdx(#[source] VhdxHeaderError),
|
||||||
#[error("Failed to parse VHDx header {0}")]
|
#[error("Failed to parse VHDx header: {0}")]
|
||||||
ParseVhdxHeader(#[source] VhdxHeaderError),
|
ParseVhdxHeader(#[source] VhdxHeaderError),
|
||||||
#[error("Failed to parse VHDx metadata {0}")]
|
#[error("Failed to parse VHDx metadata: {0}")]
|
||||||
ParseVhdxMetadata(#[source] VhdxMetadataError),
|
ParseVhdxMetadata(#[source] VhdxMetadataError),
|
||||||
#[error("Failed to parse VHDx region entries {0}")]
|
#[error("Failed to parse VHDx region entries: {0}")]
|
||||||
ParseVhdxRegionEntry(#[source] VhdxHeaderError),
|
ParseVhdxRegionEntry(#[source] VhdxHeaderError),
|
||||||
#[error("Failed reading metadata {0}")]
|
#[error("Failed reading metadata: {0}")]
|
||||||
ReadBatEntry(#[source] VhdxBatError),
|
ReadBatEntry(#[source] VhdxBatError),
|
||||||
#[error("Failed reading sector from disk {0}")]
|
#[error("Failed reading sector from disk: {0}")]
|
||||||
ReadFailed(#[source] VhdxIoError),
|
ReadFailed(#[source] VhdxIoError),
|
||||||
#[error("Failed writing to sector on disk {0}")]
|
#[error("Failed writing to sector on disk: {0}")]
|
||||||
WriteFailed(#[source] VhdxIoError),
|
WriteFailed(#[source] VhdxIoError),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ impl Read for Vhdx {
|
|||||||
let sector_count = (buf.len() as u64).div_ceil(self.disk_spec.logical_sector_size as u64);
|
let sector_count = (buf.len() as u64).div_ceil(self.disk_spec.logical_sector_size as u64);
|
||||||
let sector_index = self.current_offset / self.disk_spec.logical_sector_size as u64;
|
let sector_index = self.current_offset / self.disk_spec.logical_sector_size as u64;
|
||||||
|
|
||||||
vhdx_io::read(
|
let result = vhdx_io::read(
|
||||||
&mut self.file,
|
&mut self.file,
|
||||||
buf,
|
buf,
|
||||||
&self.disk_spec,
|
&self.disk_spec,
|
||||||
@@ -111,13 +112,14 @@ impl Read for Vhdx {
|
|||||||
sector_count,
|
sector_count,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
std::io::Error::new(
|
std::io::Error::other(format!(
|
||||||
std::io::ErrorKind::Other,
|
"Failed reading {sector_count} sectors from VHDx at index {sector_index}: {e}"
|
||||||
format!(
|
))
|
||||||
"Failed reading {sector_count} sectors from VHDx at index {sector_index}: {e}"
|
})?;
|
||||||
),
|
|
||||||
)
|
self.current_offset = self.current_offset.checked_add(result as u64).unwrap();
|
||||||
})
|
|
||||||
|
Ok(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,15 +136,12 @@ impl Write for Vhdx {
|
|||||||
|
|
||||||
if self.first_write {
|
if self.first_write {
|
||||||
self.first_write = false;
|
self.first_write = false;
|
||||||
self.vhdx_header.update(&mut self.file).map_err(|e| {
|
self.vhdx_header
|
||||||
std::io::Error::new(
|
.update(&mut self.file)
|
||||||
std::io::ErrorKind::Other,
|
.map_err(|e| std::io::Error::other(format!("Failed to update VHDx header: {e}")))?;
|
||||||
format!("Failed to update VHDx header: {e}"),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vhdx_io::write(
|
let result = vhdx_io::write(
|
||||||
&mut self.file,
|
&mut self.file,
|
||||||
buf,
|
buf,
|
||||||
&mut self.disk_spec,
|
&mut self.disk_spec,
|
||||||
@@ -152,13 +151,14 @@ impl Write for Vhdx {
|
|||||||
sector_count,
|
sector_count,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
std::io::Error::new(
|
std::io::Error::other(format!(
|
||||||
std::io::ErrorKind::Other,
|
"Failed writing {sector_count} sectors on VHDx at index {sector_index}: {e}"
|
||||||
format!(
|
))
|
||||||
"Failed writing {sector_count} sectors on VHDx at index {sector_index}: {e}"
|
})?;
|
||||||
),
|
|
||||||
)
|
self.current_offset = self.current_offset.checked_add(result as u64).unwrap();
|
||||||
})
|
|
||||||
|
Ok(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,6 +223,12 @@ impl Clone for Vhdx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRawFd for Vhdx {
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.file.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn uuid_from_guid(buf: &[u8]) -> Uuid {
|
pub(crate) fn uuid_from_guid(buf: &[u8]) -> Uuid {
|
||||||
// The first 3 fields of UUID are stored in Big Endian format, and
|
// The first 3 fields of UUID are stored in Big Endian format, and
|
||||||
// the last 8 bytes are stored as byte array. Therefore, we read the
|
// the last 8 bytes are stored as byte array. Therefore, we read the
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ pub enum VhdxBatError {
|
|||||||
InvalidBatEntry,
|
InvalidBatEntry,
|
||||||
#[error("Invalid BAT entry count")]
|
#[error("Invalid BAT entry count")]
|
||||||
InvalidEntryCount,
|
InvalidEntryCount,
|
||||||
#[error("Failed to read BAT entry {0}")]
|
#[error("Failed to read BAT entry: {0}")]
|
||||||
ReadBat(#[source] io::Error),
|
ReadBat(#[source] io::Error),
|
||||||
#[error("Failed to write BAT entry {0}")]
|
#[error("Failed to write BAT entry: {0}")]
|
||||||
WriteBat(#[source] io::Error),
|
WriteBat(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl FileTypeIdentifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
pub signature: u32,
|
pub signature: u32,
|
||||||
@@ -142,7 +142,7 @@ impl Header {
|
|||||||
return Err(VhdxHeaderError::InvalidHeaderSign);
|
return Err(VhdxHeaderError::InvalidHeaderSign);
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_checksum = calculate_checksum(&mut buffer, size_of::<u32>())?;
|
let new_checksum = calculate_checksum(&mut buffer, size_of::<u32>());
|
||||||
if header.checksum != new_checksum {
|
if header.checksum != new_checksum {
|
||||||
return Err(VhdxHeaderError::InvalidChecksum(String::from("Header")));
|
return Err(VhdxHeaderError::InvalidChecksum(String::from("Header")));
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ impl Header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Converts the header structure into a buffer
|
/// Converts the header structure into a buffer
|
||||||
fn get_header_as_buffer(&self, buffer: &mut [u8; HEADER_SIZE as usize]) {
|
fn write_to_buffer(&self, buffer: &mut [u8; HEADER_SIZE as usize]) {
|
||||||
// SAFETY: self is a valid header.
|
// SAFETY: self is a valid header.
|
||||||
let reference = unsafe {
|
let reference = unsafe {
|
||||||
std::slice::from_raw_parts(self as *const Header as *const u8, HEADER_SIZE as usize)
|
std::slice::from_raw_parts(self as *const Header as *const u8, HEADER_SIZE as usize)
|
||||||
@@ -160,7 +160,7 @@ impl Header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and returns new updated header from the provided current header
|
/// Creates and returns new updated header from the provided current header
|
||||||
pub fn update_header(
|
fn update_header(
|
||||||
f: &mut File,
|
f: &mut File,
|
||||||
current_header: &Header,
|
current_header: &Header,
|
||||||
change_data_guid: bool,
|
change_data_guid: bool,
|
||||||
@@ -191,11 +191,9 @@ impl Header {
|
|||||||
log_offset: current_header.log_offset,
|
log_offset: current_header.log_offset,
|
||||||
};
|
};
|
||||||
|
|
||||||
new_header.get_header_as_buffer(&mut buffer);
|
new_header.write_to_buffer(&mut buffer);
|
||||||
let mut crc = crc_any::CRC::crc32c();
|
new_header.checksum = calculate_checksum(&mut buffer, size_of::<u32>());
|
||||||
crc.digest(&buffer);
|
new_header.write_to_buffer(&mut buffer);
|
||||||
new_header.checksum = crc.get_crc() as u32;
|
|
||||||
new_header.get_header_as_buffer(&mut buffer);
|
|
||||||
|
|
||||||
f.seek(SeekFrom::Start(start))
|
f.seek(SeekFrom::Start(start))
|
||||||
.map_err(VhdxHeaderError::SeekHeader)?;
|
.map_err(VhdxHeaderError::SeekHeader)?;
|
||||||
@@ -205,7 +203,7 @@ impl Header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
struct RegionTableHeader {
|
struct RegionTableHeader {
|
||||||
pub signature: u32,
|
pub signature: u32,
|
||||||
@@ -231,7 +229,7 @@ impl RegionTableHeader {
|
|||||||
return Err(VhdxHeaderError::InvalidRegionSign);
|
return Err(VhdxHeaderError::InvalidRegionSign);
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_checksum = calculate_checksum(&mut buffer, size_of::<u32>())?;
|
let new_checksum = calculate_checksum(&mut buffer, size_of::<u32>());
|
||||||
if region_table_header.checksum != new_checksum {
|
if region_table_header.checksum != new_checksum {
|
||||||
return Err(VhdxHeaderError::InvalidChecksum(String::from("Region")));
|
return Err(VhdxHeaderError::InvalidChecksum(String::from("Region")));
|
||||||
}
|
}
|
||||||
@@ -330,7 +328,7 @@ impl RegionInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct RegionTableEntry {
|
pub struct RegionTableEntry {
|
||||||
pub guid: Uuid,
|
pub guid: Uuid,
|
||||||
@@ -371,22 +369,10 @@ pub struct VhdxHeader {
|
|||||||
impl VhdxHeader {
|
impl VhdxHeader {
|
||||||
/// Creates a VhdxHeader from a reference to a file
|
/// Creates a VhdxHeader from a reference to a file
|
||||||
pub fn new(f: &mut File) -> Result<VhdxHeader> {
|
pub fn new(f: &mut File) -> Result<VhdxHeader> {
|
||||||
let _file_type_identifier: FileTypeIdentifier = FileTypeIdentifier::new(f)?;
|
|
||||||
let header_1 = Header::new(f, HEADER_1_START);
|
|
||||||
let header_2 = Header::new(f, HEADER_2_START);
|
|
||||||
|
|
||||||
let mut file_write_guid: u128 = 0;
|
|
||||||
let metadata = f.metadata().map_err(VhdxHeaderError::ReadMetadata)?;
|
|
||||||
if !metadata.permissions().readonly() {
|
|
||||||
file_write_guid = Uuid::new_v4().as_u128();
|
|
||||||
}
|
|
||||||
|
|
||||||
let (header_1, header_2) =
|
|
||||||
VhdxHeader::update_headers(f, header_1, header_2, file_write_guid)?;
|
|
||||||
Ok(VhdxHeader {
|
Ok(VhdxHeader {
|
||||||
_file_type_identifier,
|
_file_type_identifier: FileTypeIdentifier::new(f)?,
|
||||||
header_1,
|
header_1: Header::new(f, HEADER_1_START)?,
|
||||||
header_2,
|
header_2: Header::new(f, HEADER_2_START)?,
|
||||||
region_table_1: RegionTableHeader::new(f, REGION_TABLE_1_START)?,
|
region_table_1: RegionTableHeader::new(f, REGION_TABLE_1_START)?,
|
||||||
_region_table_2: RegionTableHeader::new(f, REGION_TABLE_2_START)?,
|
_region_table_2: RegionTableHeader::new(f, REGION_TABLE_2_START)?,
|
||||||
})
|
})
|
||||||
@@ -468,13 +454,11 @@ impl VhdxHeader {
|
|||||||
/// Therefore, before calculating, the existing checksum is retrieved and the
|
/// Therefore, before calculating, the existing checksum is retrieved and the
|
||||||
/// corresponding field is made zero. After the calculation, the existing checksum
|
/// corresponding field is made zero. After the calculation, the existing checksum
|
||||||
/// is put back to the buffer.
|
/// is put back to the buffer.
|
||||||
pub fn calculate_checksum(buffer: &mut [u8], csum_offset: usize) -> Result<u32> {
|
fn calculate_checksum(buffer: &mut [u8], csum_offset: usize) -> u32 {
|
||||||
// Read the checksum into a mutable slice
|
// Read the original checksum from the buffer
|
||||||
let csum_buf = &mut buffer[csum_offset..csum_offset + 4];
|
let orig_csum = LittleEndian::read_u32(&buffer[csum_offset..csum_offset + 4]);
|
||||||
// Convert the checksum chunk into a u32 integer
|
|
||||||
let orig_csum = LittleEndian::read_u32(csum_buf);
|
|
||||||
// Zero the checksum in the buffer
|
// Zero the checksum in the buffer
|
||||||
LittleEndian::write_u32(csum_buf, 0);
|
LittleEndian::write_u32(&mut buffer[csum_offset..csum_offset + 4], 0);
|
||||||
// Calculate the checksum on the resulting buffer
|
// Calculate the checksum on the resulting buffer
|
||||||
let mut crc = crc_any::CRC::crc32c();
|
let mut crc = crc_any::CRC::crc32c();
|
||||||
crc.digest(&buffer);
|
crc.digest(&buffer);
|
||||||
@@ -483,5 +467,5 @@ pub fn calculate_checksum(buffer: &mut [u8], csum_offset: usize) -> Result<u32>
|
|||||||
// Put back the original checksum in the buffer
|
// Put back the original checksum in the buffer
|
||||||
LittleEndian::write_u32(&mut buffer[csum_offset..csum_offset + 4], orig_csum);
|
LittleEndian::write_u32(&mut buffer[csum_offset..csum_offset + 4], orig_csum);
|
||||||
|
|
||||||
Ok(new_csum)
|
new_csum
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,46 +95,45 @@ pub fn read(
|
|||||||
mut sector_index: u64,
|
mut sector_index: u64,
|
||||||
mut sector_count: u64,
|
mut sector_count: u64,
|
||||||
) -> Result<usize> {
|
) -> Result<usize> {
|
||||||
|
if disk_spec.has_parent {
|
||||||
|
return Err(VhdxIoError::UnsupportedMode);
|
||||||
|
}
|
||||||
|
|
||||||
let mut read_count: usize = 0;
|
let mut read_count: usize = 0;
|
||||||
|
|
||||||
while sector_count > 0 {
|
while sector_count > 0 {
|
||||||
if disk_spec.has_parent {
|
let sector = Sector::new(disk_spec, bat, sector_index, sector_count)?;
|
||||||
return Err(VhdxIoError::UnsupportedMode);
|
|
||||||
} else {
|
|
||||||
let sector = Sector::new(disk_spec, bat, sector_index, sector_count)?;
|
|
||||||
|
|
||||||
let bat_entry = match bat.get(sector.bat_index as usize) {
|
let bat_entry = match bat.get(sector.bat_index as usize) {
|
||||||
Some(entry) => entry.0,
|
Some(entry) => entry.0,
|
||||||
None => {
|
None => {
|
||||||
return Err(VhdxIoError::InvalidBatIndex);
|
return Err(VhdxIoError::InvalidBatIndex);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
match bat_entry & vhdx_bat::BAT_STATE_BIT_MASK {
|
|
||||||
vhdx_bat::PAYLOAD_BLOCK_NOT_PRESENT
|
|
||||||
| vhdx_bat::PAYLOAD_BLOCK_UNDEFINED
|
|
||||||
| vhdx_bat::PAYLOAD_BLOCK_UNMAPPED
|
|
||||||
| vhdx_bat::PAYLOAD_BLOCK_ZERO => {}
|
|
||||||
vhdx_bat::PAYLOAD_BLOCK_FULLY_PRESENT => {
|
|
||||||
f.seek(SeekFrom::Start(sector.file_offset))
|
|
||||||
.map_err(VhdxIoError::ReadSectorBlock)?;
|
|
||||||
f.read_exact(
|
|
||||||
&mut buf[read_count
|
|
||||||
..(read_count + (sector.free_sectors * SECTOR_SIZE) as usize)],
|
|
||||||
)
|
|
||||||
.map_err(VhdxIoError::ReadSectorBlock)?;
|
|
||||||
}
|
|
||||||
vhdx_bat::PAYLOAD_BLOCK_PARTIALLY_PRESENT => {
|
|
||||||
return Err(VhdxIoError::UnsupportedMode);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return Err(VhdxIoError::InvalidBatEntryState);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
sector_count -= sector.free_sectors;
|
|
||||||
sector_index += sector.free_sectors;
|
|
||||||
read_count = sector.free_bytes as usize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match bat_entry & vhdx_bat::BAT_STATE_BIT_MASK {
|
||||||
|
vhdx_bat::PAYLOAD_BLOCK_NOT_PRESENT
|
||||||
|
| vhdx_bat::PAYLOAD_BLOCK_UNDEFINED
|
||||||
|
| vhdx_bat::PAYLOAD_BLOCK_UNMAPPED
|
||||||
|
| vhdx_bat::PAYLOAD_BLOCK_ZERO => {}
|
||||||
|
vhdx_bat::PAYLOAD_BLOCK_FULLY_PRESENT => {
|
||||||
|
f.seek(SeekFrom::Start(sector.file_offset))
|
||||||
|
.map_err(VhdxIoError::ReadSectorBlock)?;
|
||||||
|
f.read_exact(
|
||||||
|
&mut buf
|
||||||
|
[read_count..(read_count + (sector.free_sectors * SECTOR_SIZE) as usize)],
|
||||||
|
)
|
||||||
|
.map_err(VhdxIoError::ReadSectorBlock)?;
|
||||||
|
}
|
||||||
|
vhdx_bat::PAYLOAD_BLOCK_PARTIALLY_PRESENT => {
|
||||||
|
return Err(VhdxIoError::UnsupportedMode);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
return Err(VhdxIoError::InvalidBatEntryState);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sector_count -= sector.free_sectors;
|
||||||
|
sector_index += sector.free_sectors;
|
||||||
|
read_count += sector.free_bytes as usize;
|
||||||
}
|
}
|
||||||
Ok(read_count)
|
Ok(read_count)
|
||||||
}
|
}
|
||||||
@@ -150,77 +149,73 @@ pub fn write(
|
|||||||
mut sector_index: u64,
|
mut sector_index: u64,
|
||||||
mut sector_count: u64,
|
mut sector_count: u64,
|
||||||
) -> Result<usize> {
|
) -> Result<usize> {
|
||||||
|
if disk_spec.has_parent {
|
||||||
|
return Err(VhdxIoError::UnsupportedMode);
|
||||||
|
}
|
||||||
|
|
||||||
let mut write_count: usize = 0;
|
let mut write_count: usize = 0;
|
||||||
|
|
||||||
while sector_count > 0 {
|
while sector_count > 0 {
|
||||||
if disk_spec.has_parent {
|
let sector = Sector::new(disk_spec, bat, sector_index, sector_count)?;
|
||||||
return Err(VhdxIoError::UnsupportedMode);
|
|
||||||
} else {
|
|
||||||
let sector = Sector::new(disk_spec, bat, sector_index, sector_count)?;
|
|
||||||
|
|
||||||
let bat_entry = match bat.get(sector.bat_index as usize) {
|
let bat_entry = match bat.get(sector.bat_index as usize) {
|
||||||
Some(entry) => entry.0,
|
Some(entry) => entry.0,
|
||||||
None => {
|
None => {
|
||||||
return Err(VhdxIoError::InvalidBatIndex);
|
return Err(VhdxIoError::InvalidBatIndex);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
match bat_entry & vhdx_bat::BAT_STATE_BIT_MASK {
|
|
||||||
vhdx_bat::PAYLOAD_BLOCK_NOT_PRESENT
|
|
||||||
| vhdx_bat::PAYLOAD_BLOCK_UNDEFINED
|
|
||||||
| vhdx_bat::PAYLOAD_BLOCK_UNMAPPED
|
|
||||||
| vhdx_bat::PAYLOAD_BLOCK_ZERO => {
|
|
||||||
let file_offset =
|
|
||||||
align!(disk_spec.image_size, vhdx_metadata::BLOCK_SIZE_MIN as u64);
|
|
||||||
let new_size = file_offset
|
|
||||||
.checked_add(disk_spec.block_size as u64)
|
|
||||||
.ok_or(VhdxIoError::InvalidDiskSize)?;
|
|
||||||
|
|
||||||
f.set_len(new_size).map_err(VhdxIoError::ResizeFile)?;
|
|
||||||
disk_spec.image_size = new_size;
|
|
||||||
|
|
||||||
let new_bat_entry = file_offset
|
|
||||||
| (vhdx_bat::PAYLOAD_BLOCK_FULLY_PRESENT & vhdx_bat::BAT_STATE_BIT_MASK);
|
|
||||||
bat[sector.bat_index as usize] = BatEntry(new_bat_entry);
|
|
||||||
BatEntry::write_bat_entries(f, bat_offset, bat)
|
|
||||||
.map_err(VhdxIoError::WriteBat)?;
|
|
||||||
|
|
||||||
if file_offset < vhdx_metadata::BLOCK_SIZE_MIN as u64 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
f.seek(SeekFrom::Start(file_offset))
|
|
||||||
.map_err(VhdxIoError::ReadSectorBlock)?;
|
|
||||||
f.write_all(
|
|
||||||
&buf[write_count
|
|
||||||
..(write_count + (sector.free_sectors * SECTOR_SIZE) as usize)],
|
|
||||||
)
|
|
||||||
.map_err(VhdxIoError::ReadSectorBlock)?;
|
|
||||||
}
|
|
||||||
vhdx_bat::PAYLOAD_BLOCK_FULLY_PRESENT => {
|
|
||||||
if sector.file_offset < vhdx_metadata::BLOCK_SIZE_MIN as u64 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
f.seek(SeekFrom::Start(sector.file_offset))
|
|
||||||
.map_err(VhdxIoError::ReadSectorBlock)?;
|
|
||||||
f.write_all(
|
|
||||||
&buf[write_count
|
|
||||||
..(write_count + (sector.free_sectors * SECTOR_SIZE) as usize)],
|
|
||||||
)
|
|
||||||
.map_err(VhdxIoError::ReadSectorBlock)?;
|
|
||||||
}
|
|
||||||
vhdx_bat::PAYLOAD_BLOCK_PARTIALLY_PRESENT => {
|
|
||||||
return Err(VhdxIoError::UnsupportedMode);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return Err(VhdxIoError::InvalidBatEntryState);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
sector_count -= sector.free_sectors;
|
|
||||||
sector_index += sector.free_sectors;
|
|
||||||
write_count = sector.free_bytes as usize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match bat_entry & vhdx_bat::BAT_STATE_BIT_MASK {
|
||||||
|
vhdx_bat::PAYLOAD_BLOCK_NOT_PRESENT
|
||||||
|
| vhdx_bat::PAYLOAD_BLOCK_UNDEFINED
|
||||||
|
| vhdx_bat::PAYLOAD_BLOCK_UNMAPPED
|
||||||
|
| vhdx_bat::PAYLOAD_BLOCK_ZERO => {
|
||||||
|
let file_offset =
|
||||||
|
align!(disk_spec.image_size, vhdx_metadata::BLOCK_SIZE_MIN as u64);
|
||||||
|
let new_size = file_offset
|
||||||
|
.checked_add(disk_spec.block_size as u64)
|
||||||
|
.ok_or(VhdxIoError::InvalidDiskSize)?;
|
||||||
|
|
||||||
|
f.set_len(new_size).map_err(VhdxIoError::ResizeFile)?;
|
||||||
|
disk_spec.image_size = new_size;
|
||||||
|
|
||||||
|
let new_bat_entry = file_offset
|
||||||
|
| (vhdx_bat::PAYLOAD_BLOCK_FULLY_PRESENT & vhdx_bat::BAT_STATE_BIT_MASK);
|
||||||
|
bat[sector.bat_index as usize] = BatEntry(new_bat_entry);
|
||||||
|
BatEntry::write_bat_entries(f, bat_offset, bat).map_err(VhdxIoError::WriteBat)?;
|
||||||
|
|
||||||
|
if file_offset < vhdx_metadata::BLOCK_SIZE_MIN as u64 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.seek(SeekFrom::Start(file_offset))
|
||||||
|
.map_err(VhdxIoError::ReadSectorBlock)?;
|
||||||
|
f.write_all(
|
||||||
|
&buf[write_count..(write_count + (sector.free_sectors * SECTOR_SIZE) as usize)],
|
||||||
|
)
|
||||||
|
.map_err(VhdxIoError::ReadSectorBlock)?;
|
||||||
|
}
|
||||||
|
vhdx_bat::PAYLOAD_BLOCK_FULLY_PRESENT => {
|
||||||
|
if sector.file_offset < vhdx_metadata::BLOCK_SIZE_MIN as u64 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.seek(SeekFrom::Start(sector.file_offset))
|
||||||
|
.map_err(VhdxIoError::ReadSectorBlock)?;
|
||||||
|
f.write_all(
|
||||||
|
&buf[write_count..(write_count + (sector.free_sectors * SECTOR_SIZE) as usize)],
|
||||||
|
)
|
||||||
|
.map_err(VhdxIoError::ReadSectorBlock)?;
|
||||||
|
}
|
||||||
|
vhdx_bat::PAYLOAD_BLOCK_PARTIALLY_PRESENT => {
|
||||||
|
return Err(VhdxIoError::UnsupportedMode);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
return Err(VhdxIoError::InvalidBatEntryState);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sector_count -= sector.free_sectors;
|
||||||
|
sector_index += sector.free_sectors;
|
||||||
|
write_count += sector.free_bytes as usize;
|
||||||
}
|
}
|
||||||
Ok(write_count)
|
Ok(write_count)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ const METADATA_LENGTH_MAX: u32 = 1 << 20; // 1 MiB
|
|||||||
pub enum VhdxMetadataError {
|
pub enum VhdxMetadataError {
|
||||||
#[error("Invalid block size count")]
|
#[error("Invalid block size count")]
|
||||||
InvalidBlockSize,
|
InvalidBlockSize,
|
||||||
|
#[error("Invalid disk size {0}")]
|
||||||
|
InvalidDiskSize(u64),
|
||||||
#[error("Invalid metadata entry count")]
|
#[error("Invalid metadata entry count")]
|
||||||
InvalidEntryCount,
|
InvalidEntryCount,
|
||||||
#[error("Invalid logical sector size")]
|
#[error("Invalid logical sector size")]
|
||||||
@@ -214,6 +216,14 @@ impl DiskSpec {
|
|||||||
if metadata_presence != METADATA_ALL_PRESENT {
|
if metadata_presence != METADATA_ALL_PRESENT {
|
||||||
return Err(VhdxMetadataError::MissingMetadata);
|
return Err(VhdxMetadataError::MissingMetadata);
|
||||||
}
|
}
|
||||||
|
// Make sure virtual disk size is not zero
|
||||||
|
if (metadata_presence & METADATA_VIRTUAL_DISK_SIZE_PRESENT != 0)
|
||||||
|
&& disk_spec.virtual_disk_size == 0
|
||||||
|
{
|
||||||
|
return Err(VhdxMetadataError::InvalidDiskSize(
|
||||||
|
disk_spec.virtual_disk_size,
|
||||||
|
));
|
||||||
|
}
|
||||||
// Check if the virtual disk size is a multiple of the logical sector
|
// Check if the virtual disk size is a multiple of the logical sector
|
||||||
// size.
|
// size.
|
||||||
if ((metadata_presence & METADATA_LOGICAL_SECTOR_SIZE_PRESENT) != 0)
|
if ((metadata_presence & METADATA_LOGICAL_SECTOR_SIZE_PRESENT) != 0)
|
||||||
@@ -257,7 +267,7 @@ impl DiskSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Default, Debug, Clone, Copy)]
|
#[derive(Default, Debug, Clone, Copy)]
|
||||||
struct MetadataTableHeader {
|
struct MetadataTableHeader {
|
||||||
signature: u64,
|
signature: u64,
|
||||||
@@ -288,7 +298,7 @@ impl MetadataTableHeader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[derive(Default, Debug, Clone, Copy)]
|
#[derive(Default, Debug, Clone, Copy)]
|
||||||
pub struct MetadataTableEntry {
|
pub struct MetadataTableEntry {
|
||||||
item_id: Uuid,
|
item_id: Uuid,
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
use std::os::fd::AsRawFd;
|
||||||
use std::sync::{Arc, Mutex, MutexGuard};
|
use std::sync::{Arc, Mutex, MutexGuard};
|
||||||
|
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
use crate::async_io::{AsyncIo, AsyncIoResult, DiskFile, DiskFileError, DiskFileResult};
|
use crate::async_io::{
|
||||||
|
AsyncIo, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||||
|
};
|
||||||
use crate::vhdx::{Result as VhdxResult, Vhdx};
|
use crate::vhdx::{Result as VhdxResult, Vhdx};
|
||||||
use crate::AsyncAdaptor;
|
use crate::AsyncAdaptor;
|
||||||
|
|
||||||
@@ -35,6 +38,11 @@ impl DiskFile for VhdxDiskSync {
|
|||||||
as Box<dyn AsyncIo>,
|
as Box<dyn AsyncIo>,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fd(&mut self) -> BorrowedDiskFd {
|
||||||
|
let lock = self.vhdx_file.lock().unwrap();
|
||||||
|
BorrowedDiskFd::new(lock.as_raw_fd())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct VhdxSync {
|
pub struct VhdxSync {
|
||||||
|
|||||||
9
build.rs
9
build.rs
@@ -3,6 +3,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -12,10 +13,18 @@ fn main() {
|
|||||||
if git_out.status.success() {
|
if git_out.status.success() {
|
||||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||||
version = git_out_str;
|
version = git_out_str;
|
||||||
|
// Pop the trailing newline.
|
||||||
|
version.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append CH_EXTRA_VERSION to version if it is set.
|
||||||
|
if let Ok(extra_version) = env::var("CH_EXTRA_VERSION") {
|
||||||
|
println!("cargo:rerun-if-env-changed=CH_EXTRA_VERSION");
|
||||||
|
version.push_str(&format!("-{extra_version}"));
|
||||||
|
}
|
||||||
|
|
||||||
// This println!() has a special behavior, as it will set the environment
|
// This println!() has a special behavior, as it will set the environment
|
||||||
// variable BUILD_VERSION, so that it can be reused from the binary.
|
// variable BUILD_VERSION, so that it can be reused from the binary.
|
||||||
// Particularly, this is used from src/main.rs to display the exact
|
// Particularly, this is used from src/main.rs to display the exact
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ version = "0.1.0"
|
|||||||
acpi_tables = { workspace = true }
|
acpi_tables = { workspace = true }
|
||||||
anyhow = "1.0.94"
|
anyhow = "1.0.94"
|
||||||
arch = { path = "../arch" }
|
arch = { path = "../arch" }
|
||||||
bitflags = "2.6.0"
|
bitflags = "2.9.0"
|
||||||
byteorder = "1.5.0"
|
byteorder = "1.5.0"
|
||||||
event_monitor = { path = "../event_monitor" }
|
event_monitor = { path = "../event_monitor" }
|
||||||
hypervisor = { path = "../hypervisor" }
|
hypervisor = { path = "../hypervisor" }
|
||||||
@@ -17,7 +17,7 @@ log = "0.4.22"
|
|||||||
num_enum = "0.7.2"
|
num_enum = "0.7.2"
|
||||||
pci = { path = "../pci" }
|
pci = { path = "../pci" }
|
||||||
serde = { version = "1.0.208", features = ["derive"] }
|
serde = { version = "1.0.208", features = ["derive"] }
|
||||||
thiserror = "1.0.62"
|
thiserror = "2.0.6"
|
||||||
tpm = { path = "../tpm" }
|
tpm = { path = "../tpm" }
|
||||||
vm-allocator = { path = "../vm-allocator" }
|
vm-allocator = { path = "../vm-allocator" }
|
||||||
vm-device = { path = "../vm-device" }
|
vm-device = { path = "../vm-device" }
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ use std::sync::{Arc, Mutex};
|
|||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use arch::layout;
|
use arch::layout;
|
||||||
use hypervisor::arch::aarch64::gic::{Vgic, VgicConfig};
|
use hypervisor::arch::aarch64::gic::{GicState, Vgic, VgicConfig};
|
||||||
use hypervisor::{CpuState, GicState};
|
use hypervisor::CpuState;
|
||||||
use vm_device::interrupt::{
|
use vm_device::interrupt::{
|
||||||
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
|
InterruptIndex, InterruptManager, InterruptSourceConfig, InterruptSourceGroup,
|
||||||
LegacyIrqSourceConfig, MsiIrqGroupConfig,
|
LegacyIrqSourceConfig, MsiIrqGroupConfig,
|
||||||
|
|||||||
@@ -18,38 +18,38 @@ pub enum Error {
|
|||||||
InvalidDeliveryMode,
|
InvalidDeliveryMode,
|
||||||
/// Failed creating the interrupt source group.
|
/// Failed creating the interrupt source group.
|
||||||
#[error("Failed creating the interrupt source group: {0}")]
|
#[error("Failed creating the interrupt source group: {0}")]
|
||||||
CreateInterruptSourceGroup(io::Error),
|
CreateInterruptSourceGroup(#[source] io::Error),
|
||||||
/// Failed triggering the interrupt.
|
/// Failed triggering the interrupt.
|
||||||
#[error("Failed triggering the interrupt: {0}")]
|
#[error("Failed triggering the interrupt: {0}")]
|
||||||
TriggerInterrupt(io::Error),
|
TriggerInterrupt(#[source] io::Error),
|
||||||
/// Failed masking the interrupt.
|
/// Failed masking the interrupt.
|
||||||
#[error("Failed masking the interrupt: {0}")]
|
#[error("Failed masking the interrupt: {0}")]
|
||||||
MaskInterrupt(io::Error),
|
MaskInterrupt(#[source] io::Error),
|
||||||
/// Failed unmasking the interrupt.
|
/// Failed unmasking the interrupt.
|
||||||
#[error("Failed unmasking the interrupt: {0}")]
|
#[error("Failed unmasking the interrupt: {0}")]
|
||||||
UnmaskInterrupt(io::Error),
|
UnmaskInterrupt(#[source] io::Error),
|
||||||
/// Failed updating the interrupt.
|
/// Failed updating the interrupt.
|
||||||
#[error("Failed updating the interrupt: {0}")]
|
#[error("Failed updating the interrupt: {0}")]
|
||||||
UpdateInterrupt(io::Error),
|
UpdateInterrupt(#[source] io::Error),
|
||||||
/// Failed enabling the interrupt.
|
/// Failed enabling the interrupt.
|
||||||
#[error("Failed enabling the interrupt: {0}")]
|
#[error("Failed enabling the interrupt: {0}")]
|
||||||
EnableInterrupt(io::Error),
|
EnableInterrupt(#[source] io::Error),
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
/// Failed creating GIC device.
|
/// Failed creating GIC device.
|
||||||
#[error("Failed creating GIC device: {0}")]
|
#[error("Failed creating GIC device: {0}")]
|
||||||
CreateGic(hypervisor::HypervisorVmError),
|
CreateGic(#[source] hypervisor::HypervisorVmError),
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
/// Failed restoring GIC device.
|
/// Failed restoring GIC device.
|
||||||
#[error("Failed restoring GIC device: {0}")]
|
#[error("Failed restoring GIC device: {0}")]
|
||||||
RestoreGic(hypervisor::arch::aarch64::gic::Error),
|
RestoreGic(#[source] hypervisor::arch::aarch64::gic::Error),
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
/// Failed creating AIA device.
|
/// Failed creating AIA device.
|
||||||
#[error("Failed creating AIA device: {0}")]
|
#[error("Failed creating AIA device: {0}")]
|
||||||
CreateAia(hypervisor::HypervisorVmError),
|
CreateAia(#[source] hypervisor::HypervisorVmError),
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
/// Failed restoring AIA device.
|
/// Failed restoring AIA device.
|
||||||
#[error("Failed restoring AIA device: {0}")]
|
#[error("Failed restoring AIA device: {0}")]
|
||||||
RestoreAia(hypervisor::arch::riscv64::aia::Error),
|
RestoreAia(#[source] hypervisor::arch::riscv64::aia::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result<T> = result::Result<T, Error>;
|
type Result<T> = result::Result<T, Error>;
|
||||||
|
|||||||
@@ -346,9 +346,9 @@ impl Ioapic {
|
|||||||
|
|
||||||
// Generate MSI message address
|
// Generate MSI message address
|
||||||
let low_addr: u32 = self.apic_address.0 as u32
|
let low_addr: u32 = self.apic_address.0 as u32
|
||||||
| u32::from(destination_id) << 12
|
| (u32::from(destination_id) << 12)
|
||||||
| u32::from(redirection_hint) << 3
|
| (u32::from(redirection_hint) << 3)
|
||||||
| u32::from(destination_mode) << 2;
|
| (u32::from(destination_mode) << 2);
|
||||||
|
|
||||||
// Validate Trigger Mode value
|
// Validate Trigger Mode value
|
||||||
let trigger_mode = trigger_mode(entry);
|
let trigger_mode = trigger_mode(entry);
|
||||||
@@ -372,9 +372,9 @@ impl Ioapic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate MSI message data
|
// Generate MSI message data
|
||||||
let data: u32 = u32::from(trigger_mode) << 15
|
let data: u32 = (u32::from(trigger_mode) << 15)
|
||||||
| u32::from(remote_irr(entry)) << 14
|
| (u32::from(remote_irr(entry)) << 14)
|
||||||
| u32::from(delivery_mode) << 8
|
| (u32::from(delivery_mode) << 8)
|
||||||
| u32::from(vector(entry));
|
| u32::from(vector(entry));
|
||||||
|
|
||||||
let config = MsiIrqSourceConfig {
|
let config = MsiIrqSourceConfig {
|
||||||
@@ -418,7 +418,7 @@ impl InterruptController for Ioapic {
|
|||||||
self.interrupt_source_group
|
self.interrupt_source_group
|
||||||
.trigger(irq as InterruptIndex)
|
.trigger(irq as InterruptIndex)
|
||||||
.map_err(Error::TriggerInterrupt)?;
|
.map_err(Error::TriggerInterrupt)?;
|
||||||
debug!("Interrupt {irq} successfully delivered");
|
trace!("Interrupt {irq} successfully delivered");
|
||||||
|
|
||||||
// If trigger mode is level sensitive, set the Remote IRR bit.
|
// If trigger mode is level sensitive, set the Remote IRR bit.
|
||||||
// It will be cleared when the EOI is received.
|
// It will be cleared when the EOI is received.
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ impl BusDevice for Cmos {
|
|||||||
0x08 => to_bcd(month as u8),
|
0x08 => to_bcd(month as u8),
|
||||||
0x09 => to_bcd((year % 100) as u8),
|
0x09 => to_bcd((year % 100) as u8),
|
||||||
// Bit 5 for 32kHz clock. Bit 7 for Update in Progress
|
// Bit 5 for 32kHz clock. Bit 7 for Update in Progress
|
||||||
0x0a => 1 << 5 | (update_in_progress as u8) << 7,
|
0x0a => (1 << 5) | ((update_in_progress as u8) << 7),
|
||||||
// Bit 0-6 are reserved and must be 0.
|
// Bit 0-6 are reserved and must be 0.
|
||||||
// Bit 7 must be 1 (CMOS has power)
|
// Bit 7 must be 1 (CMOS has power)
|
||||||
0x0d => 1 << 7,
|
0x0d => 1 << 7,
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ const N_GPIOS: u32 = 8;
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Bad Write Offset: {0}")]
|
#[error("Bad Write Offset: {0}")]
|
||||||
BadWriteOffset(u64),
|
BadWriteOffset(u64),
|
||||||
#[error("GPIO interrupt disabled by guest driver.")]
|
#[error("GPIO interrupt disabled by guest driver")]
|
||||||
GpioInterruptDisabled,
|
GpioInterruptDisabled,
|
||||||
#[error("Could not trigger GPIO interrupt: {0}.")]
|
#[error("Could not trigger GPIO interrupt: {0}")]
|
||||||
GpioInterruptFailure(io::Error),
|
GpioInterruptFailure(#[source] io::Error),
|
||||||
#[error("Invalid GPIO Input key triggered: {0}.")]
|
#[error("Invalid GPIO Input key triggered: {0}")]
|
||||||
GpioTriggerKeyFailure(u32),
|
GpioTriggerKeyFailure(u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ pub enum Error {
|
|||||||
#[error("Bad Write Offset: {0}")]
|
#[error("Bad Write Offset: {0}")]
|
||||||
BadWriteOffset(u64),
|
BadWriteOffset(u64),
|
||||||
#[error("Failed to trigger interrupt: {0}")]
|
#[error("Failed to trigger interrupt: {0}")]
|
||||||
InterruptFailure(io::Error),
|
InterruptFailure(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result<T> = result::Result<T, Error>;
|
type Result<T> = result::Result<T, Error>;
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ const AMBA_ID_HIGH: u64 = 0x401;
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("pl011_write: Bad Write Offset: {0}")]
|
#[error("pl011_write: Bad Write Offset: {0}")]
|
||||||
BadWriteOffset(u64),
|
BadWriteOffset(u64),
|
||||||
#[error("pl011: DMA not implemented.")]
|
#[error("pl011: DMA not implemented")]
|
||||||
DmaNotImplemented,
|
DmaNotImplemented,
|
||||||
#[error("Failed to trigger interrupt: {0}")]
|
#[error("Failed to trigger interrupt: {0}")]
|
||||||
InterruptFailure(io::Error),
|
InterruptFailure(#[source] io::Error),
|
||||||
#[error("Failed to write: {0}")]
|
#[error("Failed to write: {0}")]
|
||||||
WriteAllFailure(io::Error),
|
WriteAllFailure(#[source] io::Error),
|
||||||
#[error("Failed to flush: {0}")]
|
#[error("Failed to flush: {0}")]
|
||||||
FlushFailure(io::Error),
|
FlushFailure(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result<T> = result::Result<T, Error>;
|
type Result<T> = result::Result<T, Error>;
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ impl PvmemcontrolBusDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_vma_anon_name(&self, addr: u64, length: u64, name: u64) -> result::Result<(), Error> {
|
fn set_vma_anon_name(&self, addr: u64, length: u64, name: u64) -> result::Result<(), Error> {
|
||||||
let name = (name != 0).then(|| CString::new(format!("pvmemcontrol-{}", name)).unwrap());
|
let name = (name != 0).then(|| CString::new(format!("pvmemcontrol-{name}")).unwrap());
|
||||||
let name_ptr = if let Some(name) = &name {
|
let name_ptr = if let Some(name) = &name {
|
||||||
name.as_ptr()
|
name.as_ptr()
|
||||||
} else {
|
} else {
|
||||||
@@ -698,17 +698,19 @@ impl PciDevice for PvmemcontrolPciDevice {
|
|||||||
reg_idx: usize,
|
reg_idx: usize,
|
||||||
offset: u64,
|
offset: u64,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Option<Arc<Barrier>> {
|
) -> (Vec<BarReprogrammingParams>, Option<Arc<Barrier>>) {
|
||||||
self.configuration
|
(
|
||||||
.write_config_register(reg_idx, offset, data);
|
self.configuration
|
||||||
None
|
.write_config_register(reg_idx, offset, data),
|
||||||
|
None,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_config_register(&mut self, reg_idx: usize) -> u32 {
|
fn read_config_register(&mut self, reg_idx: usize) -> u32 {
|
||||||
self.configuration.read_config_register(reg_idx)
|
self.configuration.read_config_register(reg_idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any(&mut self) -> &mut dyn std::any::Any {
|
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,14 +718,6 @@ impl PciDevice for PvmemcontrolPciDevice {
|
|||||||
Some(self.id.clone())
|
Some(self.id.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn detect_bar_reprogramming(
|
|
||||||
&mut self,
|
|
||||||
reg_idx: usize,
|
|
||||||
data: &[u8],
|
|
||||||
) -> Option<BarReprogrammingParams> {
|
|
||||||
self.configuration.detect_bar_reprogramming(reg_idx, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn allocate_bars(
|
fn allocate_bars(
|
||||||
&mut self,
|
&mut self,
|
||||||
_allocator: &Arc<Mutex<SystemAllocator>>,
|
_allocator: &Arc<Mutex<SystemAllocator>>,
|
||||||
|
|||||||
@@ -88,7 +88,11 @@ impl PvPanicDevice {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let command: [u8; 2] = [0x03, 0x01];
|
let command: [u8; 2] = [0x03, 0x01];
|
||||||
configuration.write_config_register(1, 0, &command);
|
let bar_reprogram = configuration.write_config_register(1, 0, &command);
|
||||||
|
assert!(
|
||||||
|
bar_reprogram.is_empty(),
|
||||||
|
"No bar reprogrammig is expected from writing to the COMMAND register"
|
||||||
|
);
|
||||||
|
|
||||||
let state: Option<PvPanicDeviceState> = snapshot
|
let state: Option<PvPanicDeviceState> = snapshot
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -156,24 +160,18 @@ impl PciDevice for PvPanicDevice {
|
|||||||
reg_idx: usize,
|
reg_idx: usize,
|
||||||
offset: u64,
|
offset: u64,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Option<Arc<Barrier>> {
|
) -> (Vec<BarReprogrammingParams>, Option<Arc<Barrier>>) {
|
||||||
self.configuration
|
(
|
||||||
.write_config_register(reg_idx, offset, data);
|
self.configuration
|
||||||
None
|
.write_config_register(reg_idx, offset, data),
|
||||||
|
None,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_config_register(&mut self, reg_idx: usize) -> u32 {
|
fn read_config_register(&mut self, reg_idx: usize) -> u32 {
|
||||||
self.configuration.read_reg(reg_idx)
|
self.configuration.read_reg(reg_idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn detect_bar_reprogramming(
|
|
||||||
&mut self,
|
|
||||||
reg_idx: usize,
|
|
||||||
data: &[u8],
|
|
||||||
) -> Option<BarReprogrammingParams> {
|
|
||||||
self.configuration.detect_bar_reprogramming(reg_idx, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn allocate_bars(
|
fn allocate_bars(
|
||||||
&mut self,
|
&mut self,
|
||||||
_allocator: &Arc<Mutex<SystemAllocator>>,
|
_allocator: &Arc<Mutex<SystemAllocator>>,
|
||||||
@@ -237,7 +235,7 @@ impl PciDevice for PvPanicDevice {
|
|||||||
data[0] = self.events;
|
data[0] = self.events;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any(&mut self) -> &mut dyn Any {
|
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# AMD SEV-SNP
|
# AMD SEV-SNP
|
||||||
|
|
||||||
### WARNING
|
### WARNING
|
||||||
|
|
||||||
This feature is only currently supported on MSHV.
|
This feature is only currently supported on MSHV.
|
||||||
|
|
||||||
AMD Secure Encrypted Virtualization & Secure Nested Paging (SEV-SNP) is an AMD
|
AMD Secure Encrypted Virtualization & Secure Nested Paging (SEV-SNP) is an AMD
|
||||||
@@ -9,8 +10,8 @@ malicious hypervisor-based attacks like data replay, memory-remapping and more
|
|||||||
in order to create an isolated execution environment. Here are some useful
|
in order to create an isolated execution environment. Here are some useful
|
||||||
links:
|
links:
|
||||||
|
|
||||||
* [SNP Homepage] (https://www.amd.com/en/processors/amd-secure-encrypted-virtualization)
|
- [SNP Homepage](https://www.amd.com/content/dam/amd/en/documents/epyc-business-docs/solution-briefs/amd-secure-encrypted-virtualization-solution-brief.pdf):
|
||||||
more information about SEV-SNP technical aspects, design and specification.
|
more information about SEV-SNP technical aspects, design and specification.
|
||||||
|
|
||||||
## Cloud Hypervisor support
|
## Cloud Hypervisor support
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# `cloud-hypervisor` debug IO ports
|
# `cloud-hypervisor` debug IO ports
|
||||||
|
|
||||||
When running x86 guests, `cloud-hypervisor` provides different kinds of debug ports:
|
When running x86 guests, `cloud-hypervisor` provides different kinds of debug ports:
|
||||||
- [`0x80` debug port](https://www.intel.com/content/www/us/en/support/articles/000005500/boards-and-kits.html)
|
|
||||||
- Debug console (by default at `0xe9`).
|
- [`0x80` debug port](https://web.archive.org/web/20211028033025/https://www.intel.com/content/www/us/en/support/articles/000005500/boards-and-kits.html)
|
||||||
|
- Debug console (by default at `0xe9`).
|
||||||
- Firmware debug port at `0x402`.
|
- Firmware debug port at `0x402`.
|
||||||
|
|
||||||
All of them can be used to trace user-defined guest events and all of them can
|
All of them can be used to trace user-defined guest events and all of them can
|
||||||
@@ -25,13 +26,13 @@ for debugging specific components of the guest software stack. When logging a
|
|||||||
write of one of those codes to the debug port, `cloud-hypervisor` adds a
|
write of one of those codes to the debug port, `cloud-hypervisor` adds a
|
||||||
pre-defined string to the logs.
|
pre-defined string to the logs.
|
||||||
|
|
||||||
| Code Range | Component | Log string |
|
| Code Range | Component | Log string |
|
||||||
| ---------------- | ----------- | ------------ |
|
| ---------------- | ---------- | ------------ |
|
||||||
| `0x00` to `0x1f` | Firmware | `Firmware` |
|
| `0x00` to `0x1f` | Firmware | `Firmware` |
|
||||||
| `0x20` to `0x3f` | Bootloader | `Bootloader` |
|
| `0x20` to `0x3f` | Bootloader | `Bootloader` |
|
||||||
| `0x40` to `0x5f` | Kernel | `Kernel` |
|
| `0x40` to `0x5f` | Kernel | `Kernel` |
|
||||||
| `0x60` to `0x7f` | Userspace | `Userspace` |
|
| `0x60` to `0x7f` | Userspace | `Userspace` |
|
||||||
| `0x80` to `0xff` | Custom | `Custom` |
|
| `0x80` to `0xff` | Custom | `Custom` |
|
||||||
|
|
||||||
One typical use case is guest boot time measurement and tracing. By writing
|
One typical use case is guest boot time measurement and tracing. By writing
|
||||||
different values to the debug I/O port at different boot process steps, the
|
different values to the debug I/O port at different boot process steps, the
|
||||||
@@ -71,8 +72,8 @@ cloud-hypervisor: 403.499628ms: DEBUG:vmm/src/vm.rs:510 -- [Debug I/O port: Firm
|
|||||||
|
|
||||||
### Debug console port
|
### Debug console port
|
||||||
|
|
||||||
The debug console is inspired by QEMU and Bochs, which have a similar feature.
|
The debug console is inspired by QEMU and Bochs, which have a similar feature.
|
||||||
By default, the I/O port `0xe9` is used. This port can be configured like a
|
By default, the I/O port `0xe9` is used. This port can be configured like a
|
||||||
console. Thus, it can print to a tty, a file, or a pty, for example.
|
console. Thus, it can print to a tty, a file, or a pty, for example.
|
||||||
|
|
||||||
### Firmware debug port
|
### Firmware debug port
|
||||||
@@ -83,7 +84,7 @@ it. The firmware debug port only prints to stdout.
|
|||||||
## When do I need these ports?
|
## When do I need these ports?
|
||||||
|
|
||||||
The ports are on the one hand interesting for firmware or kernel developers, as
|
The ports are on the one hand interesting for firmware or kernel developers, as
|
||||||
they provide an easy way to print debug information from within a guest.
|
they provide an easy way to print debug information from within a guest.
|
||||||
Furthermore, you can patch "normal" software to measure certain events, such as
|
Furthermore, you can patch "normal" software to measure certain events, such as
|
||||||
the boot time of a guest.
|
the boot time of a guest.
|
||||||
|
|
||||||
@@ -91,6 +92,6 @@ the boot time of a guest.
|
|||||||
|
|
||||||
The `0x80` debug port and the port of the firmware debug device are always
|
The `0x80` debug port and the port of the firmware debug device are always
|
||||||
available. The debug console must be activated via the command line, but
|
available. The debug console must be activated via the command line, but
|
||||||
provides more configuration options.
|
provides more configuration options.
|
||||||
|
|
||||||
You can use different ports for different aspect of your logging messages.
|
You can use different ports for different aspect of your logging messages.
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ the host kernel. The required Linux and KVM changes can be found in the
|
|||||||
[KVM SGX Tree](https://github.com/intel/kvm-sgx).
|
[KVM SGX Tree](https://github.com/intel/kvm-sgx).
|
||||||
|
|
||||||
Utilizing SGX in the guest requires a kernel/OS with SGX support, e.g. a kernel
|
Utilizing SGX in the guest requires a kernel/OS with SGX support, e.g. a kernel
|
||||||
built using the [SGX Linux Development Tree](https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-sgx.git)
|
since release 5.11, see
|
||||||
|
[here](https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html)
|
||||||
or the [KVM SGX Tree](https://github.com/intel/kvm-sgx). Running KVM SGX as the
|
or the [KVM SGX Tree](https://github.com/intel/kvm-sgx). Running KVM SGX as the
|
||||||
guest kernel allows nested virtualization of SGX.
|
guest kernel allows nested virtualization of SGX.
|
||||||
|
|
||||||
For more information about SGX, please refer to the [SGX Homepage](https://software.intel.com/sgx).
|
For more information about SGX, please refer to the [SGX Homepage](https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html).
|
||||||
|
|
||||||
For more information about SGX SDK and how to test SGX, please refer to the
|
For more information about SGX SDK and how to test SGX, please refer to the
|
||||||
following [instructions](https://github.com/intel/linux-sgx).
|
following [instructions](https://github.com/intel/linux-sgx).
|
||||||
|
|||||||
@@ -4,21 +4,21 @@ Intel® Trust Domain Extensions (Intel® TDX) is an Intel technology designed to
|
|||||||
isolate virtual machines from the VMM, hypervisor and any other software on the
|
isolate virtual machines from the VMM, hypervisor and any other software on the
|
||||||
host platform. Here are some useful links:
|
host platform. Here are some useful links:
|
||||||
|
|
||||||
* [TDX Homepage](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-trust-domain-extensions.html):
|
- [TDX Homepage](https://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/overview.html):
|
||||||
more information about TDX technical aspects, design and specification
|
more information about TDX technical aspects, design and specification
|
||||||
|
|
||||||
* [KVM TDX tree](https://github.com/intel/tdx/tree/kvm): the required
|
- [KVM TDX tree](https://github.com/intel/tdx/tree/kvm): the required
|
||||||
Linux kernel changes for the host side
|
Linux kernel changes for the host side
|
||||||
|
|
||||||
* [Guest TDX tree](https://github.com/intel/tdx/tree/guest): the Linux
|
- [Guest TDX tree](https://github.com/intel/tdx/tree/guest): the Linux
|
||||||
kernel changes for the guest side
|
kernel changes for the guest side
|
||||||
|
|
||||||
* [EDK2 project](https://github.com/tianocore/edk2): the TDVF firmware
|
- [EDK2 project](https://github.com/tianocore/edk2): the TDVF firmware
|
||||||
|
|
||||||
* [Confidential Containers project](https://github.com/confidential-containers/td-shim):
|
- [Confidential Containers project](https://github.com/confidential-containers/td-shim):
|
||||||
the TDShim firmware
|
the TDShim firmware
|
||||||
|
|
||||||
* [TDX Tools](https://github.com/intel/tdx-tools): a collection of tools
|
- [TDX Linux](https://github.com/intel/tdx-linux): a collection of tools
|
||||||
and scripts to setup TDX environment for testing purpose (such as
|
and scripts to setup TDX environment for testing purpose (such as
|
||||||
installing required packages on the host, creating guest images, and
|
installing required packages on the host, creating guest images, and
|
||||||
building the custom Linux kernel for TDX host and guest)
|
building the custom Linux kernel for TDX host and guest)
|
||||||
@@ -27,17 +27,13 @@ more information about TDX technical aspects, design and specification
|
|||||||
|
|
||||||
It is required to use a machine with TDX enabled in hardware and
|
It is required to use a machine with TDX enabled in hardware and
|
||||||
with the host OS compiled from the [KVM TDX tree](https://github.com/intel/tdx/tree/kvm).
|
with the host OS compiled from the [KVM TDX tree](https://github.com/intel/tdx/tree/kvm).
|
||||||
The host environment can also be setup with the [TDX Tools](https://github.com/intel/tdx-tools).
|
The host environment can also be setup with the [TDX Linux](https://github.com/intel/tdx-linux).
|
||||||
|
|
||||||
Cloud Hypervisor can run TDX VM (Trust Domain) by loading a TD firmware ([TDVF](https://github.com/tianocore/edk2)),
|
Cloud Hypervisor can run TDX VM (Trust Domain) by loading a TD firmware ([TDVF](https://github.com/tianocore/edk2)),
|
||||||
which will then load the guest kernel from the image. The image must be custom
|
which will then load the guest kernel from the image. The image must be custom
|
||||||
as it must include a kernel built from the [Guest TDX tree](https://github.com/intel/tdx/tree/guest).
|
as it must include a kernel built from the [Guest TDX tree](https://github.com/intel/tdx/tree/guest).
|
||||||
Cloud Hypervisor can also boot a TDX VM with direct kernel boot using [TDshim](https://github.com/confidential-containers/td-shim).
|
Cloud Hypervisor can also boot a TDX VM with direct kernel boot using [TDshim](https://github.com/confidential-containers/td-shim).
|
||||||
The custom Linux kernel for the guest can be built with the [TDX Tools](https://github.com/intel/tdx-tools).
|
The custom Linux kernel for the guest can be built with the [TDX Linux](https://github.com/intel/tdx-linux).
|
||||||
|
|
||||||
> **Note**
|
|
||||||
> The latest version of custom host and guest kernel being tested is
|
|
||||||
> from [TDX Tools - 2023ww01](https://github.com/intel/tdx-tools/commits/2023ww01).
|
|
||||||
|
|
||||||
### TDVF
|
### TDVF
|
||||||
|
|
||||||
@@ -110,6 +106,7 @@ direct kernel boot, which is useful for containers use cases.
|
|||||||
|
|
||||||
To build TDShim from source, it is required to install `Rust`, `NASM`,
|
To build TDShim from source, it is required to install `Rust`, `NASM`,
|
||||||
and `LLVM` first. The TDshim can be build as follows:
|
and `LLVM` first. The TDshim can be build as follows:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/confidential-containers/td-shim
|
git clone https://github.com/confidential-containers/td-shim
|
||||||
cd td-shim
|
cd td-shim
|
||||||
@@ -126,13 +123,14 @@ cargo image --release
|
|||||||
|
|
||||||
If debug logs from the TDShim is needed, here are the alternative
|
If debug logs from the TDShim is needed, here are the alternative
|
||||||
commands:
|
commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo image
|
cargo image
|
||||||
```
|
```
|
||||||
|
|
||||||
And run a TDX VM by providing the firmware previously built, along with a guest
|
And run a TDX VM by providing the firmware previously built, along with a guest
|
||||||
kernel built from the [Guest TDX tree](https://github.com/intel/tdx/tree/guest)
|
kernel built from the [Guest TDX tree](https://github.com/intel/tdx/tree/guest)
|
||||||
or the [TDX Tools](https://github.com/intel/tdx-tools).
|
or the [TDX Linux](https://github.com/intel/tdx-linux).
|
||||||
The appropriate kernel boot options must be provided through the `--cmdline`
|
The appropriate kernel boot options must be provided through the `--cmdline`
|
||||||
option as well.
|
option as well.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# I/O Throttling
|
# I/O Throttling
|
||||||
|
|
||||||
Cloud Hypervisor now supports I/O throttling on virtio-block and virtio-net
|
Cloud Hypervisor now supports I/O throttling on virtio-block and virtio-net
|
||||||
devices. This support is based on the [`rate-limiter` module](https://github.com/firecracker-microvm/firecracker/tree/master/src/rate_limiter)
|
devices. This support is based on the [`rate-limiter` module](https://github.com/firecracker-microvm/firecracker/tree/7a1231b141e958d15d5b2c079dd5e0880528b4b0/src/rate_limiter)
|
||||||
from Firecracker. This document explains the user interface of this
|
from Firecracker. This document explains the user interface of this
|
||||||
feature, and highlights some internal implementations that can help users
|
feature, and highlights some internal implementations that can help users
|
||||||
better understand the expected behavior of I/O throttling in practice.
|
better understand the expected behavior of I/O throttling in practice.
|
||||||
@@ -44,10 +44,12 @@ generally advisable to keep `bw/ops_refill_time` larger than `100 ms`
|
|||||||
expectation ("refill-rate").
|
expectation ("refill-rate").
|
||||||
|
|
||||||
## Rate Limit Groups
|
## Rate Limit Groups
|
||||||
|
|
||||||
It is possible to throttle the aggregate bandwidth or operations
|
It is possible to throttle the aggregate bandwidth or operations
|
||||||
of multiple virtio-blk devices using a `rate_limit_group`. virtio-blk devices may be
|
of multiple virtio-blk devices using a `rate_limit_group`. virtio-blk devices may be
|
||||||
dynamically added and removed from a `rate_limit_group`. The following example
|
dynamically added and removed from a `rate_limit_group`. The following example
|
||||||
demonstrates how to throttle the aggregate bandwidth of two disks to 10 MiB/s.
|
demonstrates how to throttle the aggregate bandwidth of two disks to 10 MiB/s.
|
||||||
|
|
||||||
```
|
```
|
||||||
--disk path=disk0.raw,rate_limit_group=group0 \
|
--disk path=disk0.raw,rate_limit_group=group0 \
|
||||||
path=disk1.raw,rate_limit_group=group0 \
|
path=disk1.raw,rate_limit_group=group0 \
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
The target audience of this document is both:
|
The target audience of this document is both:
|
||||||
|
|
||||||
* Developers who want to understand what log level to use and when,
|
- Developers who want to understand what log level to use and when,
|
||||||
* Users who want to debug issues with running their workloads in Cloud Hypervisor
|
- Users who want to debug issues with running their workloads in Cloud Hypervisor
|
||||||
|
|
||||||
## Control
|
## Control
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ A typical example of where this level of message should be generated is during a
|
|||||||
|
|
||||||
The user should investigate the meaning of this warning and take steps to ensure the correct functionality.
|
The user should investigate the meaning of this warning and take steps to ensure the correct functionality.
|
||||||
|
|
||||||
|
|
||||||
### `info!()`
|
### `info!()`
|
||||||
|
|
||||||
Use `-v` to enable.
|
Use `-v` to enable.
|
||||||
@@ -40,4 +39,4 @@ This level is for the benefit of developers. It should be used for sporadic and
|
|||||||
|
|
||||||
Use `-vv` to enable.
|
Use `-vv` to enable.
|
||||||
|
|
||||||
For the most verbose of logging messages. It is acceptable to "spam" the log with repeated invocations of the same message. This level of logging would be combined with `--log-file`.
|
For the most verbose of logging messages. It is acceptable to "spam" the log with repeated invocations of the same message. This level of logging would be combined with `--log-file`.
|
||||||
|
|||||||
168
docs/riscv.md
Normal file
168
docs/riscv.md
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
# How to build and test Cloud Hypervisor on riscv64
|
||||||
|
|
||||||
|
This document introduces how to build and test Cloud Hypervisor on `riscv64`.
|
||||||
|
All instructions here are tested with Ubuntu 24.04.2 as the host OS.
|
||||||
|
|
||||||
|
## Hardware requirements
|
||||||
|
|
||||||
|
- riscv64 servers (recommended) or development boards equipped with the AIA
|
||||||
|
(Advance Interrupt Architecture) interrupt controller.
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
We create a folder to build and run Cloud Hypervisor at `$HOME/cloud-hypervisor`
|
||||||
|
|
||||||
|
```console
|
||||||
|
export CLOUDH=$HOME/cloud-hypervisor
|
||||||
|
mkdir $CLOUDH
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
You need to install some prerequisite packages to build and test Cloud Hypervisor.
|
||||||
|
|
||||||
|
### Tools
|
||||||
|
|
||||||
|
```console
|
||||||
|
# Install rust tool chain
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
|
# Install the tools used for building guest kernel, EDK2 and converting guest disk
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install git build-essential m4 bison flex uuid-dev qemu-utils
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building Cloud Hypervisor
|
||||||
|
|
||||||
|
```console
|
||||||
|
pushd $CLOUDH
|
||||||
|
git clone https://github.com/cloud-hypervisor/cloud-hypervisor.git
|
||||||
|
cd cloud-hypervisor
|
||||||
|
cargo build
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
### Disk image
|
||||||
|
|
||||||
|
Download the Ubuntu cloud image and convert the image type.
|
||||||
|
|
||||||
|
```console
|
||||||
|
pushd $CLOUDH
|
||||||
|
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-riscv64.img
|
||||||
|
qemu-img convert -p -f qcow2 -O raw jammy-server-cloudimg-riscv64.img jammy-server-cloudimg-riscv64.raw
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
## Direct-kernel booting
|
||||||
|
|
||||||
|
### Building kernel
|
||||||
|
|
||||||
|
```console
|
||||||
|
pushd $CLOUDH
|
||||||
|
git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b ch-6.12.8
|
||||||
|
cd linux
|
||||||
|
make ch_defconfig
|
||||||
|
make -j `nproc`
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
### Booting the guest VM
|
||||||
|
|
||||||
|
```console
|
||||||
|
pushd $CLOUDH
|
||||||
|
sudo $CLOUDH/cloud-hypervisor/target/debug/cloud-hypervisor \
|
||||||
|
--kernel $CLOUDH/linux/arch/riscv64/boot/Image \
|
||||||
|
--disk path=jammy-server-cloudimg-riscv64.raw \
|
||||||
|
--cmdline "console=hvc0 root=/dev/vda rw" \
|
||||||
|
--cpus boot=1 \
|
||||||
|
--memory size=1024M \
|
||||||
|
--seccomp false \
|
||||||
|
--log-file boot.log -vv
|
||||||
|
popd
|
||||||
|
```
|
||||||
|
|
||||||
|
## Virtualized Development Setup
|
||||||
|
|
||||||
|
Since there are few RISC-V development boards on the market and not
|
||||||
|
many details about the AIA interrupt controller featured in product listings,
|
||||||
|
QEMU is a popular and viable choice for creating a RISC-V development environment.
|
||||||
|
Below are the steps used to create a QEMU virtual machine that can be used for
|
||||||
|
cloud-hypervisor RISC-V development:
|
||||||
|
|
||||||
|
### Install Dependencies
|
||||||
|
|
||||||
|
```console
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install opensbi qemu-system-misc u-boot-qemu
|
||||||
|
```
|
||||||
|
|
||||||
|
### Download and Build QEMU (>=v9.2.0)
|
||||||
|
|
||||||
|
Older versions of QEMU may not have support for the AIA
|
||||||
|
interrupt controller.
|
||||||
|
|
||||||
|
```console
|
||||||
|
wget https://download.qemu.org/qemu-10.0.0.tar.xz
|
||||||
|
tar xvJf qemu-10.0.0.tar.xz
|
||||||
|
cd qemu-10.0.0
|
||||||
|
./configure --target-list=riscv64-softmmu
|
||||||
|
make -j $(nproc)
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Download Ubuntu Server Image
|
||||||
|
|
||||||
|
At the time of writing, the best results have been seen with
|
||||||
|
the Ubuntu 24.10 (Oracular) server image. Ex:
|
||||||
|
|
||||||
|
```console
|
||||||
|
wget https://cdimage.ubuntu.com/releases/oracular/release/ubuntu-24.10-preinstalled-server-riscv64.img.xz
|
||||||
|
xz -dk ubuntu-24.10-preinstalled-server-riscv64.img.xz
|
||||||
|
```
|
||||||
|
|
||||||
|
### (Optional) Resize Disk
|
||||||
|
|
||||||
|
If you would like a larger disk, you can resize it now.
|
||||||
|
|
||||||
|
```console
|
||||||
|
qemu-img resize -f raw <ubuntu-image> +5G
|
||||||
|
```
|
||||||
|
|
||||||
|
### Boot VM
|
||||||
|
|
||||||
|
Note the inclusion of the AIA interrupt controller in the
|
||||||
|
invocation.
|
||||||
|
|
||||||
|
```console
|
||||||
|
qemu-system-riscv64 \
|
||||||
|
-machine virt,aia=aplic-imsic \
|
||||||
|
-nographic -m 1G -smp 8 \
|
||||||
|
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
|
||||||
|
-device virtio-rng-pci \
|
||||||
|
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
|
||||||
|
-drive file=<ubuntu-image>,format=raw,if=virtio
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install KVM Kernel Module Within VM
|
||||||
|
KVM is not enabled within the VM by default, so we must enable
|
||||||
|
it manually.
|
||||||
|
|
||||||
|
```console
|
||||||
|
sudo modprobe kvm
|
||||||
|
```
|
||||||
|
|
||||||
|
From this point, you can continue with the above steps from the beginning.
|
||||||
|
|
||||||
|
### Sources
|
||||||
|
|
||||||
|
https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html
|
||||||
|
|
||||||
|
https://canonical-ubuntu-boards.readthedocs-hosted.com/en/latest/how-to/qemu-riscv/#using-the-live-server-image
|
||||||
|
|
||||||
|
https://www.qemu.org/docs/master/specs/riscv-aia.html
|
||||||
|
|
||||||
|
## Known limitations
|
||||||
|
|
||||||
|
- Direct kernel boot only
|
||||||
|
- `64-bit Linux` guest OS only
|
||||||
|
- For more details, see
|
||||||
|
[here](https://github.com/cloud-hypervisor/cloud-hypervisor/issues/6978).
|
||||||
@@ -9,4 +9,4 @@ flume = "0.11.1"
|
|||||||
libc = "0.2.167"
|
libc = "0.2.167"
|
||||||
once_cell = "1.20.2"
|
once_cell = "1.20.2"
|
||||||
serde = { version = "1.0.208", features = ["derive", "rc"] }
|
serde = { version = "1.0.208", features = ["derive", "rc"] }
|
||||||
serde_json = "1.0.120"
|
serde_json = { workspace = true }
|
||||||
|
|||||||
272
fuzz/Cargo.lock
generated
272
fuzz/Cargo.lock
generated
@@ -1,13 +1,13 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "acpi_tables"
|
name = "acpi_tables"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/rust-vmm/acpi_tables?branch=main#849d5950196f66dd10f2b2606d8fe8c7cb39ec24"
|
source = "git+https://github.com/rust-vmm/acpi_tables?branch=main#e08a3f0b0a59b98859dbf59f5aa7fd4d2eb4018a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -61,15 +61,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.87"
|
version = "1.0.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8"
|
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arbitrary"
|
name = "arbitrary"
|
||||||
version = "1.3.2"
|
version = "1.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110"
|
checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arc-swap"
|
name = "arc-swap"
|
||||||
@@ -89,7 +89,7 @@ dependencies = [
|
|||||||
"linux-loader",
|
"linux-loader",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vm-fdt",
|
"vm-fdt",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -103,6 +103,17 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitfield-struct"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2be5a46ba01b60005ae2c51a36a29cfe134bcacae2dd5cedcd4615fbaad1494b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
@@ -111,9 +122,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.6.0"
|
version = "2.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block"
|
name = "block"
|
||||||
@@ -126,7 +137,7 @@ dependencies = [
|
|||||||
"remain",
|
"remain",
|
||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"uuid",
|
"uuid",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
"virtio-queue",
|
"virtio-queue",
|
||||||
@@ -195,13 +206,16 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
|||||||
name = "cloud-hypervisor-fuzz"
|
name = "cloud-hypervisor-fuzz"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"arbitrary",
|
||||||
"block",
|
"block",
|
||||||
"devices",
|
"devices",
|
||||||
"epoll",
|
"epoll",
|
||||||
|
"hypervisor",
|
||||||
"libc",
|
"libc",
|
||||||
"libfuzzer-sys",
|
"libfuzzer-sys",
|
||||||
"linux-loader",
|
"linux-loader",
|
||||||
"micro_http",
|
"micro_http",
|
||||||
|
"mshv-bindings",
|
||||||
"net_util",
|
"net_util",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"seccompiler",
|
"seccompiler",
|
||||||
@@ -288,7 +302,7 @@ dependencies = [
|
|||||||
"acpi_tables",
|
"acpi_tables",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arch",
|
"arch",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"event_monitor",
|
"event_monitor",
|
||||||
"hypervisor",
|
"hypervisor",
|
||||||
@@ -297,7 +311,7 @@ dependencies = [
|
|||||||
"num_enum",
|
"num_enum",
|
||||||
"pci",
|
"pci",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"tpm",
|
"tpm",
|
||||||
"vm-allocator",
|
"vm-allocator",
|
||||||
"vm-device",
|
"vm-device",
|
||||||
@@ -332,7 +346,7 @@ version = "4.3.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74351c3392ea1ff6cd2628e0042d268ac2371cb613252ff383b6dfa50d22fa79"
|
checksum = "74351c3392ea1ff6cd2628e0042d268ac2371cb613252ff383b6dfa50d22fa79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -395,7 +409,7 @@ version = "0.7.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fbcc892208d6998fb57e7c3e05883def66f8130924bba066beb0cfe71566a9f6"
|
checksum = "fbcc892208d6998fb57e7c3e05883def66f8130924bba066beb0cfe71566a9f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"log",
|
"log",
|
||||||
"managed",
|
"managed",
|
||||||
@@ -422,10 +436,22 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi 0.13.3+wasi-0.2.2",
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.14.5"
|
version = "0.14.5"
|
||||||
@@ -437,19 +463,35 @@ name = "hypervisor"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"arc-swap",
|
||||||
|
"bitfield-struct",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"concat-idents",
|
"concat-idents",
|
||||||
|
"iced-x86",
|
||||||
"kvm-bindings",
|
"kvm-bindings",
|
||||||
"kvm-ioctls",
|
"kvm-ioctls",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
|
"mshv-bindings",
|
||||||
|
"open-enum",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
|
"zerocopy 0.8.24",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iced-x86"
|
||||||
|
version = "1.21.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c447cff8c7f384a7d4f741cfcff32f75f3ad02b406432e8d6c878d56b1edf6b"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -506,16 +548,16 @@ checksum = "fa4933174d0cc4b77b958578cd45784071cc5ae212c2d78fbd755aaaa6dfa71a"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
"zerocopy",
|
"zerocopy 0.7.35",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kvm-ioctls"
|
name = "kvm-ioctls"
|
||||||
version = "0.19.0"
|
version = "0.19.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "337d1afa126368bbd6a5c328048f71a69a737e9afe7e436b392a8f8d770c9171"
|
checksum = "e013ae7fcd2c6a8f384104d16afe7ea02969301ea2bb2a56e44b011ebc907cab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"kvm-bindings",
|
"kvm-bindings",
|
||||||
"libc",
|
"libc",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -529,14 +571,20 @@ checksum = "18738c5d4c7fae6727a96adb94722ef7ce82f3eafea0a11777e258a93816537e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"enumflags2",
|
"enumflags2",
|
||||||
"libc",
|
"libc",
|
||||||
"thiserror",
|
"thiserror 1.0.64",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "lazy_static"
|
||||||
version = "0.2.158"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.169"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libfuzzer-sys"
|
name = "libfuzzer-sys"
|
||||||
@@ -589,19 +637,33 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "micro_http"
|
name = "micro_http"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/firecracker-microvm/micro-http?branch=main#8182cd5523b63ceb52ad9d0e7eb6fb95683e6d1b"
|
source = "git+https://github.com/firecracker-microvm/micro-http?branch=main#4f621532e81ee2ad096a9c9592fdacc40d19de48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mshv-bindings"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "577073a0abbf515d17bfe96ca2ce49c44a68454d4179e95ce1244e858a9ebd4e"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"num_enum",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"vmm-sys-util",
|
||||||
|
"zerocopy 0.8.24",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nanorand"
|
name = "nanorand"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
|
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.2.15",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -616,13 +678,13 @@ name = "net_util"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"epoll",
|
"epoll",
|
||||||
"getrandom",
|
"getrandom 0.3.1",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"net_gen",
|
"net_gen",
|
||||||
"rate_limiter",
|
"rate_limiter",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
"virtio-queue",
|
"virtio-queue",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -666,6 +728,26 @@ version = "1.20.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open-enum"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2eb2508143a400b3361812094d987dd5adc81f0f5294a46491be648d6c94cab5"
|
||||||
|
dependencies = [
|
||||||
|
"open-enum-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open-enum-derive"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8d1296fab5231654a5aec8bf9e87ba4e3938c502fc4c3c0425a00084c78944be"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "option_parser"
|
name = "option_parser"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -686,7 +768,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vfio-bindings",
|
"vfio-bindings",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"vfio_user",
|
"vfio_user",
|
||||||
@@ -703,7 +785,7 @@ version = "0.2.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy",
|
"zerocopy 0.7.35",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -717,9 +799,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.86"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -735,20 +817,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.8.5"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_chacha"
|
name = "rand_chacha"
|
||||||
version = "0.3.1"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ppv-lite86",
|
"ppv-lite86",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
@@ -756,11 +838,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_core"
|
name = "rand_core"
|
||||||
version = "0.6.4"
|
version = "0.9.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.3.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -770,7 +852,7 @@ dependencies = [
|
|||||||
"epoll",
|
"epoll",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -799,9 +881,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "seccompiler"
|
name = "seccompiler"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "345a3e4dddf721a478089d4697b83c6c0a8f5bf16086f6c13397e4534eb6e2e5"
|
checksum = "a4ae55de56877481d112a559bbc12667635fdaf5e005712fd4e2b2fa50ffc884"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
@@ -913,9 +995,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.77"
|
version = "2.0.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -928,7 +1010,16 @@ version = "1.0.64"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
|
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl 1.0.64",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "2.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl 2.0.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -942,6 +1033,17 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "2.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "0.6.8"
|
version = "0.6.8"
|
||||||
@@ -968,7 +1070,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"net_gen",
|
"net_gen",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -997,20 +1099,20 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.10.0"
|
version = "1.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314"
|
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.3.1",
|
||||||
"rand",
|
"rand",
|
||||||
"uuid-macro-internal",
|
"uuid-macro-internal",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid-macro-internal"
|
name = "uuid-macro-internal"
|
||||||
version = "1.10.0"
|
version = "1.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee1cd046f83ea2c4e920d6ee9f7c3537ef928d75dce5d84a87c2c5d6b3999a3a"
|
checksum = "9521621447c21497fac206ffe6e9f642f977c4f82eeba9201055f64884d9cb01"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1035,7 +1137,7 @@ dependencies = [
|
|||||||
"kvm-ioctls",
|
"kvm-ioctls",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"thiserror",
|
"thiserror 1.0.64",
|
||||||
"vfio-bindings",
|
"vfio-bindings",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -1052,7 +1154,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror 1.0.64",
|
||||||
"vfio-bindings",
|
"vfio-bindings",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -1063,7 +1165,7 @@ name = "vhost"
|
|||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "git+https://github.com/rust-vmm/vhost?rev=d983ae0#d983ae07f78663b7d24059667376992460b571a2"
|
source = "git+https://github.com/rust-vmm/vhost?rev=d983ae0#d983ae07f78663b7d24059667376992460b571a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
@@ -1097,7 +1199,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"serial_buffer",
|
"serial_buffer",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vhost",
|
"vhost",
|
||||||
"virtio-bindings",
|
"virtio-bindings",
|
||||||
"virtio-queue",
|
"virtio-queue",
|
||||||
@@ -1137,7 +1239,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"hypervisor",
|
"hypervisor",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
@@ -1150,13 +1252,13 @@ source = "git+https://github.com/rust-vmm/vm-fdt?branch=main#ef5bd734f5f66fb0772
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vm-memory"
|
name = "vm-memory"
|
||||||
version = "0.16.0"
|
version = "0.16.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2919f87420b6998a131eb7c78843890295e91a3f8f786ccc925c8d387b75121"
|
checksum = "f1720e7240cdc739f935456eb77f370d7e9b2a3909204da1e2b47bef1137a013"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
"libc",
|
"libc",
|
||||||
"thiserror",
|
"thiserror 1.0.64",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1167,7 +1269,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"vm-memory",
|
"vm-memory",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1188,7 +1290,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
"arch",
|
"arch",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.9.0",
|
||||||
"block",
|
"block",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1214,7 +1316,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serial_buffer",
|
"serial_buffer",
|
||||||
"signal-hook",
|
"signal-hook",
|
||||||
"thiserror",
|
"thiserror 2.0.9",
|
||||||
"tracer",
|
"tracer",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vfio-ioctls",
|
"vfio-ioctls",
|
||||||
@@ -1227,7 +1329,7 @@ dependencies = [
|
|||||||
"vm-migration",
|
"vm-migration",
|
||||||
"vm-virtio",
|
"vm-virtio",
|
||||||
"vmm-sys-util",
|
"vmm-sys-util",
|
||||||
"zerocopy",
|
"zerocopy 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1248,6 +1350,15 @@ version = "0.11.0+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.13.3+wasi-0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen-rt",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.93"
|
version = "0.2.93"
|
||||||
@@ -1407,6 +1518,15 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen-rt"
|
||||||
|
version = "0.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.9.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.7.35"
|
version = "0.7.35"
|
||||||
@@ -1414,7 +1534,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"zerocopy-derive",
|
"zerocopy-derive 0.7.35",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.8.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive 0.8.24",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1427,3 +1556,14 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.8.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|||||||
@@ -9,20 +9,25 @@ version = "0.0.0"
|
|||||||
cargo-fuzz = true
|
cargo-fuzz = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = ["mshv_emulator"]
|
||||||
igvm = []
|
igvm = []
|
||||||
|
mshv_emulator = ["hypervisor/mshv_emulator"]
|
||||||
pvmemcontrol = []
|
pvmemcontrol = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
arbitrary = "1.4.1"
|
||||||
block = { path = "../block" }
|
block = { path = "../block" }
|
||||||
devices = { path = "../devices" }
|
devices = { path = "../devices" }
|
||||||
epoll = "4.3.3"
|
epoll = "4.3.3"
|
||||||
|
hypervisor = { path = "../hypervisor", features = ["mshv_emulator"] }
|
||||||
libc = "0.2.155"
|
libc = "0.2.155"
|
||||||
libfuzzer-sys = "0.4.7"
|
libfuzzer-sys = "0.4.7"
|
||||||
linux-loader = { version = "0.13.0", features = ["bzimage", "elf", "pe"] }
|
linux-loader = { version = "0.13.0", features = ["bzimage", "elf", "pe"] }
|
||||||
micro_http = { git = "https://github.com/firecracker-microvm/micro-http", branch = "main" }
|
micro_http = { git = "https://github.com/firecracker-microvm/micro-http", branch = "main" }
|
||||||
|
mshv-bindings = "0.5.0"
|
||||||
net_util = { path = "../net_util" }
|
net_util = { path = "../net_util" }
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
seccompiler = "0.4.0"
|
seccompiler = "0.5.0"
|
||||||
virtio-devices = { path = "../virtio-devices" }
|
virtio-devices = { path = "../virtio-devices" }
|
||||||
virtio-queue = "0.14.0"
|
virtio-queue = "0.14.0"
|
||||||
vm-device = { path = "../vm-device" }
|
vm-device = { path = "../vm-device" }
|
||||||
@@ -126,8 +131,21 @@ name = "vhdx"
|
|||||||
path = "fuzz_targets/vhdx.rs"
|
path = "fuzz_targets/vhdx.rs"
|
||||||
test = false
|
test = false
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
doc = false
|
||||||
|
name = "vsock"
|
||||||
|
path = "fuzz_targets/vsock.rs"
|
||||||
|
test = false
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
doc = false
|
doc = false
|
||||||
name = "watchdog"
|
name = "watchdog"
|
||||||
path = "fuzz_targets/watchdog.rs"
|
path = "fuzz_targets/watchdog.rs"
|
||||||
test = false
|
test = false
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
doc = false
|
||||||
|
name = "x86emul"
|
||||||
|
path = "fuzz_targets/x86emul.rs"
|
||||||
|
required-features = ["mshv_emulator"]
|
||||||
|
test = false
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -37,11 +37,11 @@ const AVAIL_RING_SIZE: u64 = 6_u64 + 2 * QUEUE_SIZE as u64;
|
|||||||
// Used ring size
|
// Used ring size
|
||||||
const USED_RING_SIZE: u64 = 6_u64 + 8 * QUEUE_SIZE as u64;
|
const USED_RING_SIZE: u64 = 6_u64 + 8 * QUEUE_SIZE as u64;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < QUEUE_DATA_SIZE * QUEUE_NUM
|
if bytes.len() < QUEUE_DATA_SIZE * QUEUE_NUM
|
||||||
|| bytes.len() > (QUEUE_DATA_SIZE * QUEUE_NUM + MEM_SIZE)
|
|| bytes.len() > (QUEUE_DATA_SIZE * QUEUE_NUM + MEM_SIZE)
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut balloon = virtio_devices::Balloon::new(
|
let mut balloon = virtio_devices::Balloon::new(
|
||||||
@@ -61,7 +61,7 @@ fuzz_target!(|bytes| {
|
|||||||
// Setup the guest memory with the input bytes
|
// Setup the guest memory with the input bytes
|
||||||
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -108,6 +108,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and balloon device worker thread to return
|
// Wait for the events to finish and balloon device worker thread to return
|
||||||
balloon.wait_for_epoll_threads();
|
balloon.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use std::{ffi, io};
|
|||||||
|
|
||||||
use block::async_io::DiskFile;
|
use block::async_io::DiskFile;
|
||||||
use block::raw_sync::RawFileDiskSync;
|
use block::raw_sync::RawFileDiskSync;
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{Block, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{Block, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -40,9 +40,9 @@ const AVAIL_RING_SIZE: u64 = 6_u64 + 2 * QUEUE_SIZE as u64;
|
|||||||
// Guest physical address for used ring (requires to 4-bytes aligned)
|
// Guest physical address for used ring (requires to 4-bytes aligned)
|
||||||
const USED_RING_ADDR: u64 = (AVAIL_RING_ADDR + AVAIL_RING_SIZE + 3) & !3_u64;
|
const USED_RING_ADDR: u64 = (AVAIL_RING_ADDR + AVAIL_RING_SIZE + 3) & !3_u64;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < QUEUE_DATA_SIZE || bytes.len() > (QUEUE_DATA_SIZE + MEM_SIZE) {
|
if bytes.len() < QUEUE_DATA_SIZE || bytes.len() > (QUEUE_DATA_SIZE + MEM_SIZE) {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let queue_data = &bytes[..QUEUE_DATA_SIZE];
|
let queue_data = &bytes[..QUEUE_DATA_SIZE];
|
||||||
@@ -76,7 +76,7 @@ fuzz_target!(|bytes| {
|
|||||||
// Setup the guest memory with the input bytes
|
// Setup the guest memory with the input bytes
|
||||||
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -96,6 +96,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and block device worker thread to return
|
// Wait for the events to finish and block device worker thread to return
|
||||||
block.wait_for_epoll_threads();
|
block.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
fn memfd_create(name: &ffi::CStr, flags: u32) -> Result<RawFd, io::Error> {
|
fn memfd_create(name: &ffi::CStr, flags: u32) -> Result<RawFd, io::Error> {
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
use devices::legacy::Cmos;
|
use devices::legacy::Cmos;
|
||||||
use libc::EFD_NONBLOCK;
|
use libc::EFD_NONBLOCK;
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use vm_device::BusDevice;
|
use vm_device::BusDevice;
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
// Need at least 16 bytes for the test
|
// Need at least 16 bytes for the test
|
||||||
if bytes.len() < 16 {
|
if bytes.len() < 16 {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut below_4g = [0u8; 8];
|
let mut below_4g = [0u8; 8];
|
||||||
@@ -46,4 +46,6 @@ fuzz_target!(|bytes| {
|
|||||||
cmos.write(0, offset, &data);
|
cmos.write(0, offset, &data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use std::io::Write;
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -54,12 +54,12 @@ const QUEUE_BYTES_SIZE: usize = align!(
|
|||||||
DESC_TABLE_ALIGN_SIZE
|
DESC_TABLE_ALIGN_SIZE
|
||||||
) as usize;
|
) as usize;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM + CONSOLE_INPUT_SIZE
|
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM + CONSOLE_INPUT_SIZE
|
||||||
|| bytes.len()
|
|| bytes.len()
|
||||||
> (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM + CONSOLE_INPUT_SIZE + MEM_SIZE
|
> (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM + CONSOLE_INPUT_SIZE + MEM_SIZE
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (pipe_rx, mut pipe_tx) = create_pipe().unwrap();
|
let (pipe_rx, mut pipe_tx) = create_pipe().unwrap();
|
||||||
@@ -108,10 +108,10 @@ fuzz_target!(|bytes| {
|
|||||||
.write_slice(queue_bytes, GuestAddress(BASE_VIRT_QUEUE_ADDR))
|
.write_slice(queue_bytes, GuestAddress(BASE_VIRT_QUEUE_ADDR))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -137,6 +137,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and console device worker thread to return
|
// Wait for the events to finish and console device worker thread to return
|
||||||
console.wait_for_epoll_threads();
|
console.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::path::PathBuf;
|
|||||||
use std::sync::mpsc::{channel, Receiver};
|
use std::sync::mpsc::{channel, Receiver};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use micro_http::Request;
|
use micro_http::Request;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use vm_migration::MigratableError;
|
use vm_migration::MigratableError;
|
||||||
@@ -27,9 +27,9 @@ use vmm_sys_util::eventfd::EventFd;
|
|||||||
static ROUTES: Lazy<Vec<&Box<dyn EndpointHandler + Sync + Send>>> =
|
static ROUTES: Lazy<Vec<&Box<dyn EndpointHandler + Sync + Send>>> =
|
||||||
Lazy::new(|| HTTP_ROUTES.routes.values().collect());
|
Lazy::new(|| HTTP_ROUTES.routes.values().collect());
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < 2 {
|
if bytes.len() < 2 {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let route = ROUTES[bytes[0] as usize % ROUTES.len()];
|
let route = ROUTES[bytes[0] as usize % ROUTES.len()];
|
||||||
@@ -53,6 +53,8 @@ fuzz_target!(|bytes| {
|
|||||||
exit_evt.write(1).ok();
|
exit_evt.write(1).ok();
|
||||||
http_receiver_thread.join().unwrap();
|
http_receiver_thread.join().unwrap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
fn generate_request(bytes: &[u8]) -> Option<Request> {
|
fn generate_request(bytes: &[u8]) -> Option<Request> {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -54,11 +54,11 @@ const USED_RING_ADDR: u64 = align!(AVAIL_RING_ADDR + AVAIL_RING_SIZE, USED_RING_
|
|||||||
// Virtio-queue size in bytes
|
// Virtio-queue size in bytes
|
||||||
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE)
|
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE)
|
||||||
|| bytes.len() > (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
|| bytes.len() > (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (mut iommu, _) = virtio_devices::Iommu::new(
|
let (mut iommu, _) = virtio_devices::Iommu::new(
|
||||||
@@ -66,6 +66,7 @@ fuzz_target!(|bytes| {
|
|||||||
SeccompAction::Allow,
|
SeccompAction::Allow,
|
||||||
EventFd::new(EFD_NONBLOCK).unwrap(),
|
EventFd::new(EFD_NONBLOCK).unwrap(),
|
||||||
((MEM_SIZE - IOVA_SPACE_SIZE) as u64, (MEM_SIZE - 1) as u64),
|
((MEM_SIZE - IOVA_SPACE_SIZE) as u64, (MEM_SIZE - 1) as u64),
|
||||||
|
64,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -91,10 +92,10 @@ fuzz_target!(|bytes| {
|
|||||||
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -118,6 +119,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and vIOMMU device worker thread to return
|
// Wait for the events to finish and vIOMMU device worker thread to return
|
||||||
iommu.wait_for_epoll_threads();
|
iommu.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use vm_memory::bitmap::AtomicBitmap;
|
use vm_memory::bitmap::AtomicBitmap;
|
||||||
use vm_memory::GuestAddress;
|
use vm_memory::GuestAddress;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ const MEM_SIZE: usize = 256 * 1024 * 1024;
|
|||||||
// From 'arch::x86_64::layout::CMDLINE_START'
|
// From 'arch::x86_64::layout::CMDLINE_START'
|
||||||
const CMDLINE_START: GuestAddress = GuestAddress(0x20000);
|
const CMDLINE_START: GuestAddress = GuestAddress(0x20000);
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
let payload_config = vmm::vm_config::PayloadConfig {
|
let payload_config = vmm::vm_config::PayloadConfig {
|
||||||
firmware: None,
|
firmware: None,
|
||||||
kernel: None,
|
kernel: None,
|
||||||
@@ -29,9 +29,11 @@ fuzz_target!(|bytes| {
|
|||||||
};
|
};
|
||||||
let kernel_cmdline = match vmm::vm::Vm::generate_cmdline(&payload_config) {
|
let kernel_cmdline = match vmm::vm::Vm::generate_cmdline(&payload_config) {
|
||||||
Ok(cmdline) => cmdline,
|
Ok(cmdline) => cmdline,
|
||||||
_ => return,
|
_ => return Corpus::Reject,
|
||||||
};
|
};
|
||||||
let guest_memory = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
let guest_memory = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
||||||
|
|
||||||
linux_loader::loader::load_cmdline(&guest_memory, CMDLINE_START, &kernel_cmdline).ok();
|
linux_loader::loader::load_cmdline(&guest_memory, CMDLINE_START, &kernel_cmdline).ok();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{BlocksState, Mem, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{BlocksState, Mem, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -57,11 +57,11 @@ const USED_RING_ADDR: u64 = align!(AVAIL_RING_ADDR + AVAIL_RING_SIZE, USED_RING_
|
|||||||
// Virtio-queue size in bytes
|
// Virtio-queue size in bytes
|
||||||
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < VIRTIO_MEM_DATA_SIZE + QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE
|
if bytes.len() < VIRTIO_MEM_DATA_SIZE + QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE
|
||||||
|| bytes.len() > (VIRTIO_MEM_DATA_SIZE + QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
|| bytes.len() > (VIRTIO_MEM_DATA_SIZE + QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let virtio_mem_data = &bytes[..VIRTIO_MEM_DATA_SIZE];
|
let virtio_mem_data = &bytes[..VIRTIO_MEM_DATA_SIZE];
|
||||||
@@ -86,7 +86,7 @@ fuzz_target!(|bytes| {
|
|||||||
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
// Add the memory region for the virtio-mem device
|
// Add the memory region for the virtio-mem device
|
||||||
let mem = mem.insert_region(virtio_mem_region).unwrap();
|
let mem = mem.insert_region(virtio_mem_region).unwrap();
|
||||||
@@ -94,7 +94,7 @@ fuzz_target!(|bytes| {
|
|||||||
.write_slice(mem_bytes, GuestAddress(VIRTIO_MEM_REGION_ADDRESS))
|
.write_slice(mem_bytes, GuestAddress(VIRTIO_MEM_REGION_ADDRESS))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -114,6 +114,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and virtio-mem device worker thread to return
|
// Wait for the events to finish and virtio-mem device worker thread to return
|
||||||
virtio_mem.wait_for_epoll_threads();
|
virtio_mem.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
return Corpus::Keep;
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use std::io::{Read, Write};
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -55,12 +55,12 @@ const QUEUE_BYTES_SIZE: usize = align!(
|
|||||||
DESC_TABLE_ALIGN_SIZE
|
DESC_TABLE_ALIGN_SIZE
|
||||||
) as usize;
|
) as usize;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < TAP_INPUT_SIZE + (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM
|
if bytes.len() < TAP_INPUT_SIZE + (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM
|
||||||
|| bytes.len()
|
|| bytes.len()
|
||||||
> TAP_INPUT_SIZE + (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM + MEM_SIZE
|
> TAP_INPUT_SIZE + (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE) * QUEUE_NUM + MEM_SIZE
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (dummy_tap_frontend, dummy_tap_backend) = create_socketpair().unwrap();
|
let (dummy_tap_frontend, dummy_tap_backend) = create_socketpair().unwrap();
|
||||||
@@ -111,10 +111,10 @@ fuzz_target!(|bytes| {
|
|||||||
.write_slice(queue_bytes, GuestAddress(BASE_VIRT_QUEUE_ADDR))
|
.write_slice(queue_bytes, GuestAddress(BASE_VIRT_QUEUE_ADDR))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -155,6 +155,8 @@ fuzz_target!(|bytes| {
|
|||||||
// Terminate the thread for the dummy tap backend
|
// Terminate the thread for the dummy tap backend
|
||||||
exit_evt.write(1).ok();
|
exit_evt.write(1).ok();
|
||||||
tap_backend_thread.join().unwrap();
|
tap_backend_thread.join().unwrap();
|
||||||
|
|
||||||
|
return Corpus::Keep;
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use std::sync::Arc;
|
|||||||
use std::{ffi, io};
|
use std::{ffi, io};
|
||||||
|
|
||||||
use libc::{MAP_NORESERVE, MAP_PRIVATE, PROT_READ, PROT_WRITE};
|
use libc::{MAP_NORESERVE, MAP_PRIVATE, PROT_READ, PROT_WRITE};
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{Pmem, UserspaceMapping, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{Pmem, UserspaceMapping, VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -35,9 +35,9 @@ const AVAIL_RING_SIZE: u64 = 6_u64 + 2 * QUEUE_SIZE as u64;
|
|||||||
// Guest physical address for used ring (requires to 4-bytes aligned)
|
// Guest physical address for used ring (requires to 4-bytes aligned)
|
||||||
const USED_RING_ADDR: u64 = (AVAIL_RING_ADDR + AVAIL_RING_SIZE + 3) & !3_u64;
|
const USED_RING_ADDR: u64 = (AVAIL_RING_ADDR + AVAIL_RING_SIZE + 3) & !3_u64;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < QUEUE_DATA_SIZE || bytes.len() > (QUEUE_DATA_SIZE + MEM_SIZE) {
|
if bytes.len() < QUEUE_DATA_SIZE || bytes.len() > (QUEUE_DATA_SIZE + MEM_SIZE) {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut pmem = create_dummy_pmem();
|
let mut pmem = create_dummy_pmem();
|
||||||
@@ -50,7 +50,7 @@ fuzz_target!(|bytes| {
|
|||||||
// Setup the guest memory with the input bytes
|
// Setup the guest memory with the input bytes
|
||||||
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -69,6 +69,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and pmem device worker thread to return
|
// Wait for the events to finish and pmem device worker thread to return
|
||||||
pmem.wait_for_epoll_threads();
|
pmem.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
fn memfd_create_with_size(name: &ffi::CStr, flags: u32, size: usize) -> Result<RawFd, io::Error> {
|
fn memfd_create_with_size(name: &ffi::CStr, flags: u32, size: usize) -> Result<RawFd, io::Error> {
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ use std::mem::size_of;
|
|||||||
use std::os::unix::io::{FromRawFd, RawFd};
|
use std::os::unix::io::{FromRawFd, RawFd};
|
||||||
|
|
||||||
use block::qcow::{QcowFile, RawFile};
|
use block::qcow::{QcowFile, RawFile};
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
|
|
||||||
// Take the first 64 bits of data as an address and the next 64 bits as data to
|
// Take the first 64 bits of data as an address and the next 64 bits as data to
|
||||||
// store there. The rest of the data is used as a qcow image.
|
// store there. The rest of the data is used as a qcow image.
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < 16 {
|
if bytes.len() < 16 {
|
||||||
// Need an address and data, each are 8 bytes.
|
// Need an address and data, each are 8 bytes.
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let mut disk_image = Cursor::new(bytes);
|
let mut disk_image = Cursor::new(bytes);
|
||||||
let addr = read_u64(&mut disk_image);
|
let addr = read_u64(&mut disk_image);
|
||||||
@@ -33,6 +33,8 @@ fuzz_target!(|bytes| {
|
|||||||
let _ = qcow.write_all(&value.to_le_bytes());
|
let _ = qcow.write_all(&value.to_le_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
fn read_u64<T: Read>(readable: &mut T) -> u64 {
|
fn read_u64<T: Read>(readable: &mut T) -> u64 {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -52,11 +52,11 @@ const USED_RING_ADDR: u64 = align!(AVAIL_RING_ADDR + AVAIL_RING_SIZE, USED_RING_
|
|||||||
// Virtio-queue size in bytes
|
// Virtio-queue size in bytes
|
||||||
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE)
|
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE)
|
||||||
|| bytes.len() > (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
|| bytes.len() > (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut rng = virtio_devices::Rng::new(
|
let mut rng = virtio_devices::Rng::new(
|
||||||
@@ -86,10 +86,10 @@ fuzz_target!(|bytes| {
|
|||||||
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -108,6 +108,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and rng device worker thread to return
|
// Wait for the events to finish and rng device worker thread to return
|
||||||
rng.wait_for_epoll_threads();
|
rng.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
@@ -9,38 +9,47 @@ use std::io::{self, Read, Seek, SeekFrom, Write};
|
|||||||
use std::os::unix::io::{FromRawFd, RawFd};
|
use std::os::unix::io::{FromRawFd, RawFd};
|
||||||
|
|
||||||
use block::vhdx::Vhdx;
|
use block::vhdx::Vhdx;
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
|
|
||||||
// Populate the corpus directory with a test file:
|
// Populate the corpus directory with a test file:
|
||||||
// truncate -s 16M /tmp/source
|
// truncate -s 16M /tmp/source
|
||||||
// qemu-img convert -O vhdx /tmp/source fuzz/corpus/vhdx/test.vhdx
|
// qemu-img convert -O vhdx /tmp/source fuzz/corpus/vhdx/test.vhdx
|
||||||
// Run with:
|
// Run with:
|
||||||
// cargo fuzz run vhdx -j 32 -- -max_len=16777216
|
// cargo fuzz run vhdx -j 32 -- -max_len=16777216
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
let shm = memfd_create(&ffi::CString::new("fuzz").unwrap(), 0).unwrap();
|
let shm = memfd_create(&ffi::CString::new("fuzz").unwrap(), 0).unwrap();
|
||||||
let mut disk_file: File = unsafe { File::from_raw_fd(shm) };
|
let mut disk_file: File = unsafe { File::from_raw_fd(shm) };
|
||||||
disk_file.write_all(&bytes[..]).unwrap();
|
disk_file.write_all(&bytes[..]).unwrap();
|
||||||
disk_file.seek(SeekFrom::Start(0)).unwrap();
|
disk_file.seek(SeekFrom::Start(0)).unwrap();
|
||||||
|
|
||||||
if let Ok(mut vhdx) = Vhdx::new(disk_file) {
|
let mut vhdx = match Vhdx::new(disk_file) {
|
||||||
if vhdx.seek(SeekFrom::Start(0)).is_ok() {
|
Ok(vhdx) => vhdx,
|
||||||
let mut offset = 0;
|
Err(_) => return Corpus::Reject,
|
||||||
while offset < bytes.len() {
|
};
|
||||||
let mut data = vec![0; 8192];
|
|
||||||
vhdx.read_exact(&mut data).ok();
|
|
||||||
offset += data.len();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if vhdx.seek(SeekFrom::Start(0)).is_ok() {
|
if matches!(vhdx.seek(SeekFrom::Start(0)).is_err(), true) {
|
||||||
let mut offset = 0;
|
return Corpus::Reject;
|
||||||
while offset < bytes.len() {
|
};
|
||||||
let data = vec![0; 8192];
|
|
||||||
vhdx.write_all(&data).ok();
|
let mut offset = 0;
|
||||||
offset += data.len();
|
while offset < bytes.len() {
|
||||||
}
|
let mut data = vec![0; 8192];
|
||||||
}
|
vhdx.read_exact(&mut data).ok();
|
||||||
|
offset += data.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches!(vhdx.seek(SeekFrom::Start(0)).is_err(), true) {
|
||||||
|
return Corpus::Reject;
|
||||||
|
};
|
||||||
|
|
||||||
|
offset = 0;
|
||||||
|
while offset < bytes.len() {
|
||||||
|
let data = vec![0; 8192];
|
||||||
|
vhdx.write_all(&data).ok();
|
||||||
|
offset += data.len();
|
||||||
|
}
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
fn memfd_create(name: &ffi::CStr, flags: u32) -> Result<RawFd, io::Error> {
|
fn memfd_create(name: &ffi::CStr, flags: u32) -> Result<RawFd, io::Error> {
|
||||||
|
|||||||
148
fuzz/fuzz_targets/vsock.rs
Normal file
148
fuzz/fuzz_targets/vsock.rs
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
// Copyright © 2025 Microsoft
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
|
use seccompiler::SeccompAction;
|
||||||
|
use virtio_devices::vsock::tests::TestBackend;
|
||||||
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
|
use virtio_queue::{Queue, QueueT};
|
||||||
|
use vm_memory::bitmap::AtomicBitmap;
|
||||||
|
use vm_memory::{Bytes, GuestAddress, GuestMemoryAtomic};
|
||||||
|
use vmm_sys_util::eventfd::{EventFd, EFD_NONBLOCK};
|
||||||
|
use vmm_sys_util::tempdir::TempDir;
|
||||||
|
|
||||||
|
type GuestMemoryMmap = vm_memory::GuestMemoryMmap<AtomicBitmap>;
|
||||||
|
|
||||||
|
macro_rules! align {
|
||||||
|
($n:expr, $align:expr) => {{
|
||||||
|
$n.div_ceil($align) * $align
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
const QUEUE_DATA_SIZE: usize = 4;
|
||||||
|
const MEM_SIZE: usize = 1 * 1024 * 1024;
|
||||||
|
|
||||||
|
// Max entries in the queue.
|
||||||
|
const QUEUE_SIZE: u16 = 256;
|
||||||
|
// Descriptor table alignment
|
||||||
|
const DESC_TABLE_ALIGN_SIZE: u64 = 16;
|
||||||
|
// Available ring alignment
|
||||||
|
const AVAIL_RING_ALIGN_SIZE: u64 = 2;
|
||||||
|
// Used ring alignment
|
||||||
|
const USED_RING_ALIGN_SIZE: u64 = 4;
|
||||||
|
// Descriptor table size
|
||||||
|
const DESC_TABLE_SIZE: u64 = 16_u64 * QUEUE_SIZE as u64;
|
||||||
|
// Available ring size
|
||||||
|
const AVAIL_RING_SIZE: u64 = 6_u64 + 2 * QUEUE_SIZE as u64;
|
||||||
|
// Used ring size
|
||||||
|
const USED_RING_SIZE: u64 = 6_u64 + 8 * QUEUE_SIZE as u64;
|
||||||
|
|
||||||
|
// Guest memory gap
|
||||||
|
const GUEST_MEM_GAP: u64 = 1 * 1024 * 1024;
|
||||||
|
// Guest physical address for descriptor table.
|
||||||
|
const DESC_TABLE_ADDR: u64 = align!(MEM_SIZE as u64 + GUEST_MEM_GAP, DESC_TABLE_ALIGN_SIZE);
|
||||||
|
// Guest physical address for available ring
|
||||||
|
const AVAIL_RING_ADDR: u64 = align!(DESC_TABLE_ADDR + DESC_TABLE_SIZE, AVAIL_RING_ALIGN_SIZE);
|
||||||
|
// Guest physical address for used ring
|
||||||
|
const USED_RING_ADDR: u64 = align!(AVAIL_RING_ADDR + AVAIL_RING_SIZE, USED_RING_ALIGN_SIZE);
|
||||||
|
// Virtio-queue size in bytes
|
||||||
|
const QUEUE_BYTES_SIZE: usize = (USED_RING_ADDR + USED_RING_SIZE - DESC_TABLE_ADDR) as usize;
|
||||||
|
|
||||||
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
|
if bytes.len() < (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE)
|
||||||
|
|| bytes.len() > (QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE + MEM_SIZE)
|
||||||
|
{
|
||||||
|
return Corpus::Reject;
|
||||||
|
}
|
||||||
|
|
||||||
|
let queue_data = &bytes[..QUEUE_DATA_SIZE];
|
||||||
|
let queue_bytes = &bytes[QUEUE_DATA_SIZE..QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE];
|
||||||
|
let mem_bytes = &bytes[QUEUE_DATA_SIZE + QUEUE_BYTES_SIZE..];
|
||||||
|
|
||||||
|
let q = setup_virt_queue(queue_data.try_into().unwrap());
|
||||||
|
|
||||||
|
let tmp_dir = TempDir::new_with_prefix("/tmp/fuzz_virtio_vsock").unwrap();
|
||||||
|
let vsock_path = tmp_dir.as_path().join("vsock.sock");
|
||||||
|
|
||||||
|
let backend = TestBackend::new();
|
||||||
|
|
||||||
|
// Setup the guest memory with the input bytes
|
||||||
|
let mem = GuestMemoryMmap::from_ranges(&[
|
||||||
|
(GuestAddress(0), MEM_SIZE),
|
||||||
|
(GuestAddress(DESC_TABLE_ADDR), QUEUE_BYTES_SIZE),
|
||||||
|
])
|
||||||
|
.unwrap();
|
||||||
|
if mem
|
||||||
|
.write_slice(queue_bytes, GuestAddress(DESC_TABLE_ADDR))
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
return Corpus::Reject;
|
||||||
|
}
|
||||||
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
|
return Corpus::Reject;
|
||||||
|
}
|
||||||
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
|
let evt = EventFd::new(0).unwrap();
|
||||||
|
let queue_evt = unsafe { EventFd::from_raw_fd(libc::dup(evt.as_raw_fd())) };
|
||||||
|
|
||||||
|
// Kick the 'queue' event before activate the rng device
|
||||||
|
queue_evt.write(1).unwrap();
|
||||||
|
|
||||||
|
let mut vsock = virtio_devices::Vsock::new(
|
||||||
|
"fuzzer_vsock".to_owned(),
|
||||||
|
0,
|
||||||
|
vsock_path,
|
||||||
|
backend,
|
||||||
|
false,
|
||||||
|
SeccompAction::Allow,
|
||||||
|
EventFd::new(EFD_NONBLOCK).unwrap(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
vsock
|
||||||
|
.activate(
|
||||||
|
guest_memory,
|
||||||
|
Arc::new(NoopVirtioInterrupt {}),
|
||||||
|
vec![(0, q, evt)],
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
|
||||||
|
// Wait for the events to finish and vsock device worker thread to return
|
||||||
|
vsock.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
|
});
|
||||||
|
|
||||||
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|
||||||
|
impl VirtioInterrupt for NoopVirtioInterrupt {
|
||||||
|
fn trigger(&self, _int_type: VirtioInterruptType) -> std::result::Result<(), std::io::Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup_virt_queue(bytes: &[u8; QUEUE_DATA_SIZE]) -> Queue {
|
||||||
|
let mut q = Queue::new(QUEUE_SIZE).unwrap();
|
||||||
|
q.set_next_avail(bytes[0] as u16); // 'u8' is enough given the 'QUEUE_SIZE' is small
|
||||||
|
q.set_next_used(bytes[1] as u16);
|
||||||
|
q.set_event_idx(bytes[2] % 2 != 0);
|
||||||
|
q.set_size(bytes[3] as u16 % QUEUE_SIZE);
|
||||||
|
|
||||||
|
q.try_set_desc_table_address(GuestAddress(DESC_TABLE_ADDR))
|
||||||
|
.unwrap();
|
||||||
|
q.try_set_avail_ring_address(GuestAddress(AVAIL_RING_ADDR))
|
||||||
|
.unwrap();
|
||||||
|
q.try_set_used_ring_address(GuestAddress(USED_RING_ADDR))
|
||||||
|
.unwrap();
|
||||||
|
q.set_ready(true);
|
||||||
|
|
||||||
|
q
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use seccompiler::SeccompAction;
|
use seccompiler::SeccompAction;
|
||||||
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
use virtio_devices::{VirtioDevice, VirtioInterrupt, VirtioInterruptType};
|
||||||
use virtio_queue::{Queue, QueueT};
|
use virtio_queue::{Queue, QueueT};
|
||||||
@@ -30,9 +30,9 @@ const AVAIL_RING_SIZE: u64 = 6_u64 + 2 * QUEUE_SIZE as u64;
|
|||||||
// Guest physical address for used ring (requires to 4-bytes aligned)
|
// Guest physical address for used ring (requires to 4-bytes aligned)
|
||||||
const USED_RING_ADDR: u64 = (AVAIL_RING_ADDR + AVAIL_RING_SIZE + 3) & !3_u64;
|
const USED_RING_ADDR: u64 = (AVAIL_RING_ADDR + AVAIL_RING_SIZE + 3) & !3_u64;
|
||||||
|
|
||||||
fuzz_target!(|bytes| {
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
if bytes.len() < QUEUE_DATA_SIZE || bytes.len() > (QUEUE_DATA_SIZE + MEM_SIZE) {
|
if bytes.len() < QUEUE_DATA_SIZE || bytes.len() > (QUEUE_DATA_SIZE + MEM_SIZE) {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut watchdog = virtio_devices::Watchdog::new(
|
let mut watchdog = virtio_devices::Watchdog::new(
|
||||||
@@ -53,7 +53,7 @@ fuzz_target!(|bytes| {
|
|||||||
// Setup the guest memory with the input bytes
|
// Setup the guest memory with the input bytes
|
||||||
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
let mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
||||||
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
if mem.write_slice(mem_bytes, GuestAddress(0 as u64)).is_err() {
|
||||||
return;
|
return Corpus::Reject;
|
||||||
}
|
}
|
||||||
let guest_memory = GuestMemoryAtomic::new(mem);
|
let guest_memory = GuestMemoryAtomic::new(mem);
|
||||||
|
|
||||||
@@ -73,6 +73,8 @@ fuzz_target!(|bytes| {
|
|||||||
|
|
||||||
// Wait for the events to finish and watchdog device worker thread to return
|
// Wait for the events to finish and watchdog device worker thread to return
|
||||||
watchdog.wait_for_epoll_threads();
|
watchdog.wait_for_epoll_threads();
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
});
|
});
|
||||||
|
|
||||||
pub struct NoopVirtioInterrupt {}
|
pub struct NoopVirtioInterrupt {}
|
||||||
|
|||||||
153
fuzz/fuzz_targets/x86emul.rs
Normal file
153
fuzz/fuzz_targets/x86emul.rs
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
// Copyright © 2025 Microsoft Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use hypervisor::arch::emulator::{PlatformEmulator, PlatformError};
|
||||||
|
use hypervisor::arch::x86::emulator::{Emulator, EmulatorCpuState};
|
||||||
|
use hypervisor::arch::x86::{DescriptorTable, SegmentRegister, SpecialRegisters};
|
||||||
|
use hypervisor::StandardRegisters;
|
||||||
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct EmulatorContext {
|
||||||
|
state: EmulatorCpuState,
|
||||||
|
memory: [u8; 8],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlatformEmulator for EmulatorContext {
|
||||||
|
type CpuState = EmulatorCpuState;
|
||||||
|
|
||||||
|
fn read_memory(&self, _gva: u64, data: &mut [u8]) -> Result<(), PlatformError> {
|
||||||
|
data.copy_from_slice(&self.memory[..data.len()]);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_memory(&mut self, _gva: u64, _data: &[u8]) -> Result<(), PlatformError> {
|
||||||
|
// Discard writes
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cpu_state(&self, _cpu_id: usize) -> Result<Self::CpuState, PlatformError> {
|
||||||
|
Ok(self.state.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_cpu_state(&self, _cpu_id: usize, _state: Self::CpuState) -> Result<(), PlatformError> {
|
||||||
|
// Ignore
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fetch(&self, _ip: u64, _data: &mut [u8]) -> Result<(), PlatformError> {
|
||||||
|
// The fuzzer already provides 16 bytes of data, we don't need to fetch anything
|
||||||
|
panic!("fetch should not be called");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fuzz_target!(|bytes: &[u8]| -> Corpus {
|
||||||
|
let (mut ctx, insn) = match generate_context_and_instruction(bytes) {
|
||||||
|
Ok((ctx, insn)) => (ctx, insn),
|
||||||
|
Err(_) => return Corpus::Reject,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut e = Emulator::new(&mut ctx);
|
||||||
|
|
||||||
|
if e.emulate_first_insn(0, &insn).is_err() {
|
||||||
|
return Corpus::Reject;
|
||||||
|
}
|
||||||
|
|
||||||
|
Corpus::Keep
|
||||||
|
});
|
||||||
|
|
||||||
|
// Helper functions to generate structures from fuzzer input below
|
||||||
|
|
||||||
|
fn generate_segment_register(
|
||||||
|
u: &mut arbitrary::Unstructured<'_>,
|
||||||
|
) -> arbitrary::Result<SegmentRegister> {
|
||||||
|
Ok(SegmentRegister {
|
||||||
|
base: u.arbitrary()?,
|
||||||
|
limit: u.arbitrary()?,
|
||||||
|
selector: u.arbitrary()?,
|
||||||
|
avl: u.arbitrary()?,
|
||||||
|
dpl: u.arbitrary()?,
|
||||||
|
db: u.arbitrary()?,
|
||||||
|
g: u.arbitrary()?,
|
||||||
|
l: u.arbitrary()?,
|
||||||
|
present: u.arbitrary()?,
|
||||||
|
s: u.arbitrary()?,
|
||||||
|
type_: u.arbitrary()?,
|
||||||
|
unusable: u.arbitrary()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generate_descriptor_table(
|
||||||
|
u: &mut arbitrary::Unstructured<'_>,
|
||||||
|
) -> arbitrary::Result<DescriptorTable> {
|
||||||
|
Ok(DescriptorTable {
|
||||||
|
base: u.arbitrary()?,
|
||||||
|
limit: u.arbitrary()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generate_context_and_instruction(
|
||||||
|
bytes: &[u8],
|
||||||
|
) -> arbitrary::Result<(EmulatorContext, [u8; 16])> {
|
||||||
|
let mut u = arbitrary::Unstructured::new(bytes);
|
||||||
|
|
||||||
|
let mut regs = mshv_bindings::StandardRegisters {
|
||||||
|
rax: u.arbitrary()?,
|
||||||
|
rbx: u.arbitrary()?,
|
||||||
|
rcx: u.arbitrary()?,
|
||||||
|
rdx: u.arbitrary()?,
|
||||||
|
rsi: u.arbitrary()?,
|
||||||
|
rdi: u.arbitrary()?,
|
||||||
|
rsp: u.arbitrary()?,
|
||||||
|
rbp: u.arbitrary()?,
|
||||||
|
r8: u.arbitrary()?,
|
||||||
|
r9: u.arbitrary()?,
|
||||||
|
r10: u.arbitrary()?,
|
||||||
|
r11: u.arbitrary()?,
|
||||||
|
r12: u.arbitrary()?,
|
||||||
|
r13: u.arbitrary()?,
|
||||||
|
r14: u.arbitrary()?,
|
||||||
|
r15: u.arbitrary()?,
|
||||||
|
rip: u.arbitrary()?,
|
||||||
|
rflags: u.arbitrary()?,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cap RCX to avoid looping for too long for reps instructions.
|
||||||
|
regs.rcx &= 0xFFFFu64;
|
||||||
|
|
||||||
|
let regs = StandardRegisters::Mshv(regs);
|
||||||
|
|
||||||
|
let sregs = SpecialRegisters {
|
||||||
|
cs: generate_segment_register(&mut u)?,
|
||||||
|
ds: generate_segment_register(&mut u)?,
|
||||||
|
es: generate_segment_register(&mut u)?,
|
||||||
|
fs: generate_segment_register(&mut u)?,
|
||||||
|
gs: generate_segment_register(&mut u)?,
|
||||||
|
ss: generate_segment_register(&mut u)?,
|
||||||
|
tr: generate_segment_register(&mut u)?,
|
||||||
|
ldt: generate_segment_register(&mut u)?,
|
||||||
|
gdt: generate_descriptor_table(&mut u)?,
|
||||||
|
idt: generate_descriptor_table(&mut u)?,
|
||||||
|
cr0: u.arbitrary()?,
|
||||||
|
cr2: u.arbitrary()?,
|
||||||
|
cr3: u.arbitrary()?,
|
||||||
|
cr4: u.arbitrary()?,
|
||||||
|
cr8: u.arbitrary()?,
|
||||||
|
efer: u.arbitrary()?,
|
||||||
|
apic_base: u.arbitrary()?,
|
||||||
|
interrupt_bitmap: u.arbitrary()?,
|
||||||
|
};
|
||||||
|
|
||||||
|
let memory = u.arbitrary::<[u8; 8]>()?;
|
||||||
|
let insn = u.arbitrary::<[u8; 16]>()?;
|
||||||
|
|
||||||
|
let ctx = EmulatorContext {
|
||||||
|
state: EmulatorCpuState { regs, sregs },
|
||||||
|
memory,
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok((ctx, insn))
|
||||||
|
}
|
||||||
@@ -7,18 +7,20 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
kvm = ["kvm-bindings", "kvm-ioctls", "vfio-ioctls/kvm"]
|
kvm = ["kvm-bindings", "kvm-ioctls", "vfio-ioctls/kvm"]
|
||||||
mshv = ["iced-x86", "mshv-bindings", "mshv-ioctls", "vfio-ioctls/mshv"]
|
mshv = ["mshv-bindings", "mshv-ioctls", "mshv_emulator", "vfio-ioctls/mshv"]
|
||||||
|
mshv_emulator = ["iced-x86", "mshv-bindings"]
|
||||||
sev_snp = ["igvm", "igvm_defs"]
|
sev_snp = ["igvm", "igvm_defs"]
|
||||||
tdx = []
|
tdx = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.94"
|
anyhow = "1.0.94"
|
||||||
arc-swap = "1.7.1"
|
arc-swap = "1.7.1"
|
||||||
|
bitfield-struct = "0.10.1"
|
||||||
byteorder = "1.5.0"
|
byteorder = "1.5.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
concat-idents = "1.1.5"
|
concat-idents = "1.1.5"
|
||||||
igvm = { version = "0.3.3", optional = true }
|
igvm = { workspace = true, optional = true }
|
||||||
igvm_defs = { version = "0.3.1", optional = true }
|
igvm_defs = { workspace = true, optional = true }
|
||||||
kvm-bindings = { workspace = true, optional = true, features = ["serde"] }
|
kvm-bindings = { workspace = true, optional = true, features = ["serde"] }
|
||||||
kvm-ioctls = { workspace = true, optional = true }
|
kvm-ioctls = { workspace = true, optional = true }
|
||||||
libc = "0.2.167"
|
libc = "0.2.167"
|
||||||
@@ -28,11 +30,13 @@ mshv-bindings = { workspace = true, features = [
|
|||||||
"with-serde",
|
"with-serde",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
mshv-ioctls = { workspace = true, optional = true }
|
mshv-ioctls = { workspace = true, optional = true }
|
||||||
|
open-enum = "0.5.2"
|
||||||
serde = { version = "1.0.208", features = ["derive", "rc"] }
|
serde = { version = "1.0.208", features = ["derive", "rc"] }
|
||||||
|
serde_json = { workspace = true }
|
||||||
serde_with = { version = "3.9.0", default-features = false, features = [
|
serde_with = { version = "3.9.0", default-features = false, features = [
|
||||||
"macros",
|
"macros",
|
||||||
] }
|
] }
|
||||||
thiserror = "1.0.62"
|
thiserror = "2.0.6"
|
||||||
vfio-ioctls = { workspace = true, default-features = false }
|
vfio-ioctls = { workspace = true, default-features = false }
|
||||||
vm-memory = { workspace = true, features = [
|
vm-memory = { workspace = true, features = [
|
||||||
"backend-atomic",
|
"backend-atomic",
|
||||||
@@ -40,10 +44,20 @@ vm-memory = { workspace = true, features = [
|
|||||||
"backend-mmap",
|
"backend-mmap",
|
||||||
] }
|
] }
|
||||||
vmm-sys-util = { workspace = true, features = ["with-serde"] }
|
vmm-sys-util = { workspace = true, features = ["with-serde"] }
|
||||||
|
zerocopy = { version = "0.8.24", features = ["derive"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")'.dependencies.iced-x86]
|
[target.'cfg(target_arch = "x86_64")'.dependencies.iced-x86]
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["decoder", "fast_fmt", "instr_info", "op_code_info", "std"]
|
features = [
|
||||||
|
"decoder",
|
||||||
|
"instr_info",
|
||||||
|
"no_d3now",
|
||||||
|
"no_evex",
|
||||||
|
"no_vex",
|
||||||
|
"no_xop",
|
||||||
|
"op_code_info",
|
||||||
|
"std",
|
||||||
|
]
|
||||||
optional = true
|
optional = true
|
||||||
version = "1.21.0"
|
version = "1.21.0"
|
||||||
|
|
||||||
|
|||||||
@@ -5,22 +5,25 @@
|
|||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::result;
|
use std::result;
|
||||||
|
|
||||||
|
use serde::de::Error as SerdeError;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::{CpuState, GicState, HypervisorDeviceError, HypervisorVmError};
|
use crate::{CpuState, HypervisorDeviceError, HypervisorVmError};
|
||||||
|
|
||||||
/// Errors thrown while setting up the VGIC.
|
/// Errors thrown while setting up the VGIC.
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Error while calling KVM ioctl for setting up the global interrupt controller.
|
/// Error while calling KVM ioctl for setting up the global interrupt controller.
|
||||||
#[error("Failed creating GIC device: {0}")]
|
#[error("Failed creating GIC device: {0}")]
|
||||||
CreateGic(HypervisorVmError),
|
CreateGic(#[source] HypervisorVmError),
|
||||||
/// Error while setting device attributes for the GIC.
|
/// Error while setting device attributes for the GIC.
|
||||||
#[error("Failed setting device attributes for the GIC: {0}")]
|
#[error("Failed setting device attributes for the GIC: {0}")]
|
||||||
SetDeviceAttribute(HypervisorDeviceError),
|
SetDeviceAttribute(#[source] HypervisorDeviceError),
|
||||||
/// Error while getting device attributes for the GIC.
|
/// Error while getting device attributes for the GIC.
|
||||||
#[error("Failed getting device attributes for the GIC: {0}")]
|
#[error("Failed getting device attributes for the GIC: {0}")]
|
||||||
GetDeviceAttribute(HypervisorDeviceError),
|
GetDeviceAttribute(#[source] HypervisorDeviceError),
|
||||||
}
|
}
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
@@ -36,6 +39,56 @@ pub struct VgicConfig {
|
|||||||
pub nr_irqs: u32,
|
pub nr_irqs: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize)]
|
||||||
|
pub enum GicState {
|
||||||
|
#[cfg(feature = "kvm")]
|
||||||
|
Kvm(crate::kvm::aarch64::gic::Gicv3ItsState),
|
||||||
|
#[cfg(feature = "mshv")]
|
||||||
|
MshvGicV2M(crate::mshv::aarch64::gic::MshvGicV2MState),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'de> Deserialize<'de> for GicState {
|
||||||
|
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||||
|
where
|
||||||
|
D: serde::Deserializer<'de>,
|
||||||
|
{
|
||||||
|
// GicStateDefaultDeserialize is a helper enum that mirrors GicState but also derives the Deserialize trait.
|
||||||
|
// This enables backward-compatible deserialization of GicState, facilitating live-upgrade scenarios.
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub enum GicStateDefaultDeserialize {
|
||||||
|
#[cfg(feature = "kvm")]
|
||||||
|
Kvm(crate::kvm::aarch64::gic::Gicv3ItsState),
|
||||||
|
#[cfg(feature = "mshv")]
|
||||||
|
MshvGicV2M(crate::mshv::aarch64::gic::MshvGicV2MState),
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
assert!(
|
||||||
|
std::mem::size_of::<GicStateDefaultDeserialize>()
|
||||||
|
== std::mem::size_of::<GicState>()
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
|
||||||
|
|
||||||
|
#[cfg(feature = "kvm")]
|
||||||
|
if let Ok(gicv3_its_state) =
|
||||||
|
crate::kvm::aarch64::gic::Gicv3ItsState::deserialize(value.clone())
|
||||||
|
{
|
||||||
|
return Ok(GicState::Kvm(gicv3_its_state));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Ok(gic_state_de) = GicStateDefaultDeserialize::deserialize(value.clone()) {
|
||||||
|
return match gic_state_de {
|
||||||
|
#[cfg(feature = "kvm")]
|
||||||
|
GicStateDefaultDeserialize::Kvm(state) => Ok(GicState::Kvm(state)),
|
||||||
|
#[cfg(feature = "mshv")]
|
||||||
|
GicStateDefaultDeserialize::MshvGicV2M(state) => Ok(GicState::MshvGicV2M(state)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Err(SerdeError::custom("Failed to deserialize GicState"))
|
||||||
|
}
|
||||||
|
}
|
||||||
/// Hypervisor agnostic interface for a virtualized GIC
|
/// Hypervisor agnostic interface for a virtualized GIC
|
||||||
pub trait Vgic: Send + Sync {
|
pub trait Vgic: Send + Sync {
|
||||||
/// Returns the fdt compatibility property of the device
|
/// Returns the fdt compatibility property of the device
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
pub mod gic;
|
pub mod gic;
|
||||||
|
pub mod regs;
|
||||||
|
|||||||
228
hypervisor/src/arch/aarch64/regs.rs
Normal file
228
hypervisor/src/arch/aarch64/regs.rs
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
|
||||||
|
//
|
||||||
|
// Copyright © 2025, Microsoft Corporation
|
||||||
|
//
|
||||||
|
|
||||||
|
use bitfield_struct::bitfield;
|
||||||
|
use open_enum::open_enum;
|
||||||
|
use zerocopy::{FromBytes, IntoBytes};
|
||||||
|
|
||||||
|
/// ESR_EL2, exception syndrome register.
|
||||||
|
#[bitfield(u64)]
|
||||||
|
#[derive(IntoBytes, FromBytes)]
|
||||||
|
pub struct EsrEl2 {
|
||||||
|
#[bits(25)]
|
||||||
|
pub iss: u32,
|
||||||
|
pub il: bool,
|
||||||
|
#[bits(6)]
|
||||||
|
pub ec: u8,
|
||||||
|
#[bits(5)]
|
||||||
|
pub iss2: u8,
|
||||||
|
#[bits(27)]
|
||||||
|
_rsvd: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[open_enum]
|
||||||
|
#[derive(Debug)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum FaultStatusCode {
|
||||||
|
ADDRESS_SIZE_FAULT_LEVEL0 = 0b000000,
|
||||||
|
ADDRESS_SIZE_FAULT_LEVEL1 = 0b000001,
|
||||||
|
ADDRESS_SIZE_FAULT_LEVEL2 = 0b000010,
|
||||||
|
ADDRESS_SIZE_FAULT_LEVEL3 = 0b000011,
|
||||||
|
TRANSLATION_FAULT_LEVEL0 = 0b000100,
|
||||||
|
TRANSLATION_FAULT_LEVEL1 = 0b000101,
|
||||||
|
TRANSLATION_FAULT_LEVEL2 = 0b000110,
|
||||||
|
TRANSLATION_FAULT_LEVEL3 = 0b000111,
|
||||||
|
ACCESS_FLAG_FAULT_LEVEL0 = 0b001000,
|
||||||
|
ACCESS_FLAG_FAULT_LEVEL1 = 0b001001,
|
||||||
|
ACCESS_FLAG_FAULT_LEVEL2 = 0b001010,
|
||||||
|
ACCESS_FLAG_FAULT_LEVEL3 = 0b001011,
|
||||||
|
PERMISSION_FAULT_LEVEL0 = 0b001100,
|
||||||
|
PERMISSION_FAULT_LEVEL1 = 0b001101,
|
||||||
|
PERMISSION_FAULT_LEVEL2 = 0b001110,
|
||||||
|
PERMISSION_FAULT_LEVEL3 = 0b001111,
|
||||||
|
SYNCHRONOUS_EXTERNAL_ABORT = 0b010000,
|
||||||
|
SYNC_TAG_CHECK_FAULT = 0b010001,
|
||||||
|
SEA_TTW_LEVEL_NEG1 = 0b010011,
|
||||||
|
SEA_TTW_LEVEL0 = 0b010100,
|
||||||
|
SEA_TTW_LEVEL1 = 0b010101,
|
||||||
|
SEA_TTW_LEVEL2 = 0b010110,
|
||||||
|
SEA_TTW_LEVEL3 = 0b010111,
|
||||||
|
ECC_PARITY = 0b011000,
|
||||||
|
ECC_PARITY_TTW_LEVEL_NEG1 = 0b011011,
|
||||||
|
ECC_PARITY_TTW_LEVEL0 = 0b011100,
|
||||||
|
ECC_PARITY_TTW_LEVEL1 = 0b011101,
|
||||||
|
ECC_PARITY_TTW_LEVEL2 = 0b011110,
|
||||||
|
ECC_PARITY_TTW_LEVEL3 = 0b011111,
|
||||||
|
/// Valid only for data fault.
|
||||||
|
ALIGNMENT_FAULT = 0b100001,
|
||||||
|
/// Valid only for instruction fault.
|
||||||
|
GRANULE_PROTECTION_FAULT_LEVEL_NEG = 0b100011,
|
||||||
|
/// Valid only for instruction fault.
|
||||||
|
GRANULE_PROTECTION_FAULT_LEVEL0 = 0b100100,
|
||||||
|
/// Valid only for instruction fault.
|
||||||
|
GRANULE_PROTECTION_FAULT_LEVEL1 = 0b100101,
|
||||||
|
/// Valid only for instruction fault.
|
||||||
|
GRANULE_PROTECTION_FAULT_LEVEL2 = 0b100110,
|
||||||
|
/// Valid only for instruction fault.
|
||||||
|
GRANULE_PROTECTION_FAULT_LEVEL3 = 0b100111,
|
||||||
|
ADDRESS_SIZE_FAULT_LEVEL_NEG1 = 0b101001,
|
||||||
|
TRANSLATION_FAULT_LEVEL_NEG1 = 0b101011,
|
||||||
|
TLB_CONFLICT_ABORT = 0b110000,
|
||||||
|
UNSUPPORTED_HW_UPDATE_FAULT = 0b110001,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Support for embedding within IssDataAbort/IssInstructionAbort
|
||||||
|
impl FaultStatusCode {
|
||||||
|
const fn from_bits(bits: u32) -> Self {
|
||||||
|
FaultStatusCode((bits & 0x3f) as u8)
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn into_bits(self) -> u32 {
|
||||||
|
self.0 as u32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bitfield(u32)]
|
||||||
|
pub struct IssDataAbort {
|
||||||
|
#[bits(6)]
|
||||||
|
pub dfsc: FaultStatusCode,
|
||||||
|
// Write operation (write not read)
|
||||||
|
pub wnr: bool,
|
||||||
|
pub s1ptw: bool,
|
||||||
|
pub cm: bool,
|
||||||
|
pub ea: bool,
|
||||||
|
/// FAR not valid
|
||||||
|
pub fnv: bool,
|
||||||
|
#[bits(2)]
|
||||||
|
pub set: u8,
|
||||||
|
pub vncr: bool,
|
||||||
|
/// Acquire/release
|
||||||
|
pub ar: bool,
|
||||||
|
/// (ISV==1) 64-bit, (ISV==0) FAR is approximate
|
||||||
|
pub sf: bool,
|
||||||
|
#[bits(5)]
|
||||||
|
/// Register index.
|
||||||
|
pub srt: u8,
|
||||||
|
/// Sign extended.
|
||||||
|
pub sse: bool,
|
||||||
|
#[bits(2)]
|
||||||
|
/// access width log2
|
||||||
|
pub sas: u8,
|
||||||
|
/// Valid ESREL2 iss field.
|
||||||
|
pub isv: bool,
|
||||||
|
#[bits(7)]
|
||||||
|
_unused: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[open_enum]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum ExceptionClass {
|
||||||
|
UNKNOWN = 0b000000,
|
||||||
|
WFI = 0b000001,
|
||||||
|
MCR_MRC_COPROC_15 = 0b000011,
|
||||||
|
MCRR_MRRC_COPROC_15 = 0b000100,
|
||||||
|
MCR_MRC_COPROC_14 = 0b000101,
|
||||||
|
LDC_STC = 0b000110,
|
||||||
|
FP_OR_SIMD = 0b000111,
|
||||||
|
VMRS = 0b001000,
|
||||||
|
POINTER_AUTH_HCR_OR_SCR = 0b001001,
|
||||||
|
LS64 = 0b001010,
|
||||||
|
MRRC_COPROC_14 = 0b001100,
|
||||||
|
BRANCH_TARGET = 0b001101,
|
||||||
|
ILLEGAL_STATE = 0b001110,
|
||||||
|
SVC32 = 0b010001,
|
||||||
|
HVC32 = 0b010010,
|
||||||
|
SMC32 = 0b010011,
|
||||||
|
SVC = 0b010101,
|
||||||
|
HVC = 0b010110,
|
||||||
|
SMC = 0b010111,
|
||||||
|
SYSTEM = 0b011000,
|
||||||
|
SVE = 0b011001,
|
||||||
|
ERET = 0b011010,
|
||||||
|
TSTART = 0b011011,
|
||||||
|
POINTER_AUTH = 0b011100,
|
||||||
|
SME = 0b011101,
|
||||||
|
INSTRUCTION_ABORT_LOWER = 0b100000,
|
||||||
|
INSTRUCTION_ABORT = 0b100001,
|
||||||
|
PC_ALIGNMENT = 0b100010,
|
||||||
|
DATA_ABORT_LOWER = 0b100100,
|
||||||
|
DATA_ABORT = 0b100101,
|
||||||
|
SP_ALIGNMENT_FAULT = 0b100110,
|
||||||
|
MEMORY_OP = 0b100111,
|
||||||
|
FP_EXCEPTION_32 = 0b101000,
|
||||||
|
FP_EXCEPTION_64 = 0b101100,
|
||||||
|
SERROR = 0b101111,
|
||||||
|
BREAKPOINT_LOWER = 0b110000,
|
||||||
|
BREAKPOINT = 0b110001,
|
||||||
|
STEP_LOWER = 0b110010,
|
||||||
|
STEP = 0b110011,
|
||||||
|
WATCHPOINT_LOWER = 0b110100,
|
||||||
|
WATCHPOINT = 0b110101,
|
||||||
|
BRK32 = 0b111000,
|
||||||
|
VECTOR_CATCH_32 = 0b111010,
|
||||||
|
BRK = 0b111100,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
// PSR (Processor State Register) bits.
|
||||||
|
// Taken from arch/arm64/include/uapi/asm/ptrace.h.
|
||||||
|
const PSR_MODE_EL1h: u64 = 0x0000_0005;
|
||||||
|
const PSR_F_BIT: u64 = 0x0000_0040;
|
||||||
|
const PSR_I_BIT: u64 = 0x0000_0080;
|
||||||
|
const PSR_A_BIT: u64 = 0x0000_0100;
|
||||||
|
const PSR_D_BIT: u64 = 0x0000_0200;
|
||||||
|
// Taken from arch/arm64/kvm/inject_fault.c.
|
||||||
|
pub const PSTATE_FAULT_BITS_64: u64 = PSR_MODE_EL1h | PSR_A_BIT | PSR_F_BIT | PSR_I_BIT | PSR_D_BIT;
|
||||||
|
|
||||||
|
// AArch64 system register encoding:
|
||||||
|
// See https://developer.arm.com/documentation/ddi0487 (chapter D12)
|
||||||
|
//
|
||||||
|
// 31 22 21 20 19 18 16 15 12 11 8 7 5 4 0
|
||||||
|
// +----------+---+-----+-----+-----+-----+-----+----+
|
||||||
|
// |1101010100| L | op0 | op1 | CRn | CRm | op2 | Rt |
|
||||||
|
// +----------+---+-----+-----+-----+-----+-----+----+
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
// - L and Rt are reserved as implementation defined fields, ignored.
|
||||||
|
|
||||||
|
const SYSREG_HEAD: u32 = 0b1101010100u32 << 22;
|
||||||
|
const SYSREG_OP0_SHIFT: u32 = 19;
|
||||||
|
const SYSREG_OP0_MASK: u32 = 0b11u32 << 19;
|
||||||
|
const SYSREG_OP1_SHIFT: u32 = 16;
|
||||||
|
const SYSREG_OP1_MASK: u32 = 0b111u32 << 16;
|
||||||
|
const SYSREG_CRN_SHIFT: u32 = 12;
|
||||||
|
const SYSREG_CRN_MASK: u32 = 0b1111u32 << 12;
|
||||||
|
const SYSREG_CRM_SHIFT: u32 = 8;
|
||||||
|
const SYSREG_CRM_MASK: u32 = 0b1111u32 << 8;
|
||||||
|
const SYSREG_OP2_SHIFT: u32 = 5;
|
||||||
|
const SYSREG_OP2_MASK: u32 = 0b111u32 << 5;
|
||||||
|
|
||||||
|
/// Define the ID of system registers
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! arm64_sys_reg {
|
||||||
|
($name: tt, $op0: tt, $op1: tt, $crn: tt, $crm: tt, $op2: tt) => {
|
||||||
|
pub const $name: u32 = SYSREG_HEAD
|
||||||
|
| ((($op0 as u32) << SYSREG_OP0_SHIFT) & SYSREG_OP0_MASK as u32)
|
||||||
|
| ((($op1 as u32) << SYSREG_OP1_SHIFT) & SYSREG_OP1_MASK as u32)
|
||||||
|
| ((($crn as u32) << SYSREG_CRN_SHIFT) & SYSREG_CRN_MASK as u32)
|
||||||
|
| ((($crm as u32) << SYSREG_CRM_SHIFT) & SYSREG_CRM_MASK as u32)
|
||||||
|
| ((($op2 as u32) << SYSREG_OP2_SHIFT) & SYSREG_OP2_MASK as u32);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
arm64_sys_reg!(MPIDR_EL1, 3, 0, 0, 0, 5);
|
||||||
|
arm64_sys_reg!(ID_AA64MMFR0_EL1, 3, 0, 0, 7, 0);
|
||||||
|
arm64_sys_reg!(TTBR1_EL1, 3, 0, 2, 0, 1);
|
||||||
|
arm64_sys_reg!(TCR_EL1, 3, 0, 2, 0, 2);
|
||||||
|
|
||||||
|
pub const AARCH64_ARCH_TIMER_PHYS_SECURE_IRQ: u32 = 13;
|
||||||
|
pub const AARCH64_ARCH_TIMER_PHYS_NONSECURE_IRQ: u32 = 14;
|
||||||
|
pub const AARCH64_ARCH_TIMER_VIRT_IRQ: u32 = 11;
|
||||||
|
pub const AARCH64_ARCH_TIMER_HYP_IRQ: u32 = 10;
|
||||||
|
|
||||||
|
// PMU PPI interrupt number
|
||||||
|
pub const AARCH64_PMU_IRQ: u32 = 7;
|
||||||
|
|
||||||
|
pub const AARCH64_MIN_PPI_IRQ: u32 = 16;
|
||||||
@@ -82,13 +82,13 @@ pub enum EmulationError<T: Debug> {
|
|||||||
WrongNumberOperands(#[source] anyhow::Error),
|
WrongNumberOperands(#[source] anyhow::Error),
|
||||||
|
|
||||||
#[error("Instruction Exception: {0}")]
|
#[error("Instruction Exception: {0}")]
|
||||||
InstructionException(Exception<T>),
|
InstructionException(#[source] Exception<T>),
|
||||||
|
|
||||||
#[error("Instruction fetching error: {0}")]
|
#[error("Instruction fetching error: {0}")]
|
||||||
InstructionFetchingError(#[source] anyhow::Error),
|
InstructionFetchingError(#[source] anyhow::Error),
|
||||||
|
|
||||||
#[error("Platform emulation error: {0}")]
|
#[error("Platform emulation error: {0}")]
|
||||||
PlatformEmulationError(PlatformError),
|
PlatformEmulationError(#[source] PlatformError),
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
EmulationError(#[from] anyhow::Error),
|
EmulationError(#[from] anyhow::Error),
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ use crate::{AiaState, HypervisorDeviceError, HypervisorVmError};
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Error while calling KVM ioctl for setting up the global interrupt controller.
|
/// Error while calling KVM ioctl for setting up the global interrupt controller.
|
||||||
#[error("Failed creating AIA device: {0}")]
|
#[error("Failed creating AIA device: {0}")]
|
||||||
CreateAia(HypervisorVmError),
|
CreateAia(#[source] HypervisorVmError),
|
||||||
/// Error while setting device attributes for the AIA.
|
/// Error while setting device attributes for the AIA.
|
||||||
#[error("Failed setting device attributes for the AIA: {0}")]
|
#[error("Failed setting device attributes for the AIA: {0}")]
|
||||||
SetDeviceAttribute(HypervisorDeviceError),
|
SetDeviceAttribute(#[source] HypervisorDeviceError),
|
||||||
/// Error while getting device attributes for the AIA.
|
/// Error while getting device attributes for the AIA.
|
||||||
#[error("Failed getting device attributes for the AIA: {0}")]
|
#[error("Failed getting device attributes for the AIA: {0}")]
|
||||||
GetDeviceAttribute(HypervisorDeviceError),
|
GetDeviceAttribute(#[source] HypervisorDeviceError),
|
||||||
}
|
}
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
|
|||||||
@@ -116,14 +116,14 @@ fn memory_operand_address<T: CpuStateManager>(
|
|||||||
|
|
||||||
if insn.memory_base() != iced_x86::Register::None {
|
if insn.memory_base() != iced_x86::Register::None {
|
||||||
let base: u64 = state.read_reg(insn.memory_base())?;
|
let base: u64 = state.read_reg(insn.memory_base())?;
|
||||||
address += base;
|
address = address.wrapping_add(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
if insn.memory_index() != iced_x86::Register::None {
|
if insn.memory_index() != iced_x86::Register::None {
|
||||||
let mut index: u64 = state.read_reg(insn.memory_index())?;
|
let mut index: u64 = state.read_reg(insn.memory_index())?;
|
||||||
index *= insn.memory_index_scale() as u64;
|
index = index.wrapping_mul(insn.memory_index_scale() as u64);
|
||||||
|
|
||||||
address += index;
|
address = address.wrapping_add(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
address = address.wrapping_add(insn.memory_displacement64());
|
address = address.wrapping_add(insn.memory_displacement64());
|
||||||
@@ -140,16 +140,3 @@ pub trait InstructionHandler<T: CpuStateManager> {
|
|||||||
platform: &mut dyn PlatformEmulator<CpuState = T>,
|
platform: &mut dyn PlatformEmulator<CpuState = T>,
|
||||||
) -> Result<(), EmulationError<Exception>>;
|
) -> Result<(), EmulationError<Exception>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! insn_format {
|
|
||||||
($insn:ident) => {{
|
|
||||||
let mut output = String::new();
|
|
||||||
let mut formatter = FastFormatter::new();
|
|
||||||
formatter
|
|
||||||
.options_mut()
|
|
||||||
.set_space_after_operand_separator(true);
|
|
||||||
formatter.format(&$insn, &mut output);
|
|
||||||
|
|
||||||
output
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ pub trait CpuStateManager: Clone {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(logical_addr + segment_register.base)
|
Ok(logical_addr.wrapping_add(segment_register.base))
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => Err(PlatformError::UnsupportedCpuMode(anyhow!("{:?}", mode))),
|
_ => Err(PlatformError::UnsupportedCpuMode(anyhow!("{:?}", mode))),
|
||||||
@@ -599,8 +599,8 @@ impl<T: CpuStateManager> Emulator<'_, T> {
|
|||||||
decoder.decode_out(&mut insn);
|
decoder.decode_out(&mut insn);
|
||||||
if decoder.last_error() != DecoderError::None {
|
if decoder.last_error() != DecoderError::None {
|
||||||
return Err(EmulationError::InstructionFetchingError(anyhow!(
|
return Err(EmulationError::InstructionFetchingError(anyhow!(
|
||||||
"{:#x?}",
|
"{:?}",
|
||||||
insn_format!(insn)
|
insn.code()
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -609,14 +609,17 @@ impl<T: CpuStateManager> Emulator<'_, T> {
|
|||||||
Emulator::get_handler(insn.code())
|
Emulator::get_handler(insn.code())
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
EmulationError::UnsupportedInstruction(anyhow!(
|
EmulationError::UnsupportedInstruction(anyhow!(
|
||||||
"{:#x?} {:?} {:?}",
|
"{:?} {:x?}",
|
||||||
insn_format!(insn),
|
insn.code(),
|
||||||
insn.mnemonic(),
|
insn_stream
|
||||||
insn.code()
|
|
||||||
))
|
))
|
||||||
})?
|
})?
|
||||||
.emulate(&insn, &mut state, self.platform)
|
.emulate(&insn, &mut state, self.platform)
|
||||||
.context(anyhow!("Failed to emulate {:#x?}", insn_format!(insn)))?;
|
.context(anyhow!(
|
||||||
|
"Failed to emulate {:?} {:x?}",
|
||||||
|
insn.code(),
|
||||||
|
insn_stream
|
||||||
|
))?;
|
||||||
|
|
||||||
last_decoded_ip = decoder.ip();
|
last_decoded_ip = decoder.ip();
|
||||||
num_insn_emulated += 1;
|
num_insn_emulated += 1;
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
// Copyright © 2020, Microsoft Corporation
|
// Copyright © 2020, Microsoft Corporation
|
||||||
//
|
//
|
||||||
|
|
||||||
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
|
use core::fmt;
|
||||||
|
|
||||||
|
#[cfg(all(feature = "mshv_emulator", target_arch = "x86_64"))]
|
||||||
pub mod emulator;
|
pub mod emulator;
|
||||||
pub mod gdt;
|
pub mod gdt;
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@@ -211,6 +213,22 @@ pub struct CpuIdEntry {
|
|||||||
pub edx: u32,
|
pub edx: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CpuIdEntry {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"function = 0x{:08x} \
|
||||||
|
index = 0x{:08x} \
|
||||||
|
eax = 0x{:08x} \
|
||||||
|
ebx = 0x{:08x} \
|
||||||
|
ecx = 0x{:08x} \
|
||||||
|
edx = 0x{:08x} \
|
||||||
|
flags = 0x{:08x}",
|
||||||
|
self.function, self.index, self.eax, self.ebx, self.ecx, self.edx, self.flags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub const CPUID_FLAG_VALID_INDEX: u32 = 1;
|
pub const CPUID_FLAG_VALID_INDEX: u32 = 1;
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, serde::Deserialize, serde::Serialize)]
|
#[derive(Default, Debug, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
|
|||||||
@@ -10,18 +10,21 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
#[cfg(not(target_arch = "riscv64"))]
|
#[cfg(not(target_arch = "riscv64"))]
|
||||||
use vm_memory::GuestAddress;
|
use vm_memory::GuestAddress;
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
use crate::aarch64::{RegList, VcpuInit};
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
use crate::arch::x86::{CpuIdEntry, FpuState, LapicState, MsrEntry, SpecialRegisters};
|
use crate::arch::x86::{CpuIdEntry, FpuState, LapicState, MsrEntry, SpecialRegisters};
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
use crate::kvm::{TdxExitDetails, TdxExitStatus};
|
use crate::kvm::{TdxExitDetails, TdxExitStatus};
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
|
||||||
use crate::riscv64::RegList;
|
use crate::RegList;
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
use crate::VcpuInit;
|
||||||
use crate::{CpuState, MpState, StandardRegisters};
|
use crate::{CpuState, MpState, StandardRegisters};
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
@@ -320,7 +323,13 @@ pub enum HypervisorCpuError {
|
|||||||
#[cfg(feature = "sev_snp")]
|
#[cfg(feature = "sev_snp")]
|
||||||
#[error("Failed to set sev control register: {0}")]
|
#[error("Failed to set sev control register: {0}")]
|
||||||
SetSevControlRegister(#[source] anyhow::Error),
|
SetSevControlRegister(#[source] anyhow::Error),
|
||||||
|
///
|
||||||
|
/// Unsupported SysReg registers
|
||||||
|
///
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
#[error("Unsupported SysReg registers: {0}")]
|
||||||
|
UnsupportedSysReg(u32),
|
||||||
|
///
|
||||||
/// Error injecting NMI
|
/// Error injecting NMI
|
||||||
///
|
///
|
||||||
#[error("Failed to inject NMI")]
|
#[error("Failed to inject NMI")]
|
||||||
@@ -449,7 +458,26 @@ pub trait Vcpu: Send + Sync {
|
|||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
fn vcpu_finalize(&self, feature: i32) -> Result<()>;
|
fn vcpu_finalize(&self, feature: i32) -> Result<()>;
|
||||||
|
///
|
||||||
|
/// Gets the features that have been finalized for a given CPU.
|
||||||
|
///
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
fn vcpu_get_finalized_features(&self) -> i32;
|
||||||
|
///
|
||||||
|
/// Sets processor features for a given CPU.
|
||||||
|
///
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
fn vcpu_set_processor_features(
|
||||||
|
&self,
|
||||||
|
vm: &Arc<dyn crate::Vm>,
|
||||||
|
kvi: &mut VcpuInit,
|
||||||
|
id: u8,
|
||||||
|
) -> Result<()>;
|
||||||
|
///
|
||||||
|
/// Returns VcpuInit with default value set
|
||||||
|
///
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
fn create_vcpu_init(&self) -> VcpuInit;
|
||||||
///
|
///
|
||||||
/// Gets a list of the guest registers that are supported for the
|
/// Gets a list of the guest registers that are supported for the
|
||||||
/// KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
|
/// KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
|
||||||
@@ -562,7 +590,13 @@ pub trait Vcpu: Send + Sync {
|
|||||||
fn set_sev_control_register(&self, _reg: u64) -> Result<()> {
|
fn set_sev_control_register(&self, _reg: u64) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
///
|
||||||
|
/// Sets the value of GIC redistributor address
|
||||||
|
///
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
fn set_gic_redistributor_addr(&self, _gicr_base_addr: u64) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
///
|
///
|
||||||
/// Trigger NMI interrupt
|
/// Trigger NMI interrupt
|
||||||
|
|||||||
@@ -67,22 +67,22 @@ pub enum HypervisorError {
|
|||||||
///
|
///
|
||||||
/// Checking extensions failed
|
/// Checking extensions failed
|
||||||
///
|
///
|
||||||
#[error("Checking extensions:{0}")]
|
#[error("Checking extensions: {0}")]
|
||||||
CheckExtensions(#[source] anyhow::Error),
|
CheckExtensions(#[source] anyhow::Error),
|
||||||
///
|
///
|
||||||
/// Failed to retrieve TDX capabilities
|
/// Failed to retrieve TDX capabilities
|
||||||
///
|
///
|
||||||
#[error("Failed to retrieve TDX capabilities:{0}")]
|
#[error("Failed to retrieve TDX capabilities: {0}")]
|
||||||
TdxCapabilities(#[source] anyhow::Error),
|
TdxCapabilities(#[source] anyhow::Error),
|
||||||
///
|
///
|
||||||
/// Failed to set partition property
|
/// Failed to set partition property
|
||||||
///
|
///
|
||||||
#[error("Failed to set partition property:{0}")]
|
#[error("Failed to set partition property: {0}")]
|
||||||
SetPartitionProperty(#[source] anyhow::Error),
|
SetPartitionProperty(#[source] anyhow::Error),
|
||||||
///
|
///
|
||||||
/// Running on an unsupported CPU
|
/// Running on an unsupported CPU
|
||||||
///
|
///
|
||||||
#[error("Unsupported CPU:{0}")]
|
#[error("Unsupported CPU: {0}")]
|
||||||
UnsupportedCpu(#[source] anyhow::Error),
|
UnsupportedCpu(#[source] anyhow::Error),
|
||||||
///
|
///
|
||||||
/// Launching a VM with unsupported VM Type
|
/// Launching a VM with unsupported VM Type
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use kvm_ioctls::DeviceFd;
|
|||||||
use redist_regs::{construct_gicr_typers, get_redist_regs, set_redist_regs};
|
use redist_regs::{construct_gicr_typers, get_redist_regs, set_redist_regs};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::arch::aarch64::gic::{Error, Result, Vgic, VgicConfig};
|
use crate::arch::aarch64::gic::{Error, GicState, Result, Vgic, VgicConfig};
|
||||||
use crate::device::HypervisorDeviceError;
|
use crate::device::HypervisorDeviceError;
|
||||||
use crate::kvm::KvmVm;
|
use crate::kvm::KvmVm;
|
||||||
use crate::{CpuState, Vm};
|
use crate::{CpuState, Vm};
|
||||||
@@ -125,6 +125,23 @@ pub struct Gicv3ItsState {
|
|||||||
its_baser: [u64; 8],
|
its_baser: [u64; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<GicState> for Gicv3ItsState {
|
||||||
|
fn from(state: GicState) -> Self {
|
||||||
|
match state {
|
||||||
|
GicState::Kvm(state) => state,
|
||||||
|
/* Needed in case other hypervisors are enabled */
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
|
_ => panic!("GicState is not valid"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Gicv3ItsState> for GicState {
|
||||||
|
fn from(state: Gicv3ItsState) -> Self {
|
||||||
|
GicState::Kvm(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl KvmGicV3Its {
|
impl KvmGicV3Its {
|
||||||
/// Device trees specific constants
|
/// Device trees specific constants
|
||||||
pub const ARCH_GIC_V3_MAINT_IRQ: u32 = 9;
|
pub const ARCH_GIC_V3_MAINT_IRQ: u32 = 9;
|
||||||
@@ -316,7 +333,7 @@ impl Vgic for KvmGicV3Its {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Save the state of GICv3ITS.
|
/// Save the state of GICv3ITS.
|
||||||
fn state(&self) -> Result<Gicv3ItsState> {
|
fn state(&self) -> Result<GicState> {
|
||||||
let gicr_typers = self.gicr_typers.clone();
|
let gicr_typers = self.gicr_typers.clone();
|
||||||
|
|
||||||
let gicd_ctlr = read_ctlr(&self.device)?;
|
let gicd_ctlr = read_ctlr(&self.device)?;
|
||||||
@@ -366,7 +383,7 @@ impl Vgic for KvmGicV3Its {
|
|||||||
GITS_IIDR,
|
GITS_IIDR,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(Gicv3ItsState {
|
let gic_state: GicState = Gicv3ItsState {
|
||||||
dist: dist_state,
|
dist: dist_state,
|
||||||
rdist: rdist_state,
|
rdist: rdist_state,
|
||||||
icc: icc_state,
|
icc: icc_state,
|
||||||
@@ -377,48 +394,53 @@ impl Vgic for KvmGicV3Its {
|
|||||||
its_cwriter: its_cwriter_state,
|
its_cwriter: its_cwriter_state,
|
||||||
its_creadr: its_creadr_state,
|
its_creadr: its_creadr_state,
|
||||||
its_baser: its_baser_state,
|
its_baser: its_baser_state,
|
||||||
})
|
}
|
||||||
|
.into();
|
||||||
|
|
||||||
|
Ok(gic_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Restore the state of GICv3ITS.
|
/// Restore the state of GICv3ITS.
|
||||||
fn set_state(&mut self, state: &Gicv3ItsState) -> Result<()> {
|
fn set_state(&mut self, state: &GicState) -> Result<()> {
|
||||||
|
let kvm_state: Gicv3ItsState = state.clone().into();
|
||||||
|
|
||||||
let gicr_typers = self.gicr_typers.clone();
|
let gicr_typers = self.gicr_typers.clone();
|
||||||
|
|
||||||
write_ctlr(&self.device, state.gicd_ctlr)?;
|
write_ctlr(&self.device, kvm_state.gicd_ctlr)?;
|
||||||
|
|
||||||
set_dist_regs(&self.device, &state.dist)?;
|
set_dist_regs(&self.device, &kvm_state.dist)?;
|
||||||
|
|
||||||
set_redist_regs(&self.device, &gicr_typers, &state.rdist)?;
|
set_redist_regs(&self.device, &gicr_typers, &kvm_state.rdist)?;
|
||||||
|
|
||||||
set_icc_regs(&self.device, &gicr_typers, &state.icc)?;
|
set_icc_regs(&self.device, &gicr_typers, &kvm_state.icc)?;
|
||||||
|
|
||||||
//Restore GICv3ITS registers
|
//Restore GICv3ITS registers
|
||||||
gicv3_its_attr_set(
|
gicv3_its_attr_set(
|
||||||
self.its_device.as_ref().unwrap(),
|
self.its_device.as_ref().unwrap(),
|
||||||
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
||||||
GITS_IIDR,
|
GITS_IIDR,
|
||||||
state.its_iidr,
|
kvm_state.its_iidr,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
gicv3_its_attr_set(
|
gicv3_its_attr_set(
|
||||||
self.its_device.as_ref().unwrap(),
|
self.its_device.as_ref().unwrap(),
|
||||||
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
||||||
GITS_CBASER,
|
GITS_CBASER,
|
||||||
state.its_cbaser,
|
kvm_state.its_cbaser,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
gicv3_its_attr_set(
|
gicv3_its_attr_set(
|
||||||
self.its_device.as_ref().unwrap(),
|
self.its_device.as_ref().unwrap(),
|
||||||
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
||||||
GITS_CREADR,
|
GITS_CREADR,
|
||||||
state.its_creadr,
|
kvm_state.its_creadr,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
gicv3_its_attr_set(
|
gicv3_its_attr_set(
|
||||||
self.its_device.as_ref().unwrap(),
|
self.its_device.as_ref().unwrap(),
|
||||||
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
||||||
GITS_CWRITER,
|
GITS_CWRITER,
|
||||||
state.its_cwriter,
|
kvm_state.its_cwriter,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
for i in 0..8 {
|
for i in 0..8 {
|
||||||
@@ -426,7 +448,7 @@ impl Vgic for KvmGicV3Its {
|
|||||||
self.its_device.as_ref().unwrap(),
|
self.its_device.as_ref().unwrap(),
|
||||||
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
||||||
GITS_BASER + i * 8,
|
GITS_BASER + i * 8,
|
||||||
state.its_baser[i as usize],
|
kvm_state.its_baser[i as usize],
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +459,7 @@ impl Vgic for KvmGicV3Its {
|
|||||||
self.its_device.as_ref().unwrap(),
|
self.its_device.as_ref().unwrap(),
|
||||||
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
kvm_bindings::KVM_DEV_ARM_VGIC_GRP_ITS_REGS,
|
||||||
GITS_CTLR,
|
GITS_CTLR,
|
||||||
state.its_ctlr,
|
kvm_state.its_ctlr,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ use kvm_ioctls::DeviceFd;
|
|||||||
use crate::arch::aarch64::gic::{Error, Result};
|
use crate::arch::aarch64::gic::{Error, Result};
|
||||||
use crate::device::HypervisorDeviceError;
|
use crate::device::HypervisorDeviceError;
|
||||||
use crate::kvm::kvm_bindings::{
|
use crate::kvm::kvm_bindings::{
|
||||||
kvm_device_attr, KVM_DEV_ARM_VGIC_GRP_REDIST_REGS, KVM_REG_ARM64, KVM_REG_ARM64_SYSREG,
|
kvm_device_attr, kvm_one_reg, KVM_DEV_ARM_VGIC_GRP_REDIST_REGS, KVM_REG_ARM64,
|
||||||
KVM_REG_ARM64_SYSREG_OP0_MASK, KVM_REG_ARM64_SYSREG_OP0_SHIFT, KVM_REG_ARM64_SYSREG_OP2_MASK,
|
KVM_REG_ARM64_SYSREG, KVM_REG_ARM64_SYSREG_OP0_MASK, KVM_REG_ARM64_SYSREG_OP0_SHIFT,
|
||||||
KVM_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_SIZE_U64,
|
KVM_REG_ARM64_SYSREG_OP2_MASK, KVM_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_SIZE_U64,
|
||||||
};
|
};
|
||||||
use crate::kvm::{Register, VcpuKvmState};
|
use crate::kvm::VcpuKvmState;
|
||||||
use crate::CpuState;
|
use crate::CpuState;
|
||||||
|
|
||||||
// Relevant redistributor registers that we want to save/restore.
|
// Relevant redistributor registers that we want to save/restore.
|
||||||
@@ -213,7 +213,7 @@ pub fn construct_gicr_typers(vcpu_states: &[CpuState]) -> Vec<u64> {
|
|||||||
let state: VcpuKvmState = state.clone().into();
|
let state: VcpuKvmState = state.clone().into();
|
||||||
let last = (index == vcpu_states.len() - 1) as u64;
|
let last = (index == vcpu_states.len() - 1) as u64;
|
||||||
// state.sys_regs is a big collection of system registers, including MIPDR_EL1
|
// state.sys_regs is a big collection of system registers, including MIPDR_EL1
|
||||||
let mpidr: Vec<Register> = state
|
let mpidr: Vec<kvm_one_reg> = state
|
||||||
.sys_regs
|
.sys_regs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|reg| reg.id == KVM_ARM64_SYSREG_MPIDR_EL1)
|
.filter(|reg| reg.id == KVM_ARM64_SYSREG_MPIDR_EL1)
|
||||||
@@ -221,7 +221,7 @@ pub fn construct_gicr_typers(vcpu_states: &[CpuState]) -> Vec<u64> {
|
|||||||
//calculate affinity
|
//calculate affinity
|
||||||
let mut cpu_affid = mpidr[0].addr & 1095233437695;
|
let mut cpu_affid = mpidr[0].addr & 1095233437695;
|
||||||
cpu_affid = ((cpu_affid & 0xFF00000000) >> 8) | (cpu_affid & 0xFFFFFF);
|
cpu_affid = ((cpu_affid & 0xFF00000000) >> 8) | (cpu_affid & 0xFFFFFF);
|
||||||
gicr_typers.push((cpu_affid << 32) | (1 << 24) | (index as u64) << 8 | (last << 4));
|
gicr_typers.push((cpu_affid << 32) | (1 << 24) | ((index as u64) << 8) | (last << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
gicr_typers
|
gicr_typers
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user