Dear Arus,<br><br>Thanks for your reply, well I checked this commit you mentioned as following:<br>But I still could not get a clue about where the cache policy is set outside mmu.c.<br>So do you know if I put the &quot;cachepolicy=writethrough&quot; in cmd line, where will that be parsed?<br>
Thanks a lot! <br><br>diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c<br>index 02243ee..ea67be0 100644<br>Author: Russell King &lt;<a href="mailto:rmk%2Bkernel@arm.linux.org.uk">rmk+kernel@arm.linux.org.uk</a>&gt;<br>Date:   Sun Nov 1 17:44:24 2009 +0000<br>
<br>    ARM: ensure initial page tables are setup for SMP systems<br>    <br>    Mapping the same memory using two different attributes (memory<br>    type, shareability, cacheability) is unpredictable.  During boot,<br>    we encounter a situation when we&#39;re updating the kernel&#39;s page<br>
    tables which can lead to dirty cache lines existing in the cache<br>    which are subsequently missed.  This causes stack corruption,<br>    and therefore a crash.<br>    <br>    Therefore, ensure that the shared and cacheability settings<br>
    matches the configuration that will be used later; this together<br>    with the restriction in early_cachepolicy() ensures that we won&#39;t<br>    create a mismatch during boot.<br>    <br>    Acked-by: Catalin Marinas &lt;<a href="mailto:catalin.marinas@arm.com">catalin.marinas@arm.com</a>&gt;<br>
    Signed-off-by: Russell King &lt;<a href="mailto:rmk%2Bkernel@arm.linux.org.uk">rmk+kernel@arm.linux.org.uk</a>&gt;<br><br>diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c<br>index 02243ee..ea67be0 100644<br>--- a/arch/arm/mm/mmu.c<br>
