[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 35/66] kvm/tdx: Ignore memory conversion to shared of unassign
|
From: |
Xiaoyao Li |
|
Subject: |
[PATCH v4 35/66] kvm/tdx: Ignore memory conversion to shared of unassigned region |
|
Date: |
Wed, 24 Jan 2024 22:22:57 -0500 |
From: Isaku Yamahata <isaku.yamahata@intel.com>
TDX requires vMMIO region to be shared. For KVM, MMIO region is the region
which kvm memslot isn't assigned to (except in-kernel emulation).
qemu has the memory region for vMMIO at each device level.
While OVMF issues MapGPA(to-shared) conservatively on 32bit PCI MMIO
region, qemu doesn't find corresponding vMMIO region because it's before
PCI device allocation and memory_region_find() finds the device region, not
PCI bus region. It's safe to ignore MapGPA(to-shared) because when guest
accesses those region they use GPA with shared bit set for vMMIO. Ignore
memory conversion request of non-assigned region to shared and return
success. Otherwise OVMF is confused and panics there.
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
accel/kvm/kvm-all.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index e26e9121b30d..eb8b3925dbe1 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2943,6 +2943,18 @@ static int kvm_convert_memory(hwaddr start, hwaddr size,
bool to_private)
section = memory_region_find(get_system_memory(), start, size);
mr = section.mr;
if (!mr) {
+ /*
+ * Ignore converting non-assigned region to shared.
+ *
+ * TDX requires vMMIO region to be shared to inject #VE to guest.
+ * OVMF issues conservatively MapGPA(shared) on 32bit PCI MMIO region,
+ * and vIO-APIC 0xFEC00000 4K page.
+ * OVMF assigns 32bit PCI MMIO region to
+ * [top of low memory: typically 2GB=0xC000000, 0xFC00000)
+ */
+ if (!to_private) {
+ return 0;
+ }
return -1;
}
--
2.34.1
- [PATCH v4 28/66] i386/tdx: Validate TD attributes, (continued)
- [PATCH v4 28/66] i386/tdx: Validate TD attributes, Xiaoyao Li, 2024/01/24
- [PATCH v4 26/66] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2024/01/24
- [PATCH v4 29/66] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig, Xiaoyao Li, 2024/01/24
- [PATCH v4 30/66] i386/tdx: Implement user specified tsc frequency, Xiaoyao Li, 2024/01/24
- [PATCH v4 31/66] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM, Xiaoyao Li, 2024/01/24
- [PATCH v4 32/66] kvm/memory: Introduce the infrastructure to set the default shared/private value, Xiaoyao Li, 2024/01/24
- [PATCH v4 34/66] kvm/tdx: Don't complain when converting vMMIO region to shared, Xiaoyao Li, 2024/01/24
- [PATCH v4 33/66] i386/tdx: Make memory type private by default, Xiaoyao Li, 2024/01/24
- [PATCH v4 36/66] i386/tdvf: Introduce function to parse TDVF metadata, Xiaoyao Li, 2024/01/24
- [PATCH v4 35/66] kvm/tdx: Ignore memory conversion to shared of unassigned region,
Xiaoyao Li <=
- [PATCH v4 37/66] i386/tdx: Parse TDVF metadata for TDX VM, Xiaoyao Li, 2024/01/24
- [PATCH v4 38/66] i386/tdx: Skip BIOS shadowing setup, Xiaoyao Li, 2024/01/24
- [PATCH v4 39/66] i386/tdx: Don't initialize pc.rom for TDX VMs, Xiaoyao Li, 2024/01/24
- [PATCH v4 40/66] i386/tdx: Track mem_ptr for each firmware entry of TDVF, Xiaoyao Li, 2024/01/24
- [PATCH v4 42/66] headers: Add definitions from UEFI spec for volumes, resources, etc..., Xiaoyao Li, 2024/01/24
- [PATCH v4 41/66] i386/tdx: Track RAM entries for TDX VM, Xiaoyao Li, 2024/01/24
- [PATCH v4 43/66] i386/tdx: Setup the TD HOB list, Xiaoyao Li, 2024/01/24
- [PATCH v4 45/66] memory: Introduce memory_region_init_ram_guest_memfd(), Xiaoyao Li, 2024/01/24
- [PATCH v4 44/66] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION, Xiaoyao Li, 2024/01/24