Skip to contentSkip to conversation

fix sun6i crash on setup_pagetables

RFC PATCH In review Bamvor Jian Zhang 3 participants 5 messages Jul 24, 2013 – Jul 25, 2013

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 fix sun6i crash on setup_pagetables

this patch move set_processor_id in front of setup_pagetables in order to fix crash when calling this_cpu in that functions. the HPTIDR is unknown value according to ARM ARM 7AR(DDI0406C), B4-1598. we should use it before using it.

but i do not know why other board like arndale board. should bootloader write this register?

---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/setup.c +1 -1
index 2f9fdc8..3bf1b40 100644
@@ -437,6 +437,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     cpus = smp_get_max_cpus();
     cmdline_parse(device_tree_bootargs(device_tree_flattened));
 
+    set_processor_id(0); /* needed early, for this_cpu() */
     setup_pagetables(boot_phys_offset, get_xen_paddr());
     setup_mm(fdt_paddr, fdt_size);
 
@@ -459,7 +460,6 @@ void __init start_xen(unsigned long boot_phys_offset,
     make_cpus_ready(cpus, boot_phys_offset);
 
     percpu_init_areas();
-    set_processor_id(0); /* needed early, for smp_processor_id() */
     set_current((struct vcpu *)0xfffff000); /* debug sanity */
     idle_vcpu[0] = current;
 
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 7 lines · Bamvor Jian Zhang

this patch move set_processor_id in front of setup_pagetables in order to fix crash when calling this_cpu in that functions. the HPTIDR is unknown value according to ARM ARM 7AR(DDI0406C), B4-1598. we should use it before using it.

but i do not know why other board like arndale board. should bootloader write this register?

On the Arndale, by default the value of HPTIDR is equal to 0. So it works without any issue.

During the afternoon, I have noticed this error and send a similar patch few minutes ago. I also moved percpu_init_areas earlier.

For the next patches, could you add the appropriate people? It will avoid to loose your patch with the other mail of the mailing list :).

Quoted 19 lines
---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/setup.c +1 -0
index 2f9fdc8..3bf1b40 100644
@@ -437,6 +437,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     cpus = smp_get_max_cpus();
     cmdline_parse(device_tree_bootargs(device_tree_flattened));
 
+    set_processor_id(0); /* needed early, for this_cpu() */
     setup_pagetables(boot_phys_offset, get_xen_paddr());
     setup_mm(fdt_paddr, fdt_size);
 

xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 462

