[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 36/70] kvm/tdx: Don't complain when converting vMMIO region to
|
From: |
Xiaoyao Li |
|
Subject: |
[PATCH v3 36/70] kvm/tdx: Don't complain when converting vMMIO region to shared |
|
Date: |
Wed, 15 Nov 2023 02:14:45 -0500 |
From: Isaku Yamahata <isaku.yamahata@intel.com>
Because vMMIO region needs to be shared region, guest TD may explicitly
convert such region from private to shared. Don't complain such
conversion.
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
accel/kvm/kvm-all.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 316690d113d0..5e862db4af41 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2933,17 +2933,19 @@ static int kvm_convert_memory(hwaddr start, hwaddr
size, bool to_private)
{
MemoryRegionSection section;
ram_addr_t offset;
+ MemoryRegion *mr;
RAMBlock *rb;
void *addr;
int ret = -1;
trace_kvm_convert_memory(start, size, to_private ? "shared_to_private" :
"private_to_shared");
section = memory_region_find(get_system_memory(), start, size);
- if (!section.mr) {
+ mr = section.mr;
+ if (!mr) {
return ret;
}
- if (memory_region_has_guest_memfd(section.mr)) {
+ if (memory_region_has_guest_memfd(mr)) {
if (to_private) {
ret = kvm_set_memory_attributes_private(start, size);
} else {
@@ -2965,9 +2967,22 @@ static int kvm_convert_memory(hwaddr start, hwaddr size,
bool to_private)
*/
ram_block_convert_range(rb, offset, size, to_private);
} else {
- warn_report("Convert non guest_memfd backed memory region "
- "(0x%"HWADDR_PRIx" ,+ 0x%"HWADDR_PRIx") to %s",
- start, size, to_private ? "private" : "shared");
+ /*
+ * Because vMMIO region must be shared, guest TD may convert vMMIO
+ * region to shared explicitly. Don't complain such case. See
+ * memory_region_type() for checking if the region is MMIO region.
+ */
+ if (!to_private &&
+ !memory_region_is_ram(mr) &&
+ !memory_region_is_ram_device(mr) &&
+ !memory_region_is_rom(mr) &&
+ !memory_region_is_romd(mr)) {
+ ret = 0;
+ } else {
+ warn_report("Convert non guest_memfd backed memory region "
+ "(0x%"HWADDR_PRIx" ,+ 0x%"HWADDR_PRIx") to %s",
+ start, size, to_private ? "private" : "shared");
+ }
}
memory_region_unref(section.mr);
--
2.34.1
- [PATCH v3 26/70] i386/tdx: Initialize TDX before creating TD vcpus, (continued)
- [PATCH v3 26/70] i386/tdx: Initialize TDX before creating TD vcpus, Xiaoyao Li, 2023/11/15
- [PATCH v3 27/70] i386/tdx: Add property sept-ve-disable for tdx-guest object, Xiaoyao Li, 2023/11/15
- [PATCH v3 28/70] i386/tdx: Make sept_ve_disable set by default, Xiaoyao Li, 2023/11/15
- [PATCH v3 29/70] i386/tdx: Wire CPU features up with attributes of TD guest, Xiaoyao Li, 2023/11/15
- [PATCH v3 30/70] i386/tdx: Validate TD attributes, Xiaoyao Li, 2023/11/15
- [PATCH v3 31/70] i386/tdx: Allows mrconfigid/mrowner/mrownerconfig for TDX_INIT_VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 32/70] i386/tdx: Implement user specified tsc frequency, Xiaoyao Li, 2023/11/15
- [PATCH v3 33/70] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 34/70] kvm/memory: Introduce the infrastructure to set the default shared/private value, Xiaoyao Li, 2023/11/15
- [PATCH v3 35/70] i386/tdx: Make memory type private by default, Xiaoyao Li, 2023/11/15
- [PATCH v3 36/70] kvm/tdx: Don't complain when converting vMMIO region to shared,
Xiaoyao Li <=
- [PATCH v3 37/70] kvm/tdx: Ignore memory conversion to shared of unassigned region, Xiaoyao Li, 2023/11/15
- [PATCH v3 38/70] i386/tdvf: Introduce function to parse TDVF metadata, Xiaoyao Li, 2023/11/15
- [PATCH v3 39/70] i386/tdx: Parse TDVF metadata for TDX VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 40/70] i386/tdx: Skip BIOS shadowing setup, Xiaoyao Li, 2023/11/15
- [PATCH v3 41/70] i386/tdx: Don't initialize pc.rom for TDX VMs, Xiaoyao Li, 2023/11/15
- [PATCH v3 42/70] i386/tdx: Track mem_ptr for each firmware entry of TDVF, Xiaoyao Li, 2023/11/15
- [PATCH v3 43/70] i386/tdx: Track RAM entries for TDX VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 44/70] headers: Add definitions from UEFI spec for volumes, resources, etc..., Xiaoyao Li, 2023/11/15
- [PATCH v3 45/70] i386/tdx: Setup the TD HOB list, Xiaoyao Li, 2023/11/15
- [PATCH v3 47/70] memory: Introduce memory_region_init_ram_guest_memfd(), Xiaoyao Li, 2023/11/15