Commit graph

216 commits

Author SHA1 Message Date
Grzegorz Jaszczyk
a8985f0ba8 x86: remove deprecated KVM based s2idle notification related code
This commit reverts 344e2432d1 "x86:
handle KVM_SYSTEM_EVENT_S2IDLE request" but also some other parts which
grow around this concept. The s2idle notification linux counterpart
based on KVM hypercall was rejected in the linux kernel mailing list and
new approach was suggested which is based on virtual PMC.  Additionally
the privileged guest term was introduced only for ManaTEE, which is not
evaluated anymore.

The new Virtual PMC related approach is used instead for getting guest
s2idle notifications, see CL:3780642.

BUG=None
TEST=Build + tools/presubmit crosvm_tests_x86_64

Change-Id: I3cf4b77ab192198fe9e8b990b994a41105c2e72f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4507305
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-05 22:24:58 +00:00
Dylan Reid
3df3d394cd hypervisor: fix riscv clippy lint
In preparation for enabling tools/clippy to check riscv, clean up the
warning in the hypervisor crate.

Change-Id: Iab2d1f703e0ab5e40ed165873376cdfabdc3de60
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4505756
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-05-04 15:43:59 +00:00
Frederick Mayle
5441c064e5 hypervisor: kvm: check for KVM_SET_MSRS failures
The KVM docs say

  If setting an MSR fails, ..., it stops processing the MSR list and
  returns the number of MSRs that have been set successfully.

So, a return value of zero really means the operation completely failed.

Change-Id: Ic98cdb02513ff86e22fb6b048e7ceb2d6b7e554a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4500732
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-05-03 20:52:05 +00:00
Dylan Reid
1ae4e549e5 tests: Add riscv imports where needed
In working towards enabling unit tests, import the correct arch defines
for riscv64 where needed.

TEST=from dev container run:
```
cargo nextest run --workspace --no-default-features \
--exclude tpm2 \
--exclude tpm2-sys \
--exclude libvda \
--exclude libva \
--exclude ffmpeg \
--exclude vmm_vhost \
--exclude system_api \
--exclude gpu_display \
--color=always \
--no-run \
--target riscv64gc-unknown-linux-gnu
```

Change-Id: Ia7853de8ee0a11a5fdb716546a146f892229b0cb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4501091
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-03 16:50:25 +00:00
Daniel Verkamp
db627e80e9 crosvm: make userspace_msr handling x86 only
MSRs are specific to x86/x86-64; add the appropriate cfg checks and
remove the MsrHandlers stubs from aarch64 and riscv64.

Change-Id: I94f0b5b4b9f75fecdc8e03c569f89a70b7f9f647
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4482135
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-28 17:58:30 +00:00
Andrew Walbran
1661dfca89 Update bitflags dependency to 2.2.1.
This is a new major version, and requires some code changes.

Change-Id: I294ce3604aad6e6dc5f50e33246b690e883c1e36
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4481294
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-27 17:22:36 +00:00
Dylan Reid
5c0f979761 hypervisor: add riscv64 kvm support
Add basic support for linux kvm running on a riscv64 cpu. Mostly mirrors
the arm support as the interfaces are luckily similar.

Change-Id: I77c091d9b30758788b7c97bc0b3804879e27055d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460938
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-25 22:10:18 +00:00
Daniel Verkamp
2c1d17fe41 tree-wide: remove unnecessary casts
Fixes clippy lint in Rust 1.68

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: Ib9d83b8dc15a93e815600391e93b8bb1788f7dc4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391107
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:43:59 +00:00
Noah Gold
307b57809a hypervisor: snapshot interrupt state for WHPX.
When snapshotting, the interrupt state (pending or otherwise) needs to
be saved from the VCPU. Every hypervisor has its own implementation
of how this is exposed to VMMs (KVM uses vcpu_events). This CL adds
an implementation for WHPX's VCPU.

