Bug 199739 - with ARM_NEW_PMAP ptrace syscalls do not achieve icache consistency
Summary: with ARM_NEW_PMAP ptrace syscalls do not achieve icache consistency
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-27 19:33 UTC by weiss
Modified: 2015-04-28 16:54 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description weiss 2015-04-27 19:33:02 UTC
offset in page is ignored

diff --git a/sys/arm/arm/pmap-v6-new.c b/sys/arm/arm/pmap-v6-new.c
index 53896d4..ff3fe68 100644
--- a/sys/arm/arm/pmap-v6-new.c
+++ b/sys/arm/arm/pmap-v6-new.c
@@ -6111,7 +6111,7 @@ pmap_dcache_wb_pou(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma)
        if (*sysmaps->CMAP3)
                panic("%s: CMAP3 busy", __func__);
        pte2_store(sysmaps->CMAP3, PTE2_KERN_NG(pa, PTE2_AP_KRW, ma));
-       va = (vm_offset_t)sysmaps->CADDR3;
+       va = (vm_offset_t)sysmaps->CADDR3 + (pa & PAGE_MASK);
        tlb_flush_local(va);
        dcache_wb_pou(va, size);
        pte2_clear(sysmaps->CMAP3);
Comment 1 onwahe 2015-04-28 09:32:14 UTC
Thank you for your patch. While fixing it, I'm adding some tweaks. Someone with commit bit, commit it please.

Index: sys/arm/arm/pmap-v6-new.c
===================================================================
--- sys/arm/arm/pmap-v6-new.c	(revision 282129)
+++ sys/arm/arm/pmap-v6-new.c	(working copy)
@@ -6094,13 +6094,13 @@
 
 
 /*
- *  Clean L1 data cache range on a single page, which is not mapped yet.
+ *  Clean L1 data cache range by physical address.
+ *  The range must be within a single page.
  */
 static void
 pmap_dcache_wb_pou(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma)
 {
 	struct sysmaps *sysmaps;
-	vm_offset_t va;
 
 	KASSERT(((pa & PAGE_MASK) + size) <= PAGE_SIZE,
 	    ("%s: not on single page", __func__));
@@ -6111,9 +6111,8 @@
 	if (*sysmaps->CMAP3)
 		panic("%s: CMAP3 busy", __func__);
 	pte2_store(sysmaps->CMAP3, PTE2_KERN_NG(pa, PTE2_AP_KRW, ma));
-	va = (vm_offset_t)sysmaps->CADDR3;
-	tlb_flush_local(va);
-	dcache_wb_pou(va, size);
+	tlb_flush_local((vm_offset_t)sysmaps->CADDR3);
+	dcache_wb_pou((vm_offset_t)sysmaps->CADDR3 + (pa & PAGE_MASK), size);
 	pte2_clear(sysmaps->CMAP3);
 	sched_unpin();
 	mtx_unlock(&sysmaps->lock);
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-04-28 16:47:38 UTC
A commit references this bug:

Author: andrew
Date: Tue Apr 28 16:47:35 UTC 2015
New revision: 282151
URL: https://svnweb.freebsd.org/changeset/base/282151

Log:
  Fix pmap_dcache_wb_pou in the new armv6 pmap to correctly achieve icache
  consistency from ptrace.

  PR:		199739
  Submitted by:	Jurgen Weiss <weiss at uni-mainz.de> (original version)
  Submitted by:	Svatopluk Kraus <onwahe at gmail.com>

Changes:
  head/sys/arm/arm/pmap-v6-new.c
Comment 3 Andrew Turner freebsd_committer freebsd_triage 2015-04-28 16:50:31 UTC
Thanks, committed.