+++ b/arch/arm/mm/mmu.c<br>@@ -117,6 +117,13 @@ static void __init early_cachepolicy(char **p)<br>        }<br>        if (i == ARRAY_SIZE(cache_policies))<br>                printk(KERN_ERR &quot;ERROR: unknown or unsupported cache policy\n&quot;);<br>
+       /*<br>+        * This restriction is partly to do with the way we boot; it is<br>+        * unpredictable to have memory mapped using two different sets of<br>+        * memory attributes (shared, type, and cache attribs).  We can not<br>
+        * change these attributes once the initial assembly has setup the<br>+        * page tables.<br>+        */<br>        if (cpu_architecture() &gt;= CPU_ARCH_ARMv6) {<br>                printk(KERN_WARNING &quot;Only cachepolicy=writeback supported on ARMv6 and later\n&quot;);<br>
                cachepolicy = CPOLICY_WRITEBACK;<br>diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S<br>index 194737d..70f75d2 100644<br>--- a/arch/arm/mm/proc-v6.S<br>+++ b/arch/arm/mm/proc-v6.S<br>@@ -32,8 +32,10 @@<br>
 <br> #ifndef CONFIG_SMP<br> #define TTB_FLAGS      TTB_RGN_WBWA<br>+#define PMD_FLAGS      PMD_SECT_WB<br> #else<br> #define TTB_FLAGS      TTB_RGN_WBWA|TTB_S<br>+#define PMD_FLAGS      PMD_SECT_WBWA|PMD_SECT_S<br> #endif<br>
 <br> ENTRY(cpu_v6_proc_init)<br>@@ -222,10 +224,9 @@ __v6_proc_info:<br>--- a/arch/arm/mm/proc-v6.S<br>+++ b/arch/arm/mm/proc-v6.S<br>@@ -32,8 +32,10 @@<br> <br> #ifndef CONFIG_SMP<br> #define TTB_FLAGS      TTB_RGN_WBWA<br>
@@ -32,8 +32,10 @@<br> <br> #ifndef CONFIG_SMP<br> #define TTB_FLAGS      TTB_RGN_WBWA<br>+#define PMD_FLAGS      PMD_SECT_WB<br> #else<br> #define TTB_FLAGS      TTB_RGN_WBWA|TTB_S<br>+#define PMD_FLAGS      PMD_SECT_WBWA|PMD_SECT_S<br>
 #endif<br> <br> ENTRY(cpu_v6_proc_init)<br>@@ -222,10 +224,9 @@ __v6_proc_info:<br>        .long   0x0007b000<br>        .long   0x0007f000<br>        .long   PMD_TYPE_SECT | \<br>-               PMD_SECT_BUFFERABLE | \<br>
-               PMD_SECT_CACHEABLE | \<br>                PMD_SECT_AP_WRITE | \<br>-               PMD_SECT_AP_READ<br>+               PMD_SECT_AP_READ | \<br>+               PMD_FLAGS<br>        .long   PMD_TYPE_SECT | \<br>
                PMD_SECT_XN | \<br>                PMD_SECT_AP_WRITE | \<br>diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S<br>index 23ebcf6..eeeed01 100644<br>--- a/arch/arm/mm/proc-v7.S<br>+++ b/arch/arm/mm/proc-v7.S<br>
@@ -33,9 +33,11 @@<br> #ifndef CONFIG_SMP<br> /* PTWs cacheable, inner WB not shareable, outer WB not shareable */<br> #define TTB_FLAGS      TTB_IRGN_WB|TTB_RGN_OC_WB<br>+#define PMD_FLAGS      PMD_SECT_WB<br> #else<br> /* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */<br>
 #define TTB_FLAGS      TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA<br>+#define PMD_FLAGS      PMD_SECT_WBWA|PMD_SECT_S<br> #endif<br> <br> ENTRY(cpu_v7_proc_init)<br>@@ -326,10 +328,9 @@ __v7_proc_info:<br>        .long   0x000f0000              @ Required ID value<br>
        .long   0x000f0000              @ Mask for ID<br>        .long   PMD_TYPE_SECT | \<br>-               PMD_SECT_BUFFERABLE | \<br>-               PMD_SECT_CACHEABLE | \<br>                PMD_SECT_AP_WRITE | \<br>-               PMD_SECT_AP_READ<br>
+               PMD_SECT_AP_READ | \<br>+               PMD_FLAGS<br>        .long   PMD_TYPE_SECT | \<br>                PMD_SECT_XN | \<br>                PMD_SECT_AP_WRITE | \<br><br>Cheers,<br>Jacky<br><div class="gmail_quote">
On Tue, May 29, 2012 at 6:07 PM, Arun KS <span dir="ltr">&lt;<a href="mailto:getarunks@gmail.com" target="_blank">getarunks@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hello Jacky,<br>
<div class="im"><br>
On Tue, May 29, 2012 at 10:09 AM, <a href="mailto:h.t.jacky@gmail.com">h.t.jacky@gmail.com</a><br>
&lt;<a href="mailto:h.t.jacky@gmail.com">h.t.jacky@gmail.com</a>&gt; wrote:<br>
&gt; Hi Cunsuo,<br>
&gt;<br>
&gt; Thanks for you prompt reply.<br>
&gt; But I&#39;m just wondering why the other policies(such as writethrough) are<br>
&gt; abandoned, does anyone know the architecture difference?<br>
<br>
</div>They are not abandoned from architecture.<br>
<br>
If you do a git log -p on arch/arm/mm/mmu.c, this is what we get.<br>
<br>
commit 4b46d6416548fb6a0940dfd9911fd895eb6247b3<br>
Author: Russell King &lt;<a href="mailto:rmk%2Bkernel@arm.linux.org.uk">rmk+kernel@arm.linux.org.uk</a>&gt;<br>
Date:   Sun Nov 1 17:44:24 2009 +0000<br>
<br>
    ARM: ensure initial page tables are setup for SMP systems<br>
<br>
    Mapping the same memory using two different attributes (memory<br>
    type, shareability, cacheability) is unpredictable.  During boot,<br>
    we encounter a situation when we&#39;re updating the kernel&#39;s page<br>
    tables which can lead to dirty cache lines existing in the cache<br>
    which are subsequently missed.  This causes stack corruption,<br>
    and therefore a crash.<br>
<br>
    Therefore, ensure that the shared and cacheability settings<br>
    matches the configuration that will be used later; this together<br>
    with the restriction in early_cachepolicy() ensures that we won&#39;t<br>
    create a mismatch during boot.<br>
<br>
    Acked-by: Catalin Marinas &lt;<a href="mailto:catalin.marinas@arm.com">catalin.marinas@arm.com</a>&gt;<br>
    Signed-off-by: Russell King &lt;<a href="mailto:rmk%2Bkernel@arm.linux.org.uk">rmk+kernel@arm.linux.org.uk</a>&gt;<br>
<br>
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c<br>
index 02243ee..ea67be0 100644<br>
--- a/arch/arm/mm/mmu.c<br>
+++ b/arch/arm/mm/mmu.c<br>
@@ -117,6 +117,13 @@ static void __init early_cachepolicy(char **p)<br>
        }<br>
        if (i == ARRAY_SIZE(cache_policies))<br>
                printk(KERN_ERR &quot;ERROR: unknown or unsupported cache policy\n&quot;);<br>