BUG=b:270734340
TEST=builds (we can't test the full WHPX snapshot flow yet; need to
reach critical mass on implementation first).

Change-Id: Ic97ad15391f277967bd7b19a7ff6b55c57f3a00b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428057
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-04-17 18:18:32 +00:00
Noah Gold
f897fb4f54 hypervisor: fix error codes for WHPX xsave.
EIO is more appropriate than unsupported for this error.

BUG=b:270734340
TEST=builds

Change-Id: Idaf8c291c7301f1ee929aafc12bf032f19d71e35
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4425875
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-04-17 17:40:26 +00:00
Noah Gold
22121cdb0b hypervisor: migrate VcpuEvents to a generic hypervisor blob.
Originally VcpuEvents was modeled on KVM's vcpu_events struct. Other
hypervisors like WHPX represent the sort of data that's in KVM's struct
very differently. This CL moves us to use a json blob that each
hypervisor can define for itself, which unblocks implementing for WHPX.

BUG=b:270734340
TEST=tools/dev-container e2e_tests/run

Change-Id: I1600f4303ee5bf2aebeaeb92a215edaea2f69a87
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4421490
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-04-17 17:40:26 +00:00
Daniel Verkamp
f9cc2d0827 hypervisor, kvm: fix get_msr test on newer kernels
MSR index 0x3f1 (MSR_IA32_PEBS_ENABLE) is now allowed to be fetched by
KVM_GET_MSRS in newer kernels.

Pick an even more invalid MSR index so the MSR will actually fail to be
fetched.

BUG=b:275605159
TEST=cargo test -p kvm -p hypervisor # on Linux 6.1

Change-Id: Ia4f34ca43893535883620e82f35a955e630a9743
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4419606
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-12 18:29:37 +00:00
Daniel Verkamp
d0eaef9e01 hypervisor: represent Xsave as u32 again
I suggested a workaround to make Xsave data 4-byte aligned for KVM while
representing it equivalent to a Vec<u8>, but the suggestion was
incorrect - the workaround made each XsaveByte one byte of data and
three bytes of padding, which was not intended.

Partially revert the representation of Xsave to a Vec<u32>, but keep the
Xsave::new() function so the caller does not need to know about the
internal representation.

BUG=b:270734340
TEST=tools/dev_container tools/presubmit

Change-Id: I5d51f02d4fee061840d591a9ef16a78f44274064
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4412666
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-11 02:13:53 +00:00
Noah Gold
526922ac76 hypervisor: implment get/set xsave for WHPX.
Adds implementations for get/set xsave for WHPX. This is needed for
snapshotting on WHPX.

BUG=b:270734340
TEST=unit test.

Change-Id: I6496b257dc7ef374a1c972e9b1179a6692541ae8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4409919
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
2023-04-10 23:31:45 +00:00
Noah Gold
bf82df0fe9 hypervisor: change Xsave buf. to more generic u8
get/set_xsave lets us get/set the xsave data on a VCPU. Originally this
was set to be represented as Vec<u32> since that's what KVM uses on its
ioctl; however, other hypervisors like WHPX prefer an opaque byte array.
This CL switches us to a byte array. From KVM's perspective, this is
identical because we still require a 4 byte alignment.

BUG=b:270734340
TEST=builds

Change-Id: Ia7931f0f07e5e95beab39f65ad1a5942ad9841f6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4410240
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Steven Moreland <smoreland@google.com>
2023-04-10 23:25:56 +00:00
Elliot Berman
9110f097f0 hypervisor: Implement gunyah
Implement base gunyah abstractions.

Bindings are based off aosp/2475305/9.

Cherry-pick notes: Fixed license headers and uppercased bindgen constant
to workaround "constant in pattern ... should have an upper case name"
warning that can't be disabled (will need to adjust the bindgen script
later to match).

BUG=b:232360323

