summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2026-10-20 06:38:31 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2026-10-21 03:28:21 -0400
commit164405e8e9a0378c7e1aff2254625a6553a291f1 (patch)
treec0ed0a858bd738bc0753183ce659ff218cd76498 /include/linux
parent9bcd6af09e2a3493ee702c9aa1110002ed4e83e8 (diff)
KVM: always make in-place conversion a compile-time constant when possible
Remove the unnecessary static call indirection and make gmem_in_place_conversion a constant if CONFIG_KVM_PRIVATE_MEMATTR_VM is false. Require that CONFIG_KVM_PRIVATE_MEMATTR_VM be enabled together with CONFIG_KVM_GUEST_MEMFD and with a definition of kvm_arch_has_private_mem. This way, the three possible cases can be expressed without nested #ifs. Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/kvm_host.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 09c57d31d153..e7fc94e2910a 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -2585,15 +2585,7 @@ bool kvm_arch_post_set_vm_memory_attributes(struct kvm *kvm,
#endif /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
#ifdef CONFIG_KVM_PRIVATE_MEMATTR_VM
-static inline bool kvm_vm_is_private_gfn(struct kvm *kvm, gfn_t gfn)
-{
- return kvm_get_vm_memory_attributes(kvm, gfn) & KVM_MEMORY_ATTRIBUTE_PRIVATE;
-}
-#endif /* CONFIG_KVM_PRIVATE_MEMATTR_VM */
-
-#ifdef kvm_arch_has_private_mem
extern bool gmem_in_place_conversion;
-
typedef bool (kvm_is_private_gfn_t)(struct kvm *kvm, gfn_t gfn);
DECLARE_STATIC_CALL(__kvm_is_private_gfn, kvm_is_private_gfn_t);
@@ -2601,6 +2593,11 @@ static inline bool kvm_is_private_gfn(struct kvm *kvm, gfn_t gfn)
{
return static_call(__kvm_is_private_gfn)(kvm, gfn);
}
+
+#elif defined kvm_arch_has_private_mem
+#define gmem_in_place_conversion true
+#define kvm_is_private_gfn kvm_gmem_is_private_gfn
+
#else
#define gmem_in_place_conversion false