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

Peter Xu
2025-01-20T22:42:26Z

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