Skip to content

Commit 3d89c2e

Browse files
committed
KVM: PPC: Book3S HV: Remove user-triggerable WARN_ON
Although in general we do not expect valid PTEs to be found in kvmppc_create_pte when we are inserting a large page mapping, there is one situation where this can occur. That is when dirty page logging is turned off for a memslot while the VM is running. Because the new memslots are installed before the old memslot is flushed in kvmppc_core_commit_memory_region_hv(), there is a window where a hypervisor page fault can try to install a 2MB (or 1GB) page where there are already small page mappings which were installed while dirty page logging was enabled and which have not yet been flushed. Since we have a situation where valid PTEs can legitimately be found by kvmppc_unmap_free_pte, and which can be triggered by userspace, just remove the WARN_ON_ONCE, since it is undesirable to have userspace able to trigger a kernel warning. Signed-off-by: Paul Mackerras <[email protected]>
1 parent e3326ae commit 3d89c2e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/powerpc/kvm/book3s_64_mmu_radix.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,13 @@ void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa,
429429
* Callers are responsible for flushing the PWC.
430430
*
431431
* When page tables are being unmapped/freed as part of page fault path
432-
* (full == false), ptes are not expected. There is code to unmap them
433-
* and emit a warning if encountered, but there may already be data
434-
* corruption due to the unexpected mappings.
432+
* (full == false), valid ptes are generally not expected; however, there
433+
* is one situation where they arise, which is when dirty page logging is
434+
* turned off for a memslot while the VM is running. The new memslot
435+
* becomes visible to page faults before the memslot commit function
436+
* gets to flush the memslot, which can lead to a 2MB page mapping being
437+
* installed for a guest physical address where there are already 64kB
438+
* (or 4kB) mappings (of sub-pages of the same 2MB page).
435439
*/
436440
static void kvmppc_unmap_free_pte(struct kvm *kvm, pte_t *pte, bool full,
437441
unsigned int lpid)
@@ -445,7 +449,6 @@ static void kvmppc_unmap_free_pte(struct kvm *kvm, pte_t *pte, bool full,
445449
for (it = 0; it < PTRS_PER_PTE; ++it, ++p) {
446450
if (pte_val(*p) == 0)
447451
continue;
448-
WARN_ON_ONCE(1);
449452
kvmppc_unmap_pte(kvm, p,
450453
pte_pfn(*p) << PAGE_SHIFT,
451454
PAGE_SHIFT, NULL, lpid);

0 commit comments

Comments
 (0)