Quoted 3 lines
xen/arch/arm/setup.c +0 -0
@@ -459,7 +460,6 @@ void __init start_xen(unsigned long boot_phys_offset,
     make_cpus_ready(cpus, boot_phys_offset);
 
     percpu_init_areas();

I think you can also move percpu_init_areas earlier.

Quoted 5 lines
xen/arch/arm/setup.c +0 -1
-    set_processor_id(0); /* needed early, for smp_processor_id() */
     set_current((struct vcpu *)0xfffff000); /* debug sanity */
     idle_vcpu[0] = current;
 
#2 lore raw
Quoted 11 lines · Julien Grall
Quoted 7 lines · Bamvor Jian Zhang

this patch move set_processor_id in front of setup_pagetables in order to fix crash when calling this_cpu in that functions. the HPTIDR is unknown value according to ARM ARM 7AR(DDI0406C), B4-1598. we should use it before using it.

but i do not know why other board like arndale board. should bootloader write this register?

On the Arndale, by default the value of HPTIDR is equal to 0. So it works without any issue.

Right, but strictly the register is undefined reset on reset.

The bootloader cannot initialise it because the meaning is entirely OS specific.

Quoted 2 lines

During the afternoon, I have noticed this error and send a similar patch few minutes ago. I also moved percpu_init_areas earlier.

Right, I think this makes sense.

I suppose I should just take your (Julien's) version of this patch?

Quoted 2 lines

For the next patches, could you add the appropriate people? It will avoid to loose your patch with the other mail of the mailing list :).

Yes please!

Quoted 32 lines
Quoted 20 lines
---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/setup.c +1 -0
index 2f9fdc8..3bf1b40 100644
@@ -437,6 +437,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     cpus = smp_get_max_cpus();
     cmdline_parse(device_tree_bootargs(device_tree_flattened));
 
+    set_processor_id(0); /* needed early, for this_cpu() */
     setup_pagetables(boot_phys_offset, get_xen_paddr());
     setup_mm(fdt_paddr, fdt_size);
 

xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 462

Quoted 3 lines
xen/arch/arm/setup.c +0 -0
@@ -459,7 +460,6 @@ void __init start_xen(unsigned long boot_phys_offset,
     make_cpus_ready(cpus, boot_phys_offset);
 
     percpu_init_areas();

I think you can also move percpu_init_areas earlier.

Quoted 5 lines
xen/arch/arm/setup.c +0 -1
-    set_processor_id(0); /* needed early, for smp_processor_id() */
     set_current((struct vcpu *)0xfffff000); /* debug sanity */
     idle_vcpu[0] = current;
 
#3 lore raw
Quoted 19 lines
Quoted 8 lines
Quoted 2 lines

Written "Ian Campbell <[email protected]>"> On Wed, 2013-07-24 at 19:33 +0100, Julien Grall wrote:

Quoted 5 lines · Bamvor Jian Zhang

this patch move set_processor_id in front of setup_pagetables in order to fix crash when calling this_cpu in that functions. the HPTIDR is unknown value according to ARM ARM 7AR(DDI0406C), B4-1598. we should use it before using it.

Quoted 5 lines
Quoted 2 lines

but i do not know why other board like arndale board. should bootloader write this register?

On the Arndale, by default the value of HPTIDR is equal to 0. So it works without any issue.

Right, but strictly the register is undefined reset on reset.

The bootloader cannot initialise it because the meaning is entirely OS specific.

Quoted 6 lines
Quoted 2 lines

During the afternoon, I have noticed this error and send a similar patch few minutes ago. I also moved percpu_init_areas earlier.

Right, I think this makes sense.

I suppose I should just take your (Julien's) version of this patch?

agree.

Quoted 4 lines
Quoted 2 lines

For the next patches, could you add the appropriate people? It will avoid to loose your patch with the other mail of the mailing list :).

Yes please!

i will, thanks.

Quoted 36 lines
Quoted 32 lines
Quoted 20 lines

---

 xen/arch/arm/setup.c | 2 +- 
 1 file changed, 1 insertion(+), 1 deletion(-) 
xen/arch/arm/setup.c +1 -0
index 2f9fdc8..3bf1b40 100644 
@@ -437,6 +437,7 @@ void __init start_xen(unsigned long boot_phys_offset, 
     cpus = smp_get_max_cpus(); 
     cmdline_parse(device_tree_bootargs(device_tree_flattened)); 
 
+    set_processor_id(0); /* needed early, for this_cpu() */ 
     setup_pagetables(boot_phys_offset, get_xen_paddr()); 
     setup_mm(fdt_paddr, fdt_size); 
 

xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 462

Quoted 3 lines
xen/arch/arm/setup.c +0 -0
@@ -459,7 +460,6 @@ void __init start_xen(unsigned long boot_phys_offset, 
     make_cpus_ready(cpus, boot_phys_offset); 
 
     percpu_init_areas(); 

I think you can also move percpu_init_areas earlier.

Quoted 5 lines
xen/arch/arm/setup.c +0 -1
-    set_processor_id(0); /* needed early, for smp_processor_id() */ 
     set_current((struct vcpu *)0xfffff000); /* debug sanity */ 
     idle_vcpu[0] = current; 
 
#4 lore raw
In reply to Ian Campbell
Quoted 18 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Quoted 7 lines · Bamvor Jian Zhang

this patch move set_processor_id in front of setup_pagetables in order to fix crash when calling this_cpu in that functions. the HPTIDR is unknown value according to ARM ARM 7AR(DDI0406C), B4-1598. we should use it before using it.

but i do not know why other board like arndale board. should bootloader write this register?

On the Arndale, by default the value of HPTIDR is equal to 0. So it works without any issue.

Right, but strictly the register is undefined reset on reset.

The bootloader cannot initialise it because the meaning is entirely OS specific.

Quoted 6 lines
Quoted 2 lines

During the afternoon, I have noticed this error and send a similar patch few minutes ago. I also moved percpu_init_areas earlier.

Right, I think this makes sense.

I suppose I should just take your (Julien's) version of this patch?

If you take my patch, could you slighty modify the commit message to specify that's in an issue on sun6i?

Quoted 39 lines
Quoted 2 lines

For the next patches, could you add the appropriate people? It will avoid to loose your patch with the other mail of the mailing list :).

Yes please!

Quoted 32 lines
Quoted 20 lines
---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/setup.c +1 -0
index 2f9fdc8..3bf1b40 100644
@@ -437,6 +437,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     cpus = smp_get_max_cpus();
     cmdline_parse(device_tree_bootargs(device_tree_flattened));
 
+    set_processor_id(0); /* needed early, for this_cpu() */
     setup_pagetables(boot_phys_offset, get_xen_paddr());
     setup_mm(fdt_paddr, fdt_size);
 

xen/arch/arm/setup.c void __init start_xen(unsigned long boot_phys_offset, · line 462

Quoted 3 lines
xen/arch/arm/setup.c +0 -0
@@ -459,7 +460,6 @@ void __init start_xen(unsigned long boot_phys_offset,
     make_cpus_ready(cpus, boot_phys_offset);
 
     percpu_init_areas();

I think you can also move percpu_init_areas earlier.

Quoted 5 lines
xen/arch/arm/setup.c +0 -1
-    set_processor_id(0); /* needed early, for smp_processor_id() */
     set_current((struct vcpu *)0xfffff000); /* debug sanity */
     idle_vcpu[0] = current;