[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 57/63] kvm/tdx: Ignore memory conversion to shared of unassigned r
From: |
Paolo Bonzini |
Subject: |
[PULL 57/63] kvm/tdx: Ignore memory conversion to shared of unassigned region |
Date: |
Tue, 23 Apr 2024 17:09:45 +0200 |
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>
Message-ID: <20240229063726.610065-35-xiaoyao.li@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.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 0911154bf8e..d7281b93f3b 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2923,6 +2923,18 @@ 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.44.0
- [PULL 41/63] KVM: remove kvm_arch_cpu_check_are_resettable, (continued)
- [PULL 41/63] KVM: remove kvm_arch_cpu_check_are_resettable, Paolo Bonzini, 2024/04/23
- [PULL 37/63] scripts/update-linux-headers: Add bits.h to file imports, Paolo Bonzini, 2024/04/23
- [PULL 44/63] target/i386: SEV: use KVM_SEV_INIT2 if possible, Paolo Bonzini, 2024/04/23
- [PULL 45/63] i386/sev: Add 'legacy-vm-type' parameter for SEV guest objects, Paolo Bonzini, 2024/04/23
- [PULL 46/63] hw/i386/sev: Use legacy SEV VM types for older machine types, Paolo Bonzini, 2024/04/23
- [PULL 50/63] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot, Paolo Bonzini, 2024/04/23
- [PULL 49/63] RAMBlock: Add support of KVM private guest memfd, Paolo Bonzini, 2024/04/23
- [PULL 51/63] kvm/memory: Make memory type private by default if it has guest memfd backend, Paolo Bonzini, 2024/04/23
- [PULL 62/63] pythondeps.toml: warn about updates needed to docs/requirements.txt, Paolo Bonzini, 2024/04/23
- [PULL 52/63] HostMem: Add mechanism to opt in kvm guest memfd via MachineState, Paolo Bonzini, 2024/04/23
- [PULL 57/63] kvm/tdx: Ignore memory conversion to shared of unassigned region,
Paolo Bonzini <=
- [PULL 31/63] hw/i386/acpi: Set PCAT_COMPAT bit only when pic is not disabled, Paolo Bonzini, 2024/04/23
- [PULL 40/63] KVM: track whether guest state is encrypted, Paolo Bonzini, 2024/04/23
- [PULL 47/63] trace/kvm: Split address space and slot id in trace_kvm_set_user_memory(), Paolo Bonzini, 2024/04/23
- [PULL 18/63] stubs: move monitor_fdsets_cleanup with other fdset stubs, Paolo Bonzini, 2024/04/23
- [PULL 16/63] stubs: split record/replay stubs further, Paolo Bonzini, 2024/04/23
- [PULL 26/63] target/i386: Introduce Icelake-Server-v7 to enable TSX, Paolo Bonzini, 2024/04/23
- [PULL 28/63] target/i386: Export RFDS bit to guests, Paolo Bonzini, 2024/04/23
- [PULL 35/63] s390: Switch to use confidential_guest_kvm_init(), Paolo Bonzini, 2024/04/23
- [PULL 43/63] target/i386: Implement mc->kvm_type() to get VM type, Paolo Bonzini, 2024/04/23