Message ID | 20201113110952.68086-2-tsbogend@alpha.franken.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
Hi, Thomas, On Fri, Nov 13, 2020 at 7:13 PM Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote: > > 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. Is there some visible bugs if without this fix? Huacai > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> > --- > arch/mips/kvm/mmu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c > index 28c366d307e7..3dabeda82458 100644 > --- a/arch/mips/kvm/mmu.c > +++ b/arch/mips/kvm/mmu.c > @@ -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) { > @@ -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); > -- > 2.16.4 >
On Sat, Nov 14, 2020 at 03:34:14PM +0800, Huacai Chen wrote: > Hi, Thomas, > > On Fri, Nov 13, 2020 at 7:13 PM Thomas Bogendoerfer > <tsbogend@alpha.franken.de> wrote: > > > > 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. > Is there some visible bugs if without this fix? no exec isn't enabled for these mappings, if cpu supports it. Thomas.
Hi, Thomas, On Mon, Nov 16, 2020 at 8:35 PM Thomas Bogendoerfer <tsbogend@alpha.franken.de> wrote: > > On Sat, Nov 14, 2020 at 03:34:14PM +0800, Huacai Chen wrote: > > Hi, Thomas, > > > > On Fri, Nov 13, 2020 at 7:13 PM Thomas Bogendoerfer > > <tsbogend@alpha.franken.de> wrote: > > > > > > 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. > > Is there some visible bugs if without this fix? > > no exec isn't enabled for these mappings, if cpu supports it. The whole series wants to set XI if supported? Huacai Huacai > > Thomas. > > -- > Crap can work. Given enough thrust pigs will fly, but it's not necessarily a > good idea. [ RFC1925, 2.3 ]
On Tue, Nov 17, 2020 at 09:18:15AM +0800, Huacai Chen wrote: > Hi, Thomas, > > On Mon, Nov 16, 2020 at 8:35 PM Thomas Bogendoerfer > <tsbogend@alpha.franken.de> wrote: > > > > On Sat, Nov 14, 2020 at 03:34:14PM +0800, Huacai Chen wrote: > > > Hi, Thomas, > > > > > > On Fri, Nov 13, 2020 at 7:13 PM Thomas Bogendoerfer > > > <tsbogend@alpha.franken.de> wrote: > > > > > > > > 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. > > > Is there some visible bugs if without this fix? > > > > no exec isn't enabled for these mappings, if cpu supports it. > The whole series wants to set XI if supported? that and RI where possible. I want to get rid of the PAGE_* defines, because they lead to forgetting about RI and XI protection map setup, which doesn't use the defines and would need another set of defines. So by using only protection_map[] everything goes via one place. Thomas.
On Fri, Nov 13, 2020 at 12:09:50PM +0100, Thomas Bogendoerfer wrote: > 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> > --- > arch/mips/kvm/mmu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) applied to mips-next. Thomas.
diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index 28c366d307e7..3dabeda82458 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c @@ -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) { @@ -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);
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> --- arch/mips/kvm/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)