Commit 15b8f44
KVM: guest_memfd: Pass index, not gfn, to __kvm_gmem_get_pfn()
[ Upstream commit 4af18dc ]
Refactor guest_memfd usage of __kvm_gmem_get_pfn() to pass the index into
the guest_memfd file instead of the gfn, i.e. resolve the index based on
the slot+gfn in the caller instead of in __kvm_gmem_get_pfn(). This will
allow kvm_gmem_get_pfn() to retrieve and return the specific "struct page",
which requires the index into the folio, without a redoing the index
calculation multiple times (which isn't costly, just hard to follow).
Opportunistically add a kvm_gmem_get_index() helper to make the copy+pasted
code easier to understand.
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-46-seanjc@google.com>
Stable-dep-of: ae431059e75d ("KVM: guest_memfd: Remove bindings on memslot deletion when gmem is dying")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 4559d96554dc9d9680699166d86c5cc2d9ab1bc3)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>1 parent cf23e30 commit 15b8f44
1 file changed
+13
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
307 | 312 | | |
308 | 313 | | |
309 | 314 | | |
| |||
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
560 | 565 | | |
561 | | - | |
562 | 566 | | |
563 | 567 | | |
564 | 568 | | |
| |||
594 | 598 | | |
595 | 599 | | |
596 | 600 | | |
| 601 | + | |
597 | 602 | | |
598 | 603 | | |
599 | 604 | | |
| |||
602 | 607 | | |
603 | 608 | | |
604 | 609 | | |
605 | | - | |
| 610 | + | |
606 | 611 | | |
607 | 612 | | |
608 | 613 | | |
| |||
650 | 655 | | |
651 | 656 | | |
652 | 657 | | |
| 658 | + | |
653 | 659 | | |
654 | 660 | | |
655 | 661 | | |
| |||
658 | 664 | | |
659 | 665 | | |
660 | 666 | | |
661 | | - | |
| 667 | + | |
662 | 668 | | |
663 | 669 | | |
664 | 670 | | |
| |||
0 commit comments