On Tue, Jan 17, 2023 at 1:39 PM Sean Christopherson seanjc@google.com wrote:
On Mon, Dec 05, 2022, Vishal Annapurve wrote:
Introduce HAVE_KVM_PRIVATE_MEM_TESTING config to be able to test fd based @@ -272,13 +274,15 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, .rsvd = err & PFERR_RSVD_MASK, .user = err & PFERR_USER_MASK, .prefetch = prefetch,
.is_tdp = likely(vcpu->arch.mmu->page_fault == kvm_tdp_page_fault),
.is_tdp = is_tdp, .nx_huge_page_workaround_enabled = is_nx_huge_page_enabled(vcpu->kvm), .max_level = KVM_MAX_HUGEPAGE_LEVEL, .req_level = PG_LEVEL_4K, .goal_level = PG_LEVEL_4K,
.is_private = IS_ENABLED(CONFIG_HAVE_KVM_PRIVATE_MEM_TESTING) && is_tdp &&
kvm_mem_is_private(vcpu->kvm, cr2_or_gpa >> PAGE_SHIFT),
After looking at the SNP+UPM series, I think we should forego a dedicated Kconfig for testing and instead add a new VM type for UPM-capable guests. The new type, e.g. KVM_X86_PROTECTED_VM, can then be used to leverage UPM for "legacy" SEV and SEV-ES guests, as well as for UPM-capable guests that don't utilize per-VM memory encryption, e.g. KVM selftests.
Carrying test-only behavior is obviously never ideal, and it would pretty much have to be mutually exclusive with "real" usage of UPM, otherwise the KVM logics gets unnecessarily complex.
Ack, the newly added VM type fits better here with SEV/SEV-ES and non-confidential selftests being able to share this framework.