Skip to content

Commit 03b755b

Browse files
committed
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 <[email protected]>
1 parent f2104bf commit 03b755b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/powerpc/kvm/e500_mmu_host.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
374374
unsigned long slot_start, slot_end;
375375

376376
pfnmap = 1;
377+
writable = vma->vm_flags & VM_WRITE;
377378

378379
start = vma->vm_pgoff;
379380
end = start +
@@ -449,7 +450,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
449450

450451
if (likely(!pfnmap)) {
451452
tsize_pages = 1UL << (tsize + 10 - PAGE_SHIFT);
452-
pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page);
453+
pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, &page);
453454
if (is_error_noslot_pfn(pfn)) {
454455
if (printk_ratelimit())
455456
pr_err("%s: real page not found for gfn %lx\n",
@@ -494,7 +495,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
494495
}
495496
local_irq_restore(flags);
496497

497-
kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, true);
498+
kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, writable);
498499
kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize,
499500
ref, gvaddr, stlbe);
500501
writable = tlbe_is_writable(stlbe);

0 commit comments

Comments
 (0)