Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jan 2020 08:12:23 -0300
From:      Leandro Lupori <leandro.lupori@gmail.com>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        Justin Hibbits <chmeeedalf@gmail.com>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>,  "bdragon@freebsd.org" <bdragon@freebsd.org>
Subject:   Re: A possible unbounded loop in moea_sync_icache: why sys/vm/mlock_test:mlock__copy_on_write_vnode fails?
Message-ID:  <CAC7XEcJgXZMBb1q8TrqERWwWHLq9g=NNC0hiG7ZAH7kvASYK1g@mail.gmail.com>
In-Reply-To: <022334D3-B60E-440F-A514-8D8002B65CB4@yahoo.com>
References:  <022334D3-B60E-440F-A514-8D8002B65CB4.ref@yahoo.com> <022334D3-B60E-440F-A514-8D8002B65CB4@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Interesting, this looks like the same issue that was fixed on 64-bit some
time ago: https://reviews.freebsd.org/D19149.

On Thu, Jan 9, 2020 at 3:03 AM Mark Millard via freebsd-ppc <
freebsd-ppc@freebsd.org> wrote:

> In the statement:
>
>                 lim = round_page(va);
>
> later below in moea_sync_icache, it uses:
>
> #define round_page(x)           (((x) + PAGE_MASK) & ~PAGE_MASK)
>
> So, for PAGE_MASK==(4096u-1u) the statement translates
> to, in essence (the u's are conceptual here):
>
>                 lim = ((va)+4095u) & ~4095u;
>
> That means that if va%4096u==0 then teh result
> is lim==va .
>
> In turn, that means that:
>
>                 len = MIN(lim - va, sz);
>
> results in len==0.
>
> That in turn means that:
>
>                 sz -= len;
>
> does not change sz.
>
> Overall result: the loop tesing sz>0 does not
> terminate.
>
> I expect that is why the kyua test:
>
> sys/vm/mlock_test:mlock__copy_on_write_vnode :
>
> is failing.
>
>
> The code in question:
>
> static void
> moea_sync_icache(mmu_t mmu, pmap_t pm, vm_offset_t va, vm_size_t sz)
> {
>         struct pvo_entry *pvo;
>         vm_offset_t lim;
>         vm_paddr_t pa;
>         vm_size_t len;
>
>         PMAP_LOCK(pm);
>         while (sz > 0) {
>                 lim = round_page(va);
>                 len = MIN(lim - va, sz);
>                 pvo = moea_pvo_find_va(pm, va & ~ADDR_POFF, NULL);
>                 if (pvo != NULL) {
>                         pa = (pvo->pvo_pte.pte.pte_lo & PTE_RPGN) |
>                             (va & ADDR_POFF);
>                         moea_syncicache(pa, len);
>                 }
>                 va += len;
>                 sz -= len;
>         }
>         PMAP_UNLOCK(pm);
> }
>
>
> ===
> Mark Millard
> marklmi at yahoo.com
> ( dsl-only.net went
> away in early 2018-Mar)
>
> _______________________________________________
> freebsd-ppc@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-ppc
> To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAC7XEcJgXZMBb1q8TrqERWwWHLq9g=NNC0hiG7ZAH7kvASYK1g>