cache policy of arm mmu
Hi Cunsuo,
Thanks for you prompt reply.
But I'm just wondering why the other policies(such as writethrough) are abandoned, does anyone know the architecture difference?
Cheers,
Jacky
Sent from my HTC
----- Reply message -----
From: "Cunsuo Guo" <[email protected]>
To: "Jacky lin" <[email protected]>
Cc: <[email protected]>
Subject: cache policy of arm mmu
Date: Tue, May 29, 2012 09:10
Hi Jacky?
I think the information of printk has already tell us the reason.
2012/5/29 Jacky lin <[email protected]>:
Quoted 20 lines
Hi all,
I found that the cache policy in after ARMv6 is always set as writeback mode in
mmu.c.static int
__initearly_cachepolicy(char *p){ ... if (cpu_architecture() >= CPU_ARCH_ARMv6) { printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n"); cachepolicy = CPOLICY_WRITEBACK; }...
}Does anyone know why and provide some documents or links for that?
Thanks so much!
Quoted 8 lines
Cheers,
Jacky_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120529/b5d2503a/attachment.html
Hello Jacky,
Quoted 5 lines · h.t.jacky at gmail.com
Hi Cunsuo,
Thanks for you prompt reply.
But I'm just wondering why the other policies(such as writethrough) are abandoned, does anyone know the architecture difference?
They are not abandoned from architecture.
If you do a git log -p on arch/arm/mm/mmu.c, this is what we get.
commit 4b46d6416548fb6a0940dfd9911fd895eb6247b3
Author: Russell King <[email protected]> Date: Sun Nov 1 17:44:24 2009 +0000
ARM: ensure initial page tables are setup for SMP systems
Mapping the same memory using two different attributes (memory type, shareability, cacheability) is unpredictable. During boot, we encounter a situation when we're updating the kernel's page tables which can lead to dirty cache lines existing in the cache which are subsequently missed. This causes stack corruption, and therefore a crash.
Therefore, ensure that the shared and cacheability settings matches the configuration that will be used later; this together with the restriction in early_cachepolicy() ensures that we won't create a mismatch during boot.
arch/arm/mm/mmu.c +7 -0
@@ -117,6 +117,13 @@ static void __init early_cachepolicy(char **p) }if (i ==ARRAY_SIZE (cache_policies))printk (KERN_ERR "ERROR: unknown or unsupported cache policy\n" ); +/* +* This restriction is partly to do with the way we boot; it is +* unpredictable to have memory mapped using two different sets of +* memory attributes (shared, type, and cache attribs). We can not +* change these attributes once the initial assembly has setup the +* page tables. +*/ if (cpu_architecture() >= CPU_ARCH_ARMv6) { printk(KERN_WARNING "Only cachepolicy=writeback
supported on ARMv6 and later\n");
cachepolicy = CPOLICY_WRITEBACK;Thanks,
Arun
Quoted 53 lines
Cheers,
Jacky
Sent from my HTC----- Reply message -----
From: "Cunsuo Guo" <[email protected]>
To: "Jacky lin" <[email protected]>
Cc: <[email protected]>
Subject: cache policy of arm mmu
Date: Tue, May 29, 2012 09:10Hi Jacky?
I think the information of printk has already tell us the reason.2012/5/29 Jacky lin <[email protected]>:
Quoted 21 lines
Hi all,
I found that the cache policy in after ARMv6 is always set as writeback mode
inmmu.c.static int
__initearly_cachepolicy(char *p)
{
? ?...
? ? if (cpu_architecture()>=CPU_ARCH_ARMv6) {
? ? ? ?printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n");
? ? ? ? cachepolicy =CPOLICY_WRITEBACK;
? ? }
? ?...
}Does anyone know why and provide some documents or links for that?
Thanks so much!
Quoted 8 lines
Cheers,
Jacky_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Dear Arus,
Thanks for your reply, well I checked this commit you mentioned as following:
But I still could not get a clue about where the cache policy is set outside mmu.c.
So do you know if I put the "cachepolicy=writethrough" in cmd line, where will that be parsed?
Thanks a lot!
arch/arm/mm/mmu.c +0 -0
Author: Russell King <[email protected]> Date: Sun Nov 1 17:44:24 2009 +0000
ARM: ensure initial page tables are setup for SMP systems
Mapping the same memory using two different attributes (memory type, shareability, cacheability) is unpredictable. During boot, we encounter a situation when we're updating the kernel's page tables which can lead to dirty cache lines existing in the cache which are subsequently missed. This causes stack corruption, and therefore a crash.
Therefore, ensure that the shared and cacheability settings matches the configuration that will be used later; this together with the restriction in early_cachepolicy() ensures that we won't create a mismatch during boot.
arch/arm/mm/mmu.c +0 -0
@@ -117,6 +117,13 @@ static void __init early_cachepolicy(char **p) }if (i ==ARRAY_SIZE (cache_policies)) printk(KERN_ERR "ERROR: unknown or unsupported cache
policy\n");
+ /*
+ * This restriction is partly to do with the way we boot; it is
+ * unpredictable to have memory mapped using two different sets of
+ * memory attributes (shared, type, and cache attribs). We can not
+ * change these attributes once the initial assembly has setup the
+ * page tables.
+ */
if (cpu_architecture() >= CPU_ARCH_ARMv6) {
printk(KERN_WARNING "Only cachepolicy=writeback supported
on ARMv6 and later\n");
cachepolicy = CPOLICY_WRITEBACK;arch/arm/mm/proc-v6.S +7 -4
@@ -32,8 +32,10 @@ #ifndef CONFIG_SMP #define TTB_FLAGS TTB_RGN_WBWA +#define PMD_FLAGS PMD_SECT_WB #else #define TTB_FLAGS TTB_RGN_WBWA|TTB_S +#define PMD_FLAGS PMD_SECT_WBWA|PMD_SECT_S #endif ENTRY(cpu_v6_proc_init)
@@ -222,10 +224,9 @@ __v6_proc_info: --- a/arch/arm/mm/proc-v6.S +++ b/arch/arm/mm/proc-v6.S
@@ -32,8 +32,10 @@ #ifndef CONFIG_SMP #define TTB_FLAGS TTB_RGN_WBWA
@@ -32,8 +32,10 @@ #ifndef CONFIG_SMP #define TTB_FLAGS TTB_RGN_WBWA +#define PMD_FLAGS PMD_SECT_WB #else #define TTB_FLAGS TTB_RGN_WBWA|TTB_S +#define PMD_FLAGS PMD_SECT_WBWA|PMD_SECT_S #endif ENTRY(cpu_v6_proc_init)
@@ -222,10 +224,9 @@ __v6_proc_info: .long 0x0007b000 .long 0x0007f000 .long PMD_TYPE_SECT | \ - PMD_SECT_BUFFERABLE | \ - PMD_SECT_CACHEABLE | \ PMD_SECT_AP_WRITE | \ - PMD_SECT_AP_READ + PMD_SECT_AP_READ | \ + PMD_FLAGS .long PMD_TYPE_SECT | \ PMD_SECT_XN | \ PMD_SECT_AP_WRITE | \
arch/arm/mm/proc-v7.S +4 -3
@@ -33,9 +33,11 @@ #ifndef CONFIG_SMP /* PTWs cacheable, inner WB not shareable, outer WB not shareable */ #define TTB_FLAGS TTB_IRGN_WB|TTB_RGN_OC_WB +#define PMD_FLAGS PMD_SECT_WB #else /* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */ #define TTB_FLAGS TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA +#define PMD_FLAGS PMD_SECT_WBWA|PMD_SECT_S #endif ENTRY(cpu_v7_proc_init)
@@ -326,10 +328,9 @@ __v7_proc_info: .long 0x000f0000 @ Required ID value .long 0x000f0000 @ Mask for ID .long PMD_TYPE_SECT | \ - PMD_SECT_BUFFERABLE | \ - PMD_SECT_CACHEABLE | \ PMD_SECT_AP_WRITE | \ - PMD_SECT_AP_READ + PMD_SECT_AP_READ | \ + PMD_FLAGS .long PMD_TYPE_SECT | \ PMD_SECT_XN | \ PMD_SECT_AP_WRITE | \
Cheers,
Jacky
Quoted 82 lines · Arun KS
Hello Jacky,
Quoted 5 lines · h.t.jacky at gmail.com
Hi Cunsuo,
Thanks for you prompt reply.
But I'm just wondering why the other policies(such as writethrough) are abandoned, does anyone know the architecture difference?They are not abandoned from architecture.
If you do a git log -p on
arch/arm/mm/mmu.c, this is what we get.commit
4b46d6416548fb6a0940dfd9911fd895eb6247b3Author: Russell King <[email protected]> Date: Sun Nov 1 17:44:24 2009 +0000ARM: ensure initial page tables are setup for SMP systems
Mapping the same memory using two different attributes (memory type, shareability, cacheability) is unpredictable. During boot, we encounter a situation when we're updating the kernel's page tables which can lead to dirty cache lines existing in the cache which are subsequently missed. This causes stack corruption, and therefore a crash.
Therefore, ensure that the shared and cacheability settings matches the configuration that will be used later; this together with the restriction in
early_cachepolicy()ensures that we won't create a mismatch during boot.Acked-by Catalin Marinas <[email protected]>Signed-off-by Russell King <[email protected]>arch/arm/mm/mmu.c +7
-0@@ -117,6 +117,13 @@ static void __init early_cachepolicy(char **p) }if (i ==ARRAY_SIZE (cache_policies))printk (KERN_ERR "ERROR: unknown or unsupported cache policy\n"); +/* +* This restriction is partly to do with the way we boot; it is +* unpredictable to have memory mapped using two different sets of +* memory attributes (shared, type, and cache attribs). We can not +* change these attributes once the initial assembly has setup the +* page tables. +*/ if (cpu_architecture() >= CPU_ARCH_ARMv6) { printk(KERN_WARNING "Only cachepolicy=writebacksupported on ARMv6 and later\n"); cachepolicy = CPOLICY_WRITEBACK;Thanks,
ArunQuoted 24 lines
Cheers,
Jacky
Sent from my HTC----- Reply message -----
From: "Cunsuo Guo" <[email protected]>
To: "Jacky lin" <[email protected]>
Cc: <[email protected]>
Subject: cache policy of arm mmu
Date: Tue, May 29, 2012 09:10Hi Jacky?
I think the information of printk has already tell us the reason.2012/5/29 Jacky lin <[email protected]>:
Quoted 6 lines
Hi all,
I found that the cache policy in after ARMv6 is always set as writeback mode
inmmu.c.
Quoted 31 lines
Quoted 5 lines
Quoted 5 lines
static int
__initearly_cachepolicy(char *p){ ... if (cpu_architecture() >= CPU_ARCH_ARMv6) { printk(KERN_WARNING "Only cachepolicy=writeback supported onARMv6
Quoted 24 lines
Quoted 10 lines
and later\n"); cachepolicy = CPOLICY_WRITEBACK; }...
}Does anyone know why and provide some documents or links for that?
Thanks so much!
Quoted 8 lines
Cheers,
Jacky_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120601/1b63fb86/attachment-0001.html