Change-Id: I4815128ce827112b25add87ac11e28868b4cdb46
Co-developed-by: Sreenad Menon <quic_sreemeno@quicinc.com>
Signed-off-by: Sreenad Menon <quic_sreemeno@quicinc.com>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4404217
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 18:32:18 +00:00
Elliot Berman
3cfc7c260b Cargo.toml: Enable Gunyah only for all-aarch64
Enable gunyah feature for all-aarch64. all-x86_64 inherits all-aarch64
and Gunyah does not support x86_64, so create a new meta-feature,
all-default to support the common features that need to be enabled in
aarch64 and x86_64.

Cherry-pick notes: This commit now adds the "gunyah" feature and is
moved earlier in the series so that changes later in the series can be
properly tested by presubmits.

BUG=b:232360323

Change-Id: Ibb3b0ad48017c2480498634d766aea162114b385
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4404216
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 18:32:18 +00:00
Elliot Berman
eb1c95693f hypervisor: aarch64: Add init_vm
Gunyah initializes at VM level, not the vCPU level as KVM. Add
VM-generic initialization which happens after build_vm, but before the
VM starts to run.

BUG=b:232360323

Change-Id: Iea38cf63eca9b525e613450fd7bca2d422923063
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4400669
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 18:32:18 +00:00
Daniel Verkamp
10a487a725 tree-wide: replace manual enum Defaults with derive
This is supported since Rust 1.62.

Fixes the new derivable_impls clippy lint, added in Rust 1.67.

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: I3696dd3cf4acbf9b5a2cfa8c2046e7656e13dbbd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4390735
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-04 22:12:39 +00:00
Noah Gold
7a19c54afb devices: implement ioapic save/restore.
The ioapic can now be serialized, and re-create its MSIs on restore.

BUG=b:266513575
TEST=presubmit

Change-Id: I1d164526a0e61de1e38371fc3943cd1136ca15d0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4368984
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-04-01 03:35:36 +00:00
Frederick Mayle
b8a10b19ce hypervisor: pass VcpuSnapshot restore by ref
Change-Id: I7e3d2b1a01442fcbe4a66e35b120b070ded6b593
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4385871
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-31 00:22:40 +00:00
Frederick Mayle
7603febb15 hypervisor: merge VcpuSnapshot and VcpuInnerSnapshot structs
We can require the ID field to be present in all the arch specific
structs, then we don't need an extra layer.

Change-Id: Icbbf0ec5b99fd6816863a611a538e67def09d87f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4385864
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
2023-03-31 00:22:40 +00:00
Elliot Berman
c8341f6df0 aarch64: Allow hypervisor to initialize boot context
Some hypervisors (presently: Gunyah) will configure boot-time registers
for vCPUs and not allow userspace VMM to set the boot configuration.

If this capability is declared, then crosvm will not try to initialize
vcpu registers upon VM bootup.

BUG=b:232360323

Change-Id: If2f05c832170f75eabfd7f0c63975465ba75aadf
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4379525
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-29 00:52:24 +00:00
Elliot Berman
a92cfe8cb6 vm_memory: Convert GuestMemory::with_regions to use struct argument
Introduce a struct argument, MemoryRegionInformation, for use with
with_regions.

No functional change intended.

BUG=b:232360323

Change-Id: Icd40630c32878b3bd185aeeedcf9e1e9de20e20b
Suggested-by: Frederick Mayle <fmayle@google.com>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4379522
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-29 00:52:24 +00:00
Elliot Berman
9b2ea4f8a6 hypervisor: Allow for hypervisor-specific DT additions
Gunyah hypervisor requires some VM configuration to be described on the
devicetree. Add a trait to VmAArch64 to allow a hypervisor
implementation to provide the needed info.

BUG=b:253416076
Change-Id: I07091518b856add0c1644bf6a857460da7ff2b3b
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4379521
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-29 00:52:24 +00:00
Daniel Verkamp
083dcf75f4 tree-wide: apply nightly rustfmt
BUG=None
TEST=tools/fmt --nightly

