Skip to content

Commit

Permalink
MIPS: kvm: Use vm_get_page_prot to get protection bits
Browse files Browse the repository at this point in the history
MIPS protection bits are setup during runtime so using defines like
PAGE_SHARED ignores this runtime changes. Using vm_get_page_prot
to get correct page protection fixes this.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
  • Loading branch information
Thomas Bogendoerfer committed Nov 19, 2020
1 parent 724d554 commit 411406a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/mips/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ int kvm_mips_handle_commpage_tlb_fault(unsigned long badvaddr,
{
kvm_pfn_t pfn;
pte_t *ptep;
pgprot_t prot;

ptep = kvm_trap_emul_pte_for_gva(vcpu, badvaddr);
if (!ptep) {
Expand All @@ -1083,7 +1084,8 @@ int kvm_mips_handle_commpage_tlb_fault(unsigned long badvaddr,

pfn = PFN_DOWN(virt_to_phys(vcpu->arch.kseg0_commpage));
/* Also set valid and dirty, so refill handler doesn't have to */
*ptep = pte_mkyoung(pte_mkdirty(pfn_pte(pfn, PAGE_SHARED)));
prot = vm_get_page_prot(VM_READ|VM_WRITE|VM_SHARED);
*ptep = pte_mkyoung(pte_mkdirty(pfn_pte(pfn, prot)));

/* Invalidate this entry in the TLB, guest kernel ASID only */
kvm_mips_host_tlb_inv(vcpu, badvaddr, false, true);
Expand Down

0 comments on commit 411406a

Please sign in to comment.