+       /*<br>
+        * This restriction is partly to do with the way we boot; it is<br>
+        * unpredictable to have memory mapped using two different sets of<br>
+        * memory attributes (shared, type, and cache attribs).  We can not<br>
+        * change these attributes once the initial assembly has setup the<br>
+        * page tables.<br>
+        */<br>
<div class="im">        if (cpu_architecture() &gt;= CPU_ARCH_ARMv6) {<br>
                printk(KERN_WARNING &quot;Only cachepolicy=writeback<br>
supported on ARMv6 and later\n&quot;);<br>
                cachepolicy = CPOLICY_WRITEBACK;<br>
<br>
</div>Thanks,<br>
Arun<br>
<div class="HOEnZb"><div class="h5">&gt;<br>
&gt; Cheers,<br>
&gt; Jacky<br>
&gt; Sent from my HTC<br>
&gt;<br>
&gt;<br>
&gt; ----- Reply message -----<br>
&gt; From: &quot;Cunsuo Guo&quot; &lt;<a href="mailto:cunsuo.guo@gmail.com">cunsuo.guo@gmail.com</a>&gt;<br>
&gt; To: &quot;Jacky lin&quot; &lt;<a href="mailto:h.t.jacky@gmail.com">h.t.jacky@gmail.com</a>&gt;<br>
&gt; Cc: &lt;<a href="mailto:kernelnewbies@kernelnewbies.org">kernelnewbies@kernelnewbies.org</a>&gt;<br>
&gt; Subject: cache policy of arm mmu<br>
&gt; Date: Tue, May 29, 2012 09:10<br>
&gt;<br>
&gt;<br>
&gt; Hi Jacky,<br>
&gt; I think the information of printk has already tell us the reason.<br>
&gt;<br>
&gt; 2012/5/29 Jacky lin &lt;<a href="mailto:h.t.jacky@gmail.com">h.t.jacky@gmail.com</a>&gt;:<br>
&gt;&gt; Hi all,<br>
&gt;&gt;<br>
&gt;&gt; I found that the cache policy in after ARMv6 is always set as writeback<br>
&gt;&gt; mode<br>
&gt;&gt; in mmu.c.<br>
&gt;&gt;<br>
&gt;&gt; static int __init early_cachepolicy(char *p)<br>
&gt;&gt; {<br>
&gt;&gt;    ...<br>
&gt;&gt;     if (cpu_architecture() &gt;= CPU_ARCH_ARMv6) {<br>
&gt;&gt;         printk(KERN_WARNING &quot;Only cachepolicy=writeback supported on ARMv6<br>
&gt;&gt; and later\n&quot;);<br>
&gt;&gt;         cachepolicy = CPOLICY_WRITEBACK;<br>
&gt;&gt;     }<br>
&gt;&gt;    ...<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; Does anyone know why and provide some documents or links for that?<br>
&gt;&gt;<br>
&gt;&gt; Thanks so much!<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Jacky<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Kernelnewbies mailing list<br>
&gt;&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt;&gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt;&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Kernelnewbies mailing list<br>
&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt;<br>
</div></div></blockquote></div><br>