arm and patch phys offset
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Michael Walle
[i don't know it this belongs to the arm kernel mailinglist]
It probably does, added. When in doubt, it never hurt to CC the list.
Quoted 8 lines
Hi Nico,
i'm facing some weird problem with the
PATCH_PHYS_OFFSETconfig option enabled.I have a marvell kirkwood based LS-CHLv2 board and running the latest HEAD of linus tree (with my dts patched for the kirkwood port, but hopefully this should be unrelated to this problem).
Did you try without those patches to be sure?
Quoted 6 lines
There seems to be p2v and v2p calls which aren't patched. Unfortunately i don't have jtag access to the board. So, I use the following function to dump non-patched entries of the pvtable (called from
setup_arch()):extern unsigned long
__pv_table_begin,__pv_table_end; static void__initdump_pvtable(void)
Quoted 7 lines
{
unsigned char *b;
unsigned long *cur = &__pv_table_begin;
int i = 0;
early_print("__pvtable %08lx..%08lx\n",
&__pv_table_begin, &__pv_table_end);
while (*cur) {This is wrong. You should have this instead:
while (cur < &__pv_table_end) {Quoted 5 lines
b = (unsigned char *)(*cur);
if (*b == 0x81) {
early_print(" %d %08lx\n", i, *cur);
/* uncommenting the following make the kernel work */
/* *b = 0x40; */Conceptually, this would be lacking a data vs insn cache resynchronization.
Quoted 25 lines
//early_print(" %08lx\n", *((unsigned long*)*cur)); } cur++; i++; } early_print("total of %d entries\n", i); }Now i get the following output:
Uncompressing Linux... done, booting the kernel.
__pvtablec03f3e6c..c03f43c8
7c03d8508
27c03d9208
29c03d9360
42c03d9bfc
59c03dd174
73c03df094
77c03df1b8
83c03dfc54
85c03dfe6c
127c03e07d8
129c03e11ac
total of 343 entries
Quoted 2 lines
The weird thing is that this output changes if i insert or move some debug prints. I even accomplished to make the board boot completely sometimes.
You must have some memory corrupting bug somewhere. Please try calling this code first thing in start_kernel() for comparison.
Nicolas
Am Montag 12 Dezember 2011, 01:53:42 schrieb Nicolas Pitre:
Quoted 6 lines · Michael Walle
Quoted 3 lines
I have a marvell kirkwood based LS-CHLv2 board and running the latest HEAD of linus tree (with my dts patched for the kirkwood port, but hopefully this should be unrelated to this problem).
Did you try without those patches to be sure?
clean linux tree with old fashioned setup code now (the one i sent long time ago to this mailinglist ;).
Quoted 6 lines
Quoted 3 lines
The weird thing is that this output changes if i insert or move some debug prints. I even accomplished to make the board boot completely sometimes.
You must have some memory corrupting bug somewhere. Please try calling this code first thing in
start_kernel()for comparison.
calling the dump function right at the beginning of start_kernel() won't change anything, expect the addresses.
If it would be some memory corruption, shouldn't the table or the p2v/v2p stubs be corrupt? But the non-patched entries always points to correct v2p/p2v calls and in every case there is the unpatched add/sub instruction.
Signature · 1 line
Michael
Quoted 14 lines · Michael Walle
Am Montag 12 Dezember 2011, 01:53:42 schrieb Nicolas Pitre:
Quoted 6 lines · Michael Walle
Quoted 3 lines
I have a marvell kirkwood based LS-CHLv2 board and running the latest HEAD of linus tree (with my dts patched for the kirkwood port, but hopefully this should be unrelated to this problem).
Did you try without those patches to be sure?
clean linux tree with old fashioned setup code now (the one i sent long time ago to this mailinglist ;).
Quoted 4 lines
Quoted 3 lines
The weird thing is that this output changes if i insert or move some debug prints. I even accomplished to make the board boot completely sometimes.
Quoted 5 lines
Quoted 2 lines
You must have some memory corrupting bug somewhere. Please try calling this code first thing in
start_kernel()for comparison.calling the dump function right at the beginning of
start_kernel()won't change anything, expect the addresses.
Why do you say that, and what you do mean by "expect the addresses" ? Presumably you're saying the addresses will be different. Why do you think that?
Are you saying that you find that the address of these 'unconverted' instructions change each time you run your debug function?
Quoted 3 lines
If it would be some memory corruption, shouldn't the table or the p2v/v2p stubs be corrupt? But the non-patched entries always points to correct v2p/p2v calls and in every case there is the unpatched add/sub instruction.
Have you tried dumping out the entire instruction as well as the address of the unconverted instruction?
Are you running a Thumb-2 kernel? Which kernel are you running?
Am Montag 12 Dezember 2011, 22:34:50 schrieb Russell King - ARM Linux:
Quoted 5 lines
Why do you say that, and what you do mean by "expect the addresses" ? Presumably you're saying the addresses will be different. Why do you think that?
Are you saying that you find that the address of these 'unconverted' instructions change each time you run your debug function?
i see different output from the debug function everytime i change the source code and recompile the kernel. restarting the same binary results in the same unconverted instructions.
Quoted 7 lines
Quoted 4 lines
If it would be some memory corruption, shouldn't the table or the p2v/v2p stubs be corrupt? But the non-patched entries always points to correct v2p/p2v calls and in every case there is the unpatched add/sub instruction.
Have you tried dumping out the entire instruction as well as the address of the unconverted instruction?
yes, the addresses make sense as i can see the unpatched instruction at that address in the disassembly and the instruction at these addresses are always:
add/sub rX, rY, #81000000
Quoted 1 line
Are you running a Thumb-2 kernel? Which kernel are you running?
what do you mean by which kernel?
linus' master from yesterday, ARCH_KIRKWOOD=yCONFIG_THUMB2_KERNEL is not set
Signature · 1 line
Michael
Quoted 20 lines · Michael Walle
Am Montag 12 Dezember 2011, 22:34:50 schrieb Russell King - ARM Linux:
Quoted 5 lines
Why do you say that, and what you do mean by "expect the addresses" ? Presumably you're saying the addresses will be different. Why do you think that?
Are you saying that you find that the address of these 'unconverted' instructions change each time you run your debug function?i see different output from the debug function everytime i change the source code and recompile the kernel. restarting the same binary results in the same unconverted instructions.
Quoted 7 lines
Quoted 4 lines
If it would be some memory corruption, shouldn't the table or the p2v/v2p stubs be corrupt? But the non-patched entries always points to correct v2p/p2v calls and in every case there is the unpatched add/sub instruction.
Have you tried dumping out the entire instruction as well as the address of the unconverted instruction?
yes, the addresses make sense as i can see the unpatched instruction at that address in the disassembly and the instruction at these addresses are always:
Quoted 6 lines
add/sub rX, rY, #81000000
Quoted 1 line
Are you running a Thumb-2 kernel? Which kernel are you running?
what do you mean by which kernel?
linus' master from yesterday, ARCH_KIRKWOOD=yCONFIG_THUMB2_KERNELis not set
Yes, that's what I mean.
Right, so the problem you're describing is _impossible_ - there is no way the fixup function can fix only some instructions and skip over others in a properly functioning system.
The only options are that either the CPU is not executing the instructions we're giving it (unlikely as - I assume - your hardware executes older kernels fine), or for some reason your kernel is being called with caches still enabled, violating the long-standing kernel's calling requirements.
So, some more questions to try to narrow this down:
1. What boot loader are you using?
2. What file are you taking from the kernel build in order to boot?
3. How are you transfering the kernel file to your target system?
Am Montag 12 Dezember 2011, 23:02:47 schrieb Russell King - ARM Linux:
Quoted 12 lines
Quoted 5 lines
Quoted 1 line
Are you running a Thumb-2 kernel? Which kernel are you running?
what do you mean by which kernel?
linus' master from yesterday, ARCH_KIRKWOOD=yCONFIG_THUMB2_KERNELis not setYes, that's what I mean.
Right, so the problem you're describing is _impossible_ - there is no way the fixup function can fix only some instructions and skip over others in a properly functioning system.
Quoted 8 lines
The only options are that either the CPU is not executing the instructions we're giving it (unlikely as - I assume - your hardware executes older kernels fine), or for some reason your kernel is being called with caches still enabled, violating the long-standing kernel's calling requirements.
So, some more questions to try to narrow this down:
1. What boot loader are you using?
u-boot 2011.09 with own bsp support.
Quoted 1 line
2. What file are you taking from the kernel build in order to boot?
generated uImage
Quoted 1 line
3. How are you transfering the kernel file to your target system?
tftp
Thanks for helping. I'll now have a look at the bootloader ;)
Signature · 1 line
Michael
Quoted 18 lines · Michael Walle
Am Montag 12 Dezember 2011, 23:02:47 schrieb Russell King - ARM Linux:
Quoted 17 lines
Quoted 5 lines
Quoted 1 line
Are you running a Thumb-2 kernel? Which kernel are you running?
what do you mean by which kernel?
linus' master from yesterday, ARCH_KIRKWOOD=yCONFIG_THUMB2_KERNELis not setYes, that's what I mean.
Right, so the problem you're describing is _impossible_ - there is no way the fixup function can fix only some instructions and skip over others in a properly functioning system.
The only options are that either the CPU is not executing the instructions we're giving it (unlikely as - I assume - your hardware executes older kernels fine), or for some reason your kernel is being called with caches still enabled, violating the long-standing kernel's calling requirements.
Quoted 7 lines
Quoted 3 lines
So, some more questions to try to narrow this down:
1. What boot loader are you using?
u-boot 2011.09 with own bsp support.
Quoted 1 line
2. What file are you taking from the kernel build in order to boot?
generated uImage
Okay, so this should mean that the kernel's own decompressor has run, which should turn on/off the mmu and caches, cleaning and invalidating them, which will take the boot loader completely out of the picture at this stage.
I think I'll leave this in the hands of Nicolas - from what I remember, kirkwood is a feroceon based system, and I have little working knowledge of that ARM derivative.
Quoted 27 lines · Russell King - ARM Linux
Quoted 18 lines · Michael Walle
Am Montag 12 Dezember 2011, 23:02:47 schrieb Russell King - ARM Linux:
Quoted 17 lines
Quoted 5 lines
Quoted 1 line
Are you running a Thumb-2 kernel? Which kernel are you running?
what do you mean by which kernel?
linus' master from yesterday, ARCH_KIRKWOOD=yCONFIG_THUMB2_KERNELis not setYes, that's what I mean.
Right, so the problem you're describing is _impossible_ - there is no way the fixup function can fix only some instructions and skip over others in a properly functioning system.
The only options are that either the CPU is not executing the instructions we're giving it (unlikely as - I assume - your hardware executes older kernels fine), or for some reason your kernel is being called with caches still enabled, violating the long-standing kernel's calling requirements.
Quoted 7 lines
Quoted 3 lines
So, some more questions to try to narrow this down:
1. What boot loader are you using?
u-boot 2011.09 with own bsp support.
Quoted 1 line
2. What file are you taking from the kernel build in order to boot?
generated uImage
Quoted 8 lines
Okay, so this should mean that the kernel's own decompressor has run, which should turn on/off the mmu and caches, cleaning and invalidating them, which will take the boot loader completely out of the picture at this stage.
I think I'll leave this in the hands of Nicolas - from what I remember, kirkwood is a feroceon based system, and I have little working knowledge of that ARM derivative.
I just compiled vanilla v3.2-rc5 using kirkwood_defconfig and successfully booted it on a SheevaPlug and a DB-88F6281-BP development board. And I do have CONFIG_ARM_PATCH_PHYS_VIRT=y. Both platforms are using u-Boot which booted the default uImage produced by the kernel build system.
So at this point I wouldn't think the issue is Kirkwood related as I can't reproduce it on two different Kirkwood targets.
Nicolas
Am Montag 12 Dezember 2011, 23:56:38 schrieb Nicolas Pitre:
Quoted 8 lines
I just compiled vanilla v3.2-rc5 using
kirkwood_defconfigand successfully booted it on a SheevaPlug and a DB-88F6281-BP development board. And I do haveCONFIG_ARM_PATCH_PHYS_VIRT=y. Both platforms are using u-Boot which booted the default uImage produced by the kernel build system.So at this point I wouldn't think the issue is Kirkwood related as I can't reproduce it on two different Kirkwood targets.
Seems like the l2 cache is enabled after uboot starts the linux kernel. I'll dig deeper into that tomorrow.
For now, i appended
l2_cache_disable();
to uboots cleanup_before_linux() and all stubs seems to be patched correctly.
void l2_cache_disable(void)
{
struct kwcpu_registers *cpureg =
(struct kwcpu_registers *)KW_CPU_REG_BASE;
writel(readl(&cpureg->l2_cfg) & ~0x18, &cpureg->l2_cfg);
}l2_cfg is 0xf1020128.
But i don't know if that is correct way of disabling the cache.
Nico, what uboot are you using for your SheeavaPlug? Vanilla uboot?
Signature · 1 line
michael
Quoted 10 lines · Michael Walle
Am Montag 12 Dezember 2011, 23:56:38 schrieb Nicolas Pitre:
Quoted 8 lines
I just compiled vanilla v3.2-rc5 using
kirkwood_defconfigand successfully booted it on a SheevaPlug and a DB-88F6281-BP development board. And I do haveCONFIG_ARM_PATCH_PHYS_VIRT=y. Both platforms are using u-Boot which booted the default uImage produced by the kernel build system.So at this point I wouldn't think the issue is Kirkwood related as I can't reproduce it on two different Kirkwood targets.
Quoted 6 lines
Seems like the l2 cache is enabled after uboot starts the linux kernel. I'll dig deeper into that tomorrow.
For now, i appended
l2_cache_disable();
to ubootscleanup_before_linux()and all stubs seems to be patched correctly.
Strange. Having l2 enabled shouldn't cause such trouble.
Quoted 10 lines
void
l2_cache_disable(void){ struct kwcpu_registers *cpureg = (struct kwcpu_registers *)KW_CPU_REG_BASE; writel(readl(&cpureg->l2_cfg) & ~0x18, &cpureg->l2_cfg); }
l2_cfgis0xf1020128.But i don't know if that is correct way of disabling the cache.
I don't remember the details, but I wouldn't think it is that simple. The Kirkwood manual would tell you. It is publicly available.
Quoted 1 line
Nico, what uboot are you using for your SheeavaPlug? Vanilla uboot?
No, it's whatever u-Boot that shipped with it. It says:
U-Boot 1.1.4 (Jan 20 2009 - 12:05:46) Marvell version: 3.4.11
Nicolas
Am Dienstag 13 Dezember 2011, 05:01:30 schrieb Nicolas Pitre:
Quoted 11 lines
Quoted 9 lines
Seems like the l2 cache is enabled after uboot starts the linux kernel. I'll dig deeper into that tomorrow.
For now, i appended
l2_cache_disable();to uboots
cleanup_before_linux()and all stubs seems to be patched correctly.Strange. Having l2 enabled shouldn't cause such trouble.
There is a similar commit in uboots git tree:
http://git.denx.de/?p=u-
boot.git;a=commit;h=dc7100f4080952798413fb63bb4134b22c57623a
I don't know if this is somehow connected to my problem ;)
Quoted 4 lines
Quoted 1 line
But i don't know if that is correct way of disabling the cache.
I don't remember the details, but I wouldn't think it is that simple. The Kirkwood manual would tell you. It is publicly available.
Unfortunately the Functional Specification doesn't mention anything about l2 caches. It references 'Unified Layer 2 (L2) Cache for Sheeva? CPU Cores Addendum, Doc No. MV-S104858-U0', though, which isn't publicly availble i guess.
Just for completeness, i'm now using the following to disable the l2 cache.
l2_cache_disable:
mrc p15, 1, r0, c15, c1, 0 @ marvell extra features register bic r0, r0, #0x00400000 @ disable L2 cache mcr p15, 1, r0, c15, c1, 0 mov pc, lr
Google finds some sourcecode for "marvell extra features register". And there is of course arch/arm/mm/cache-feroceon-l2.c.
Signature · 1 line
Michael
Quoted 11 lines · Michael Walle
Am Dienstag 13 Dezember 2011, 05:01:30 schrieb Nicolas Pitre:
Quoted 10 lines
Quoted 9 lines
Seems like the l2 cache is enabled after uboot starts the linux kernel. I'll dig deeper into that tomorrow.
For now, i appended
l2_cache_disable();to uboots
cleanup_before_linux()and all stubs seems to be patched correctly.
Quoted 6 lines
Quoted 1 line
Strange. Having l2 enabled shouldn't cause such trouble.
There is a similar commit in uboots git tree:
http://git.denx.de/?p=u-
boot.git;a=commit;h=dc7100f4080952798413fb63bb4134b22c57623aI don't know if this is somehow connected to my problem ;)
Michael, did you discover anything else about the problem?
I just tried 3.2-rc6 on my eSata SheevaPlug and I don't get anything after "Uncompressing Linux... done, booting the kernel". If I hack CONFIG_ARM_PATCH_PHYS_VIRT to be disabled, the it boots OK. My U-Boot reports "U-Boot 2011.03 (Apr 26 2011 - 21:50:07)"
I haven't got time to dig deeper at the moment, but thought I'd report 'me too'.
Signature · 1 line
Tixy
Quoted 2 lines · Michael Walle
Seems like the l2 cache is enabled after uboot starts the linux kernel. I'll dig deeper into that tomorrow.
Try to disable both L2 and L1 cach in U-Boot. That has solved similar issues for me.
In include/configs/my_board.h
#define CONFIG_SYS_DCACHE_OFF
Yours,
Linus Walleij
Hi Linus,
Quoted 6 lines · Linus Walleij
Quoted 3 lines · Michael Walle
Seems like the l2 cache is enabled after uboot starts the linux kernel. I'll
dig deeper into that tomorrow.
Quoted 6 lines
Try to disable both L2 and L1 cach in U-Boot. That has solved similar issues for me.
In
include/configs/my_board.h#define
CONFIG_SYS_DCACHE_OFF
but also slow things down in uboot, doesnt it? I've posted a patch on the uboot ml which disables the l2 cache upon linux start.
http://patchwork.ozlabs.org/patch/132533/
You could try that, too.
Signature · 1 line
michael
Quoted 14 lines · Michael Walle
Am Montag 12 Dezember 2011, 01:53:42 schrieb Nicolas Pitre:
Quoted 6 lines · Michael Walle
Quoted 3 lines
I have a marvell kirkwood based LS-CHLv2 board and running the latest HEAD of linus tree (with my dts patched for the kirkwood port, but hopefully this should be unrelated to this problem).
Did you try without those patches to be sure?
clean linux tree with old fashioned setup code now (the one i sent long time ago to this mailinglist ;).
Quoted 4 lines
Quoted 3 lines
The weird thing is that this output changes if i insert or move some debug prints. I even accomplished to make the board boot completely sometimes.
Quoted 8 lines
Quoted 2 lines
You must have some memory corrupting bug somewhere. Please try calling this code first thing in
start_kernel()for comparison.calling the dump function right at the beginning of
start_kernel()won't change anything, expect the addresses.If it would be some memory corruption, shouldn't the table or the p2v/v2p stubs be corrupt?
Not necessarily. But when memory corruption occurs, anything may happen.
Quoted 2 lines
But the non-patched entries always points to correct v2p/p2v calls and in every case there is the unpatched add/sub instruction.
Then, might it be possible that the cache is not properly turned off prior entering the kernel?
What bootloader do you use?
You could try instrumenting the patching code, although it is a bit tricky because of the non-standard register life rules in that file. But something like this should tell you if the expected amount of fixups were applied:
arch/arm/kernel/head.S +9 -0
@@ -530,14 +530,23 @@ __fixup_a_pv_table: bcc 1b bx lr #else + mov r0, #0 b 2f 1: ldr ip, [r7, r3] bic ip, ip, #0x000000ff orr ip, ip, r6 @ mask in offset bits 31-24 str ip, [r7, r3] + add r0, r0, #1 2: cmp r4, r5 ldrcc r7, [r4], #4 @ use branch for delay slot bcc 1b + + mov r6, r2 + mov r7, r3 + bl printhex8 @ display number of fixups done in r0 + mov r2, r6 + mov r3, r7 + mov pc, lr #endif ENDPROC(__fixup_a_pv_table)
Nicolas
Quoted 13 lines · Nicolas Pitre
You could try instrumenting the patching code, although it is a bit tricky because of the non-standard register life rules in that file. But something like this should tell you if the expected amount of fixups were applied:
arch/arm/kernel/head.S +0
-0@@ -530,14 +530,23 @@ __fixup_a_pv_table: bcc 1b bx lr #else
arch/arm/kernel/head.S __fixup_a_pv_table: · line 542
Quoted 10 lines
arch/arm/kernel/head.S +2
-0+ mov r0, #0 b 2f 1: ldr ip, [r7, r3] bic ip, ip, #0x000000ff orr ip, ip, r6 @ mask in offset bits 31-24 str ip, [r7, r3] + add r0, r0, #1 2: cmp r4, r5 ldrcc r7, [r4], #4 @ use branch for delay slot bcc 1b
If you look at this code, there is _no_ way it can fixup only some entries in the table and not others - unless the CPU starts executing something which isn't this code.
It quite simply loads the address of each entry in the table, incrementing the pointer by a word size. It then _unconditionally_ loads, modifies and stores the instruction at the location in question.
The termination condition is when r4 >= r5, which will prevent the loading of the next pointer _and_ prevent the looping, thus terminating the fixup altogether.
So, something else is going on. If I had to guess, I'd suspect the kernel is being called with caches enabled - which violates the expectations of the kernel set down many years ago.
Quoted 20 lines · Russell King - ARM Linux
Quoted 19 lines · Nicolas Pitre
You could try instrumenting the patching code, although it is a bit tricky because of the non-standard register life rules in that file. But something like this should tell you if the expected amount of fixups were applied:
arch/arm/kernel/head.S +1
-0@@ -530,14 +530,23 @@ __fixup_a_pv_table: bcc 1b bx lr #else + mov r0, #0 b 2f 1: ldr ip, [r7, r3] bic ip, ip, #0x000000ff orr ip, ip, r6 @ mask in offset bits 31-24 str ip, [r7, r3]
Quoted 8 lines
arch/arm/kernel/head.S __fixup_a_pv_table: · line 542
Quoted 4 lines
arch/arm/kernel/head.S +1
-0+ add r0, r0, #1 2: cmp r4, r5 ldrcc r7, [r4], #4 @ use branch for delay slot bcc 1bIf you look at this code, there is _no_ way it can fixup only some entries in the table and not others - unless the CPU starts executing something which isn't this code.
As you might imagine, I already know that. But getting the number out helps people gain confidence in the code they might not trust otherwise.
Nicolas
Am Montag 12 Dezember 2011, 22:38:07 schrieb Nicolas Pitre:
Quoted 5 lines
Quoted 2 lines
But the non-patched entries always points to correct v2p/p2v calls and in every case there is the unpatched add/sub instruction.
Then, might it be possible that the cache is not properly turned off prior entering the kernel?
i'll have a look at that
Quoted 1 line
What bootloader do you use?
U-Boot 2011.09 + patches for bsp support
Quoted 23 lines
You could try instrumenting the patching code, although it is a bit tricky because of the non-standard register life rules in that file. But something like this should tell you if the expected amount of fixups were applied:
arch/arm/kernel/head.S +2
-0@@ -530,14 +530,23 @@ __fixup_a_pv_table: bcc 1b bx lr #else + mov r0, #0 b 2f 1: ldr ip, [r7, r3] bic ip, ip, #0x000000ff orr ip, ip, r6 @ mask in offset bits 31-24 str ip, [r7, r3] + add r0, r0, #1 2: cmp r4, r5 ldrcc r7, [r4], #4 @ use branch for delay slot bcc 1b
arch/arm/kernel/head.S __fixup_a_pv_table: · line 552
Quoted 10 lines
arch/arm/kernel/head.S +7
-0+ + mov r6, r2 + mov r7, r3 + bl printhex8 @ display number of fixups done in r0 + mov r2, r6 + mov r3, r7 + mov pc, lr #endif ENDPROC(__fixup_a_pv_table)
Thanks, although the kernel hangs now after it printed the number, i can see it patched the correct number of stubs.
I'll have a look at the bootloader now.
Signature · 1 line
Michael