Skip to content

Commit 923310b

Browse files
Fuad Tabbabonzini
authored andcommitted
KVM: Rename kvm_slot_can_be_private() to kvm_slot_has_gmem()
Rename kvm_slot_can_be_private() to kvm_slot_has_gmem() to improve clarity and accurately reflect its purpose. The function kvm_slot_can_be_private() was previously used to check if a given kvm_memory_slot is backed by guest_memfd. However, its name implied that the memory in such a slot was exclusively "private". As guest_memfd support expands to include non-private memory (e.g., shared host mappings), it's important to remove this association. The new name, kvm_slot_has_gmem(), states that the slot is backed by guest_memfd without making assumptions about the memory's privacy attributes. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Shivank Garg <shivankg@amd.com> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Co-developed-by: David Hildenbrand <david@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Fuad Tabba <tabba@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20250729225455.670324-7-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 36cf63b commit 923310b

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

arch/x86/kvm/mmu/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,7 +3312,7 @@ static int __kvm_mmu_max_mapping_level(struct kvm *kvm,
33123312
int kvm_mmu_max_mapping_level(struct kvm *kvm,
33133313
const struct kvm_memory_slot *slot, gfn_t gfn)
33143314
{
3315-
bool is_private = kvm_slot_can_be_private(slot) &&
3315+
bool is_private = kvm_slot_has_gmem(slot) &&
33163316
kvm_mem_is_private(kvm, gfn);
33173317

33183318
return __kvm_mmu_max_mapping_level(kvm, slot, gfn, PG_LEVEL_NUM, is_private);
@@ -4551,7 +4551,7 @@ static int kvm_mmu_faultin_pfn_private(struct kvm_vcpu *vcpu,
45514551
{
45524552
int max_order, r;
45534553

4554-
if (!kvm_slot_can_be_private(fault->slot)) {
4554+
if (!kvm_slot_has_gmem(fault->slot)) {
45554555
kvm_mmu_prepare_memory_fault_exit(vcpu, fault);
45564556
return -EFAULT;
45574557
}

arch/x86/kvm/svm/sev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,7 +2361,7 @@ static int snp_launch_update(struct kvm *kvm, struct kvm_sev_cmd *argp)
23612361
mutex_lock(&kvm->slots_lock);
23622362

23632363
memslot = gfn_to_memslot(kvm, params.gfn_start);
2364-
if (!kvm_slot_can_be_private(memslot)) {
2364+
if (!kvm_slot_has_gmem(memslot)) {
23652365
ret = -EINVAL;
23662366
goto out;
23672367
}
@@ -4715,7 +4715,7 @@ void sev_handle_rmp_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code)
47154715
}
47164716

47174717
slot = gfn_to_memslot(kvm, gfn);
4718-
if (!kvm_slot_can_be_private(slot)) {
4718+
if (!kvm_slot_has_gmem(slot)) {
47194719
pr_warn_ratelimited("SEV: Unexpected RMP fault, non-private slot for GPA 0x%llx\n",
47204720
gpa);
47214721
return;

include/linux/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ struct kvm_memory_slot {
615615
#endif
616616
};
617617

618-
static inline bool kvm_slot_can_be_private(const struct kvm_memory_slot *slot)
618+
static inline bool kvm_slot_has_gmem(const struct kvm_memory_slot *slot)
619619
{
620620
return slot && (slot->flags & KVM_MEM_GUEST_MEMFD);
621621
}

virt/kvm/guest_memfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ long kvm_gmem_populate(struct kvm *kvm, gfn_t start_gfn, void __user *src, long
643643
return -EINVAL;
644644

645645
slot = gfn_to_memslot(kvm, start_gfn);
646-
if (!kvm_slot_can_be_private(slot))
646+
if (!kvm_slot_has_gmem(slot))
647647
return -EINVAL;
648648

649649
file = kvm_gmem_get_file(slot);

0 commit comments

Comments
 (0)