]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: Pin (as in FOLL_PIN) pages during kvm_vcpu_map()
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:33 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 16:58:00 +0000 (12:58 -0400)
commit2bcb52a3602bf4cbc55d8fb4da00c930f83d7789
treebccd6ec12e60bfcf1e956f6a0060e65a76d023d8
parent2ff072ba7ad2deb1c3b2d231faa0ac3a25e2451b
KVM: Pin (as in FOLL_PIN) pages during kvm_vcpu_map()

Pin, as in FOLL_PIN, pages when mapping them for direct access by KVM.
As per Documentation/core-api/pin_user_pages.rst, writing to a page that
was gotten via FOLL_GET is explicitly disallowed.

  Correct (uses FOLL_PIN calls):
      pin_user_pages()
      write to the data within the pages
      unpin_user_pages()

  INCORRECT (uses FOLL_GET calls):
      get_user_pages()
      write to the data within the pages
      put_page()

Unfortunately, FOLL_PIN is a "private" flag, and so kvm_follow_pfn must
use a one-off bool instead of being able to piggyback the "flags" field.

Link: https://lwn.net/Articles/930667
Link: https://lore.kernel.org/all/cover.1683044162.git.lstoakes@gmail.com
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20241010182427.1434605-32-seanjc@google.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c
virt/kvm/kvm_mm.h