Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: e500: map readonly host pages for read

The new __kvm_faultin_pfn() function is upset by the fact that e500 KVM
ignores host page permissions - __kvm_faultin requires a "writable"
outgoing argument, but e500 KVM is nonchalantly passing NULL.

If the host page permissions do not include writability, the shadow
TLB entry is forcibly mapped read-only.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

+3 -2
+3 -2
arch/powerpc/kvm/e500_mmu_host.c
··· 374 374 unsigned long slot_start, slot_end; 375 375 376 376 pfnmap = 1; 377 + writable = vma->vm_flags & VM_WRITE; 377 378 378 379 start = vma->vm_pgoff; 379 380 end = start + ··· 450 449 451 450 if (likely(!pfnmap)) { 452 451 tsize_pages = 1UL << (tsize + 10 - PAGE_SHIFT); 453 - pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page); 452 + pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, &page); 454 453 if (is_error_noslot_pfn(pfn)) { 455 454 if (printk_ratelimit()) 456 455 pr_err("%s: real page not found for gfn %lx\n", ··· 495 494 } 496 495 local_irq_restore(flags); 497 496 498 - kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, true); 497 + kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, writable); 499 498 kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, 500 499 ref, gvaddr, stlbe); 501 500 writable = tlbe_is_writable(stlbe);