Change-Id: Ifb08dd55ccf2a74ef739d7517a64970d24a82405
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4375640
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-27 21:30:45 +00:00
Elie Kheirallah
425764d60f hypervisor: Add restore to x86/x86-64 Vcpu
Add restore to Vcpu to restore VCPU state from snapshot.
Add kick_vcpu to kick a specific vcpu.

BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket

Change-Id: Ie09419fd50dcecd0226b2b716236d2c8196b58ec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4260157
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Elie Kheirallah <khei@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
2023-03-23 20:55:00 +00:00
Elie Kheirallah
9d214c1843 hypervisor: Add snapshot to vCPU x86_64
Add snapshot to vCPU for x86 and x86_64 arch.

BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket

Change-Id: I65d059a7537c713e9ef6c1456a7aeae2b6bc4728
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237759
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-03-23 17:15:47 +00:00
Daniel Verkamp
914d8eeb19 hypervisor: kvm: check API version
This is recommended by the kernel KVM documentation, and it also helps
to provide a more meaningful error if the user provides an incorrect KVM
device path for a file that exists but is not actually a KVM device node
("Inappropriate ioctl for device").

BUG=None
TEST=crosvm run --kvm-device=/dev/null ...

Change-Id: If8e505e2945a76bdd6ba2bf559eeeb3a12f77b15
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4363327
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-03-22 23:01:42 +00:00
Yi-De Wu
65d98b04f6 aarch64: MTK GenieZone hypervisor enablement as Crosvm backend
To support GenieZone (gz) hypervisor as a crosvm hypervisor backend:
- Implement GenieZone hypervisor
- Implement GenieZone’s irqchip
- Create config and feature for GenieZone
- Probe proper hypervisor backend with naive logic
- Inject virtual interrupts
- Bootup guest VM with linux kernel to shell

We still have other todos:

- Integrate with protected VM and pvmfw
- Support multi-core VM

Fixed bugs:
- Replace gz with geniezone in most cases for clarity
- Replace KVM’s ioctl number with GZVM’s ioctl in bindings

Bug: 264630327
TEST:
$ taskset 10 ./crosvm run --disable-sandbox -m 512 -s s1 \
  --rwroot alpine-rootfs.img -p 'init=/bin/sh rodata=off' \
  --display-window-keyboard Image_515_41_no_numa_20230130 \
  --serial type=stdout,hardware=serial,earlycon \
  --serial type=stdout,hardware=virtio-console,console,stdin

Change-Id: Ia5d92ba5cbb4198ab7f9f2a778da03b2199892cd
Signed-off-by: Ze-yu Wang <ze-yu.wang@mediatek.com>
Signed-off-by: Yi-de Wu <yi-de.wu@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4170415
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-03-22 18:04:47 +00:00
Elliot Berman
d88d67c39b base: Move BlockedSignal to base sys
Move generic implementation of BlockedSignal to base sys.

Change-Id: I459ca424a633dc3fc2a5dec625dde8e5878132c0
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 5f51fa4ae3b979972d273dff4c224c1999b6e641)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346950
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-16 18:16:28 +00:00
Elliot Berman
ae0c1d8341 aarch64: Abstract KVM register read/writes
Remove KVM-specific code from the generic aarch64 module by providing a
generic enum for hypervisor-specific vCpus to use instead:
VCpuRegAArch64.

(cherry picked from commit cfd5acd14f924fe17f09c007fb20bf2abc632a79)
Change-Id: I486ea24993493c314ed6dacd5cedeeb135225135
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346944
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-16 18:16:28 +00:00
Steven Moreland
c623af3c8a Revert "aarch64: Abstract KVM register read/writes"
This reverts commit c903a58f86.

