The KVM_X86_SW_PROTECTED_VM type is meant for experimentation and does not have underlying support for protected guests. This makes it a good candidate for testing mapping shared memory. Therefore, only when the kconfig option for in-place shared memory is enabled (KVM_GMEM_SHARED_MEM), mark this type as supporting shared memory. This means that this memory is considered by guest_memfd to be shared with the host, which is now able to map and fault in guest_memfd memory belonging to this VM type. Signed-off-by: Fuad Tabba <tabba@xxxxxxxxxx> --- arch/x86/include/asm/kvm_host.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 709cc2a7ba66..1858dde449c3 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -2255,8 +2255,13 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level, #ifdef CONFIG_KVM_GMEM #define kvm_arch_supports_gmem(kvm) ((kvm)->arch.supports_gmem) + +#define kvm_arch_gmem_supports_shared_mem(kvm) \ + (IS_ENABLED(CONFIG_KVM_GMEM_SHARED_MEM) && \ + ((kvm)->arch.vm_type == KVM_X86_SW_PROTECTED_VM)) #else #define kvm_arch_supports_gmem(kvm) false +#define kvm_arch_gmem_supports_shared_mem(kvm) false #endif #define kvm_arch_has_readonly_mem(kvm) (!(kvm)->arch.has_protected_state) -- 2.49.0.901.g37484f566f-goog