x86_64: Redesign MTRR setting

Currently MTRR setting is: the default cache type is write back and the
pci low mmio range is uncache, then guest memory is WB by default, but
pci high mmio and the gap between ram end and pci start below 4G are WB
also, this part is wrong. In order to fix it, var mtrr should be used to
set pci high mmio as uncache, but pci high mmio is too large to have
enough var mtrrs.

This commit change MTRR setting as: the default cache type is uncache,
and the guest memory is WB. So memory range below 4G and above 4G are
passed into setup_msrs(). And the variable MTRR registers are limited
and have base and length requirement, so guest memory size is aligned
to 256MB to avoid MTRR failure.

BUG=None
TEST=check guest mtrr setting with different guest memory size

Change-Id: I4c18e83ce5e7fac9ac1bf6e174116a69924184ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578015
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
4 files changed
tree: ba0d18ab35a857f64c95c56f984506fd8bd91f5f
  1. .cargo/
  2. .devcontainer/
  3. .github/
  4. aarch64/
  5. acpi_tables/
  6. arch/
  7. base/
  8. bin/
  9. bit_field/
  10. ci/
  11. common/
  12. cros_async/
  13. crosvm-fuzz/
  14. crosvm_control/
  15. crosvm_plugin/
  16. devices/
  17. disk/
  18. docs/
  19. fuse/
  20. gpu_display/
  21. hypervisor/
  22. infra/
  23. integration_tests/
  24. io_uring/
  25. kernel_cmdline/
  26. kernel_loader/
  27. kvm/
  28. kvm_sys/
  29. libcras_stub/
  30. linux_input_sys/
  31. logo/
  32. media/
  33. net_sys/
  34. net_util/
  35. power_monitor/
  36. protos/
  37. qcow_utils/
  38. resources/
  39. rutabaga_gfx/
  40. seccomp/
  41. serde_keyvalue/
  42. src/
  43. system_api_stub/
  44. tests/
  45. third_party/
  46. tools/
  47. tpm2/
  48. tpm2-sys/
  49. tube_transporter/
  50. usb_sys/
  51. usb_util/
  52. vfio_sys/
  53. vhost/
  54. virtio_sys/
  55. vm_control/
  56. vm_memory/
  57. win_util/
  58. x86_64/
  59. .dockerignore
  60. .gitignore
  61. .gitmodules
  62. .rustfmt.toml
  63. ARCHITECTURE.md
  64. Cargo.toml
  65. CONTRIBUTING.md
  66. LICENSE
  67. navbar.md
  68. OWNERS
  69. README.chromeos.md
  70. README.md
  71. run_tests
  72. rust-toolchain
  73. setup_cros_cargo.sh
  74. test_all
  75. unblocked_terms.txt
README.md

crosvm - The Chrome OS Virtual Machine Monitor

crosvm is a virtual machine monitor (VMM) based on Linux’s KVM hypervisor, with a focus on simplicity, security, and speed. crosvm is intended to run Linux guests, originally as a security boundary for running native applications on the Chrome OS platform. Compared to QEMU, crosvm doesn’t emulate architectures or real hardware, instead concentrating on paravirtualized devices, such as the virtio standard.

crosvm is currently used to run Linux/Android guests on Chrome OS devices.

Logo