Change-Id: Iea45955089bf7285232ada096b122a08e755f7c8
(cherry picked from commit 28e9e7350931c3c7c7307d777f83b3225eb3761c)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346939
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-16 18:16:28 +00:00
Steven Moreland
6a524c08b0 Revert "base: Move BlockedSignal to base sys"
This reverts commit 92ffa564c4.

Change-Id: I98ce7763a5dba804ebbe17a78a9a0af35daca52e
(cherry picked from commit 8558a5dfaee0ef5f683cf932f5abcb197afd730d)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346933
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-16 18:16:28 +00:00
Daniel Verkamp
4257db1489 hypervisor: remove nmi.pad field from VcpuEvents
This seems to be purely reserved for alignment reasons; the kernel
never touches it, so we don't need to serialize/deserialize it.

BUG=b:266515147
TEST=tools/presubmit

Change-Id: I3074d24f50a8e0e86340c398885c2fbef1410a88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4342173
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-03-15 21:43:14 +00:00
Elie Kheirallah
6abac76996 hypervisor: x86_64: add VCPU_EVENTS support
Add get/set VCPU_EVENTS as required to snapshot the full state of the
VCPUs for suspend/resume.

BUG=b:266515147
TEST=build and run VM

Change-Id: Iabca21b67a0eb9906d2e639a616e3f0826dfa659
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4327459
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-03-15 20:15:03 +00:00
Frederick Mayle
341a4a6f4f hypervisor: add contact for windows hypervisors
Change-Id: I9288e2cf73996dd7c02e0e870a9c9265acba1dfd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4335694
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Auto-Submit: Frederick Mayle <fmayle@google.com>
2023-03-14 18:22:46 +00:00
Frederick Mayle
c0e2630d69 docs: add instructions for using the --hypervisor flag
Change-Id: I254603b04b8d05b9410715e52bd7afe2db113458
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4335142
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-03-14 02:00:04 +00:00
Frederick Mayle
35ad1df0c6 hypervisor: add README.md detailing hypervisor support
Change-Id: Ia906b551f0859294670bef340610575328fe36a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4326988
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-03-14 02:00:04 +00:00
Wang Ningyuan
dda04eda47 Devices: trait implementation for BAR reprogram
This CL adds trait implementation for PciDevice to handle BAR
reprogramming. When BAR reprogramming is detected, the PciDevice checks
all ioevents needed, and requests ioevent registeration for events that
are in the changed domain. The requests are handled by instances of
PciDevice via the trait function ioevent_register_request.
Before the CL, ioevent re-registering is unhandled, and PciDevice is
broken without notification. After CL, an error message will appear, but
device still would not function as the added trait is not implemented.

Test: Presubmit Tests. Hotplugged virtio device triggers error
IoEventNotSupported as expected.
Bug: 271204121

Change-Id: Ibf4bc00cfdce24e508cd50b5009f148c5a49db30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4310071
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
2023-03-10 04:17:52 +00:00
Vaibhav Nagarnaik
7e848f215c haxm: fix future incompatibility warning
use of `unaligned_references` will be blocked soon and spits out a
warning during compiling. fix it in haxm.

Test: Compiled and ran with haxm enabled.
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Change-Id: Ia887cff1ce01e6c14a9cf4978bf49835e996dd5a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4324279
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-09 22:01:54 +00:00
Elie Kheirallah
041764bcd3 hypervisor: Add get_xsave and set_xsave support to x86.
This change adds the function get_xsave to the x86/86_64 platform.
get_xsave allows us to get state of the x87 FPU, MMX, XMM and YMM registers.
This change is needed for serializing vCPUs.
Adds also function to check if XSAVE2 Capability is enabled.
get_xsave is not implemented yet for Windows.

BUG=b:266515147
Test=Build and run VM

Change-Id: I5a9d3b2b86bc11a66db331b4b25d0c348459ab69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4292298
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-03-03 00:30:04 +00:00
Daniel Verkamp
2712fc59b1 bindgen: update kernel bindings to Linux 6.1
Switch to the ChromeOS v6.1 branch and regenerate all affected bindings
in the crosvm tree.

