Message ID | 20240227232100.478238-17-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | TDX/SNP part 1 of n, for 6.9 | expand |
On Tue, Feb 27, 2024 at 06:20:55PM -0500, Paolo Bonzini wrote: > Some SNP ioctls will require the page not to be in the pagecache, and as such they > will want to return EEXIST to userspace. Start by passing the error up from > filemap_grab_folio. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > virt/kvm/guest_memfd.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c > index 0f4e0cf4f158..de0d5a5c210c 100644 > --- a/virt/kvm/guest_memfd.c > +++ b/virt/kvm/guest_memfd.c > @@ -20,7 +20,7 @@ static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index) > /* TODO: Support huge pages. */ > folio = filemap_grab_folio(inode->i_mapping, index); > if (IS_ERR_OR_NULL(folio)) > - return NULL; > + return folio; I think it impacts kvm_gmem_get_pfn() { ... folio = kvm_gmem_get_folio(file_inode(file), index); if (!folio) { r = -ENOMEM; goto out_fput; } ... } Thanks, Yilun > > /* > * Use the up-to-date flag to track whether or not the memory has been > @@ -146,8 +146,8 @@ static long kvm_gmem_allocate(struct inode *inode, loff_t offset, loff_t len) > } > > folio = kvm_gmem_get_folio(inode, index); > - if (!folio) { > - r = -ENOMEM; > + if (IS_ERR_OR_NULL(folio)) { > + r = folio ? PTR_ERR(folio) : -ENOMEM; > break; > } > > -- > 2.39.0 > > >
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index 0f4e0cf4f158..de0d5a5c210c 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -20,7 +20,7 @@ static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index) /* TODO: Support huge pages. */ folio = filemap_grab_folio(inode->i_mapping, index); if (IS_ERR_OR_NULL(folio)) - return NULL; + return folio; /* * Use the up-to-date flag to track whether or not the memory has been @@ -146,8 +146,8 @@ static long kvm_gmem_allocate(struct inode *inode, loff_t offset, loff_t len) } folio = kvm_gmem_get_folio(inode, index); - if (!folio) { - r = -ENOMEM; + if (IS_ERR_OR_NULL(folio)) { + r = folio ? PTR_ERR(folio) : -ENOMEM; break; }
Some SNP ioctls will require the page not to be in the pagecache, and as such they will want to return EEXIST to userspace. Start by passing the error up from filemap_grab_folio. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- virt/kvm/guest_memfd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)