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

KVM: e500: use shadow TLB entry as witness for writability

kvmppc_e500_ref_setup is returning whether the guest TLB entry is writable,
which is than passed to kvm_release_faultin_page. This makes little sense
for two reasons: first, because the function sets up the private data for
the page and the return value feels like it has been bolted on the side;
second, because what really matters is whether the _shadow_ TLB entry is
writable. If it is not writable, the page can be released as non-dirty.
Shift from using tlbe_is_writable(gtlbe) to doing the same check on
the shadow TLB entry.

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

+3 -4
+3 -4
arch/powerpc/kvm/e500_mmu_host.c
··· 242 242 return tlbe->mas7_3 & (MAS3_SW|MAS3_UW); 243 243 } 244 244 245 - static inline bool kvmppc_e500_ref_setup(struct tlbe_ref *ref, 245 + static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref, 246 246 struct kvm_book3e_206_tlb_entry *gtlbe, 247 247 kvm_pfn_t pfn, unsigned int wimg) 248 248 { ··· 251 251 252 252 /* Use guest supplied MAS2_G and MAS2_E */ 253 253 ref->flags |= (gtlbe->mas2 & MAS2_ATTRIB_MASK) | wimg; 254 - 255 - return tlbe_is_writable(gtlbe); 256 254 } 257 255 258 256 static inline void kvmppc_e500_ref_release(struct tlbe_ref *ref) ··· 487 489 } 488 490 local_irq_restore(flags); 489 491 490 - writable = kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); 492 + kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); 491 493 kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, 492 494 ref, gvaddr, stlbe); 495 + writable = tlbe_is_writable(stlbe); 493 496 494 497 /* Clear i-cache for new pages */ 495 498 kvmppc_mmu_flush_icache(pfn);