Some minor fixes were required in users of the bindings:
- KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 is available in the kernel now
  and was removed from the manually-added section of kvm_sys.
- The KVM system_event now contains an anonymous union, requiring a few
  renames.
- IORING_OP_* were moved into an enum, which required the enum name to
  be prefixed to the uses of those values.

BUG=None
TEST=tools/presubmit --all

Change-Id: I84568fb76658832130e2e9a631495ba82fd4c3ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4285742
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-23 21:31:44 +00:00
Dennis Kempin
a3e2d8da3f Fix clippy errors on aarch64/armhf
We will enable clippy checks on those platforms in CI soon.

BUG=b:268356784
TEST=tools/clippy --platform=aarch64/armhf

Change-Id: Icfefdbce7498731d78448b00c7c21a0f86639dff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233580
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-09 00:09:02 +00:00
Zihan Chen
28ce4e5423 crosvm: Uprev rust toolchain and dev container
- Rust toolchain is updated to 1.65.0
- Catapult dashboard upload tool is added to dev_container
- Bindgen is updated to latest version to support custom derive
- Derive Eq when PartialEq is derived as required by new Clippy

TEST=CQ, bindgen-all-the-things

FIXED=b:260784028
BUG=b:257303497

Change-Id: I2034cd09e0aed84d4e9b30f2e85d84d94a442ea4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228427
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-08 20:26:30 +00:00
Vikram Auradkar
be24b260e5 hypervisor: fix whpx build failures
Testing whpx is somewhat limited because of LUCI bot nested hyper-v
support.

BUG=b:266137821
TEST=build locally with `--features whpx`

Change-Id: Ifc252dcc9c973ab1cbaf48a0fc17b28517238430
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4215314
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-02-02 02:29:31 +00:00
Frederick Mayle
653f62a4a3 aarch64: static swiotlb allocation
Adds a new hypervisor capability that causes crosvm to statically
allocate the location of the swiotlb buffer.

This will be used by the gunyah hypervisor.

BUG=b:244630071,b:232360323

Change-Id: Ia2f379bb6f2fa89167ddc73d65ec1b8c5494bdf6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4197001
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-02-01 00:05:48 +00:00
Elliot Berman
92ffa564c4 base: Move BlockedSignal to base sys
Move generic implementation of BlockedSignal to base sys.

Change-Id: Ib6b0aae7cf9e1405c83f8b91131e04c765482d9a
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4174622
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Frederick Mayle <fmayle@google.com>
2023-01-20 18:26:56 +00:00
Zhao Liu
cc79897fc0 x86_64: Add a x86 config option to set CPUID hybrid flags
Add a new configure option in CpuConfigX86_64, and use this option to
set hybrid flags in CPUID for vCPU.
The flags include:
1. CPUID.07H.0H:EDX.Hybrid[bit 15];
2. The Atom/Core type flags in CPUID.1AH.EAX.

Co-Developed-by: Zhuocheng Ding <zhuocheng.ding@intel.com>

BUG=b:255908920
TEST=presubmit

Change-Id: I33663b56fd201221c5fa3557f80d1f5ec5a31c03
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4020038
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-01-13 07:42:47 +00:00
Daniel Verkamp
92c90a601b windows: fix whpx build
The extra vm_evt_wrtube parameter was added in b375cbf575 ("crosvm:
reduce kiwi feature flag usage"), but the WhpxVm::new() function was not
changed and does not take a SendTube parameter.

The cl introduces dormant vm_evt_wrtube too keep the diff minimum.

BUG=None
TEST=cargo build --target=x86_64-pc-windows-gnu --features=whpx

Change-Id: Ic0c77f67b5dfca1cf666caf94c53add0fe2bdf36
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133835
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-01-04 20:04:40 +00:00