mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
KVM: Rename KVM_GENERIC_MEMORY_ATTRIBUTES to KVM_VM_MEMORY_ATTRIBUTES
Rename the per-VM memory attributes Kconfig to make it explicitly about per-VM attributes in anticipation of adding memory attributes support to guest_memfd, at which point it will be possible (and desirable) to have memory attributes without the per-VM support, even in x86. No functional change intended. Signed-off-by: Ackerley Tng <ackerleytng@google.com> Tested-by: Shivank Garg <shivankg@amd.com> Reviewed-by: Fuad Tabba <tabba@google.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Tested-by: Yan Zhao <yan.y.zhao@intel.com> Link: https://patch.msgid.link/20260910-gmem-inplace-conversion-v13-4-dd6fbf94f4e1@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
1ae5be958f
commit
44e17d0a36
|
|
@ -1851,7 +1851,7 @@ enum kvm_intr_type {
|
|||
((vcpu) && (vcpu)->arch.handling_intr_from_guest && \
|
||||
(!!in_nmi() == ((vcpu)->arch.handling_intr_from_guest == KVM_HANDLING_NMI)))
|
||||
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
#define kvm_arch_has_private_mem(kvm) ((kvm)->arch.has_private_mem)
|
||||
#endif
|
||||
#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_CONVERT
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ config KVM_SW_PROTECTED_VM
|
|||
bool "Enable support for KVM software-protected VMs"
|
||||
depends on EXPERT
|
||||
depends on KVM_X86 && X86_64
|
||||
select KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
select KVM_VM_MEMORY_ATTRIBUTES
|
||||
help
|
||||
Enable support for KVM software-protected VMs. Currently, software-
|
||||
protected VMs are purely a development and testing vehicle for
|
||||
|
|
@ -135,7 +135,7 @@ config KVM_INTEL_TDX
|
|||
bool "Intel Trust Domain Extensions (TDX) support"
|
||||
default y
|
||||
depends on INTEL_TDX_HOST
|
||||
select KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
select KVM_VM_MEMORY_ATTRIBUTES
|
||||
select HAVE_KVM_ARCH_GMEM_POPULATE
|
||||
help
|
||||
Provides support for launching Intel Trust Domain Extensions (TDX)
|
||||
|
|
@ -159,7 +159,7 @@ config KVM_AMD_SEV
|
|||
depends on KVM_AMD && X86_64
|
||||
depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m)
|
||||
select ARCH_HAS_CC_PLATFORM
|
||||
select KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
select KVM_VM_MEMORY_ATTRIBUTES
|
||||
select HAVE_KVM_ARCH_GMEM_CONVERT
|
||||
select HAVE_KVM_ARCH_GMEM_RECLAIM
|
||||
select HAVE_KVM_ARCH_GMEM_INVALIDATE
|
||||
|
|
|
|||
|
|
@ -8097,7 +8097,7 @@ void kvm_mmu_pre_destroy_vm(struct kvm *kvm)
|
|||
vhost_task_stop(kvm->arch.nx_huge_page_recovery_thread);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
static bool hugepage_test_mixed(struct kvm_memory_slot *slot, gfn_t gfn,
|
||||
int level)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10140,7 +10140,7 @@ static int kvm_alloc_memslot_metadata(struct kvm *kvm,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
kvm_mmu_init_memslot_memory_attributes(kvm, slot);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifndef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
static inline bool kvm_arch_has_private_mem(struct kvm *kvm)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -872,7 +872,7 @@ struct kvm {
|
|||
#ifdef CONFIG_HAVE_KVM_PM_NOTIFIER
|
||||
struct notifier_block pm_notifier;
|
||||
#endif
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
/* Protected by slots_lock (for writes) and RCU (for reads) */
|
||||
struct xarray mem_attr_array;
|
||||
#endif
|
||||
|
|
@ -2560,7 +2560,7 @@ static inline bool kvm_memslot_is_gmem_only(const struct kvm_memory_slot *slot)
|
|||
return slot->flags & KVM_MEMSLOT_GMEM_ONLY;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
static inline unsigned long kvm_get_memory_attributes(struct kvm *kvm, gfn_t gfn)
|
||||
{
|
||||
return xa_to_value(xa_load(&kvm->mem_attr_array, gfn));
|
||||
|
|
@ -2582,7 +2582,7 @@ static inline bool kvm_mem_is_private(struct kvm *kvm, gfn_t gfn)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
|
||||
#endif /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
|
||||
|
||||
#ifdef CONFIG_KVM_GUEST_MEMFD
|
||||
int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot,
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ TRACE_EVENT(kvm_dirty_ring_exit,
|
|||
TP_printk("vcpu %d", __entry->vcpu_id)
|
||||
);
|
||||
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
/*
|
||||
* @start: Starting address of guest memory range
|
||||
* @end: End address of guest memory range
|
||||
|
|
@ -383,7 +383,7 @@ TRACE_EVENT(kvm_vm_set_mem_attributes,
|
|||
TP_printk("%#016llx -- %#016llx [0x%lx]",
|
||||
__entry->start, __entry->end, __entry->attr)
|
||||
);
|
||||
#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
|
||||
#endif /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
|
||||
|
||||
TRACE_EVENT(kvm_unmap_hva_range,
|
||||
TP_PROTO(unsigned long start, unsigned long end),
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ config KVM_ELIDE_TLB_FLUSH_IF_YOUNG
|
|||
config KVM_MMU_LOCKLESS_AGING
|
||||
bool
|
||||
|
||||
config KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
config KVM_VM_MEMORY_ATTRIBUTES
|
||||
bool
|
||||
|
||||
config KVM_GUEST_MEMFD
|
||||
|
|
|
|||
|
|
@ -1116,7 +1116,7 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)
|
|||
spin_lock_init(&kvm->mn_invalidate_lock);
|
||||
rcuwait_init(&kvm->mn_memslots_update_rcuwait);
|
||||
xa_init(&kvm->vcpu_array);
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
xa_init(&kvm->mem_attr_array);
|
||||
#endif
|
||||
|
||||
|
|
@ -1301,7 +1301,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
|
|||
cleanup_srcu_struct(&kvm->irq_srcu);
|
||||
srcu_barrier(&kvm->srcu);
|
||||
cleanup_srcu_struct(&kvm->srcu);
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
xa_destroy(&kvm->mem_attr_array);
|
||||
#endif
|
||||
kvm_arch_free_vm(kvm);
|
||||
|
|
@ -2438,7 +2438,7 @@ static int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm,
|
|||
}
|
||||
#endif /* CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT */
|
||||
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
static u64 kvm_supported_mem_attributes(struct kvm *kvm)
|
||||
{
|
||||
if (!kvm || kvm_arch_has_private_mem(kvm))
|
||||
|
|
@ -2643,7 +2643,7 @@ static int kvm_vm_ioctl_set_mem_attributes(struct kvm *kvm,
|
|||
|
||||
return kvm_vm_set_mem_attributes(kvm, start, end, attrs->attributes);
|
||||
}
|
||||
#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
|
||||
#endif /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
|
||||
|
||||
struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn)
|
||||
{
|
||||
|
|
@ -4960,7 +4960,7 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
|
|||
case KVM_CAP_SYSTEM_EVENT_DATA:
|
||||
case KVM_CAP_DEVICE_CTRL:
|
||||
return 1;
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
case KVM_CAP_MEMORY_ATTRIBUTES:
|
||||
return kvm_supported_mem_attributes(kvm);
|
||||
#endif
|
||||
|
|
@ -5364,7 +5364,7 @@ static long kvm_vm_ioctl(struct file *filp,
|
|||
break;
|
||||
}
|
||||
#endif /* CONFIG_HAVE_KVM_IRQ_ROUTING */
|
||||
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
|
||||
#ifdef CONFIG_KVM_VM_MEMORY_ATTRIBUTES
|
||||
case KVM_SET_MEMORY_ATTRIBUTES: {
|
||||
struct kvm_memory_attributes attrs;
|
||||
|
||||
|
|
@ -5375,7 +5375,7 @@ static long kvm_vm_ioctl(struct file *filp,
|
|||
r = kvm_vm_ioctl_set_mem_attributes(kvm, &attrs);
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
|
||||
#endif /* CONFIG_KVM_VM_MEMORY_ATTRIBUTES */
|
||||
case KVM_CREATE_DEVICE: {
|
||||
struct kvm_create_device cd;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user