Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jul 2009 09:02:32 -0500 (CDT)
From:      Mark Tinguely <tinguely@casselton.net>
To:        mih@semihalf.com, stas@FreeBSD.org, tinguely@casselton.net
Cc:        freebsd-arm@FreeBSD.org
Subject:   Re: pmap problem in FreeBSD current
Message-ID:  <200907071402.n67E2WgH010354@casselton.net>
In-Reply-To: <200907061714.n66HEqsV063372@casselton.net>

next in thread | previous in thread | raw e-mail | index | archive | help

In arm_remap_nocache()/arm_unmap_nocache() a kernel shadow mapping is
made for BUS_DMA_COHERENT pages but is not removed. It is probably one
place that causes undeleted mappings required us to add the tail "if"
statement in pmap_nuke_pv() that I mentioned yesterday.

FYI future ideas: we can get rid of the shadow KVA for the BUS_DMA_COHERENT
by setting a bit in the page flags to denote a no_cache situation. The pmap
code can see that bit and refraim from turning caching on in pmap_fix_cache().

Speaking of pmap_nuke_pv() and in regards to my yesterday email, the more I
think of it, the more I believe the line "pg->md.pvh_attrs &= ~PVF_MOD;"
should remain in the code. The line, "vm_page_flag_clear(pg, PG_WRITEABLE);"
should be remove to avoid corruption.

It would be nice to remove all these unremoved mappings so that "if"
statement in pmap_nuke_pv() is unecessary. If we can't find all of
these unremoved mappings, we may need to clean out md.pv_kva when a
page is freed (or allocated) because we may be tricked into thinking the
page is shared when it really is not. This would not cause corruption,
but the cache will be turned off unnecessarily on a really unshared page.

vm_machdep.c:
void
arm_unmap_nocache(void *addr, vm_size_t size)
{
	vm_offset_t raddr = (vm_offset_t)addr;
	int i;

	size = round_page(size);
	i = (raddr - arm_nocache_startaddr) / (PAGE_SIZE);
-	for (; size > 0; size -= PAGE_SIZE, i++)
+	for (; size > 0; size -= PAGE_SIZE, i++) {
		arm_nocache_allocated[i / BITS_PER_INT] &= ~(1 << (i %
		    BITS_PER_INT));
+		pmap_kremove(raddr); 
+		raddr += PAGE_SIZE;
}

--Mark Tinguely



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