Skip to content

Commit d284562

Browse files
committed
Merge tag 'kvm-x86-generic-6.17' of https://github.com/kvm-x86/linux into HEAD
KVM generic changes for 6.17 - Add a tracepoint for KVM_SET_MEMORY_ATTRIBUTES to help debug issues related to private <=> shared memory conversions. - Drop guest_memfd's .getattr() implementation as the VFS layer will call generic_fillattr() if inode_operations.getattr is NULL.
2 parents f05efcf + 87d4fbf commit d284562

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

include/trace/events/kvm.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,33 @@ TRACE_EVENT(kvm_dirty_ring_exit,
393393
TP_printk("vcpu %d", __entry->vcpu_id)
394394
);
395395

396+
#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
397+
/*
398+
* @start: Starting address of guest memory range
399+
* @end: End address of guest memory range
400+
* @attr: The value of the attribute being set.
401+
*/
402+
TRACE_EVENT(kvm_vm_set_mem_attributes,
403+
TP_PROTO(gfn_t start, gfn_t end, unsigned long attr),
404+
TP_ARGS(start, end, attr),
405+
406+
TP_STRUCT__entry(
407+
__field(gfn_t, start)
408+
__field(gfn_t, end)
409+
__field(unsigned long, attr)
410+
),
411+
412+
TP_fast_assign(
413+
__entry->start = start;
414+
__entry->end = end;
415+
__entry->attr = attr;
416+
),
417+
418+
TP_printk("%#016llx -- %#016llx [0x%lx]",
419+
__entry->start, __entry->end, __entry->attr)
420+
);
421+
#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
422+
396423
TRACE_EVENT(kvm_unmap_hva_range,
397424
TP_PROTO(unsigned long start, unsigned long end),
398425
TP_ARGS(start, end),

virt/kvm/guest_memfd.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -382,23 +382,12 @@ static const struct address_space_operations kvm_gmem_aops = {
382382
#endif
383383
};
384384

385-
static int kvm_gmem_getattr(struct mnt_idmap *idmap, const struct path *path,
386-
struct kstat *stat, u32 request_mask,
387-
unsigned int query_flags)
388-
{
389-
struct inode *inode = path->dentry->d_inode;
390-
391-
generic_fillattr(idmap, request_mask, inode, stat);
392-
return 0;
393-
}
394-
395385
static int kvm_gmem_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
396386
struct iattr *attr)
397387
{
398388
return -EINVAL;
399389
}
400390
static const struct inode_operations kvm_gmem_iops = {
401-
.getattr = kvm_gmem_getattr,
402391
.setattr = kvm_gmem_setattr,
403392
};
404393

virt/kvm/kvm_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2558,9 +2558,11 @@ static int kvm_vm_set_mem_attributes(struct kvm *kvm, gfn_t start, gfn_t end,
25582558

25592559
entry = attributes ? xa_mk_value(attributes) : NULL;
25602560

2561+
trace_kvm_vm_set_mem_attributes(start, end, attributes);
2562+
25612563
mutex_lock(&kvm->slots_lock);
25622564

2563-
/* Nothing to do if the entire range as the desired attributes. */
2565+
/* Nothing to do if the entire range has the desired attributes. */
25642566
if (kvm_range_has_memory_attributes(kvm, start, end, ~0, attributes))
25652567
goto out_unlock;
25662568

0 commit comments

Comments
 (0)