]> www.infradead.org Git - nvme.git/commit
KVM: guest_memfd: delay folio_mark_uptodate() until after successful preparation
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 11 Jul 2024 22:27:45 +0000 (18:27 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 26 Jul 2024 18:46:14 +0000 (14:46 -0400)
commitd04c77d231223563405e8874fa7edfdc65e545fe
tree74976dd8c68e1a920dc5e66a6c71852d118bcf78
parentd0d87226f535965b4dafc6ef79246456503a4503
KVM: guest_memfd: delay folio_mark_uptodate() until after successful preparation

The up-to-date flag as is now is not too useful; it tells guest_memfd not
to overwrite the contents of a folio, but it doesn't say that the page
is ready to be mapped into the guest.  For encrypted guests, mapping
a private page requires that the "preparation" phase has succeeded,
and at the same time the same page cannot be prepared twice.

So, ensure that folio_mark_uptodate() is only called on a prepared page.  If
kvm_gmem_prepare_folio() or the post_populate callback fail, the folio
will not be marked up-to-date; it's not a problem to call clear_highpage()
again on such a page prior to the next preparation attempt.

Reviewed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/guest_memfd.c