lkml.org 
[lkml]   [2022]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 12/12] KVM: Expose KVM_MEM_PRIVATE
On 18.01.2022 14:21, Chao Peng wrote:
> KVM_MEM_PRIVATE is not exposed by default but architecture code can turn
> on it by implementing kvm_arch_private_memory_supported().
>
> Also private memslot cannot be movable and the same file+offset can not
> be mapped into different GFNs.
>
> Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
(..)
>
> static bool kvm_check_memslot_overlap(struct kvm_memslots *slots, int id,
> - gfn_t start, gfn_t end)
> + struct file *file,
> + gfn_t start, gfn_t end,
> + loff_t start_off, loff_t end_off)
> {
> struct kvm_memslot_iter iter;
> + struct kvm_memory_slot *slot;
> + struct inode *inode;
> + int bkt;
>
> kvm_for_each_memslot_in_gfn_range(&iter, slots, start, end) {
> if (iter.slot->id != id)
> return true;
> }
>
> + /* Disallow mapping the same file+offset into multiple gfns. */
> + if (file) {
> + inode = file_inode(file);
> + kvm_for_each_memslot(slot, bkt, slots) {
> + if (slot->private_file &&
> + file_inode(slot->private_file) == inode &&
> + !(end_off <= slot->private_offset ||
> + start_off >= slot->private_offset
> + + (slot->npages >> PAGE_SHIFT)))
> + return true;
> + }
> + }

That's a linear scan of all memslots on each CREATE (and MOVE) operation
with a fd - we just spent more than a year rewriting similar linear scans
into more efficient operations in KVM.

Thanks,
Maciej

\
 
 \ /
  Last update: 2022-01-25 21:22    [W:0.304 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site