Re: [RFC PATCH 27/39] KVM: guest_memfd: Allow mmapping guest_memfd files

Ackerley Tng
2025-04-23T20:25:49Z

Peter Xu <peterx@redhat.com> writes:

> On Tue, Sep 10, 2024 at 11:43:58PM +0000, Ackerley Tng wrote:
>> @@ -790,6 +791,9 @@ static long kvm_gmem_punch_hole(struct inode *inode, loff_t offset, loff_t len)
>> */
>> filemap_invalidate_lock(inode->i_mapping);
>>
>> + /* TODO: Check if even_cows should be 0 or 1 */
>> + unmap_mapping_range(inode->i_mapping, start, len, 0);
>> +
>> list_for_each_entry(gmem, gmem_list, entry)
>> kvm_gmem_invalidate_begin(gmem, start, end);
>>
>> @@ -946,6 +950,9 @@ static void kvm_gmem_hugetlb_teardown(struct inode *inode)
>> {
>> struct kvm_gmem_hugetlb *hgmem;
>>
>> + /* TODO: Check if even_cows should be 0 or 1 */
>> + unmap_mapping_range(inode->i_mapping, 0, LLONG_MAX, 0);
>
> Setting to 0 is ok in both places: even_cows only applies to MAP_PRIVATE,
> which gmemfd doesn't support. So feel free to drop the two comment lines.
>
> Thanks,
>
> --
> Peter Xu

Thank you for reviewing and helping me check on this!