Skip to contentSkip to conversation

asm/sections: add text/data checking functions for arches to override

PATCH In review Mike Frysinger 3 participants 7 messages Jun 17, 2009 – Jun 24, 2009 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 asm/sections: add text/data checking functions for arches to override

Some ports (like the Blackfin arch) have a discontiguous memory map which means there may be text or data that falls outside of the standard range of the start/end text/data symbols. Creating some helper functions allows these non-standard ports to declare these regions without adversely affecting anyone else.

---
 include/asm-generic/sections.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
include/asm-generic/sections.h +16 -0
index 4ce48e8..ee19462 100644
@@ -20,4 +20,20 @@ extern char __start_rodata[], __end_rodata[];
 #define dereference_function_descriptor(p) (p)
 #endif
 
+/* random extra sections (if any).  Override
+ * in asm/sections.h */
+#ifndef arch_is_kernel_text
+static inline int arch_is_kernel_text(unsigned long addr)
+{
+	return 0;
+}
+#endif
+
+#ifndef arch_is_kernel_data
+static inline int arch_is_kernel_data(unsigned long addr)
+{
+	return 0;
+}
+#endif
+
 #endif /* _ASM_GENERIC_SECTIONS_H_ */
Signature · 1 line
1.6.3.1
#1 lore raw

PATCH 2/4 kallsyms: use new arch_is_kernel_text()

This allows kallsyms to locate symbols that are in arch-specific text sections (such as text in Blackfin on-chip SRAM regions).

---
 kernel/kallsyms.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/kallsyms.c +2 -1
index 3a29dbe..8b6b8b6 100644
@@ -59,7 +59,8 @@ static inline int is_kernel_inittext(unsigned long addr)
 
 static inline int is_kernel_text(unsigned long addr)
 {
-	if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext)
+	if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
+	    arch_is_kernel_text(addr))
 		return 1;
 	return in_gate_area_no_task(addr);
 }
Signature · 1 line
1.6.3.1
#2 lore raw

PATCH 3/4 lockdep: use new arch_is_kernel_data()

In reply to Mike Frysinger

This allows lockdep to locate symbols that are in arch-specific data sections (such as data in Blackfin on-chip SRAM regions).

---
 kernel/lockdep.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
kernel/lockdep.c +3 -0
index 8bbeef9..8dc9b6a 100644
@@ -636,6 +636,9 @@ static int static_obj(void *obj)
 	if ((addr >= start) && (addr < end))
 		return 1;
 
+	if (arch_is_kernel_data(addr))
+		return 1;
+
 #ifdef CONFIG_SMP
 	/*
 	 * percpu var?
Signature · 1 line
1.6.3.1
#3 lore raw

PATCH 4/4 Blackfin: override text/data checking functions

In reply to Mike Frysinger
---
 arch/blackfin/include/asm/sections.h |   38 +++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 3 deletions(-)
arch/blackfin/include/asm/sections.h +35 -3
index e7fd0ec..ae4dae1 100644
@@ -1,9 +1,6 @@
 #ifndef _BLACKFIN_SECTIONS_H
 #define _BLACKFIN_SECTIONS_H
 
-/* nothing to see, move along */
-#include <asm-generic/sections.h>
-
 /* only used when MTD_UCLINUX */
 extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size;
 
@@ -15,4 +12,39 @@ extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
 	_stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[],
 	_ebss_l2[], _l2_lma_start[];
 
+#include <asm/mem_map.h>
+
+/* Blackfin systems have discontinuous memory map and no virtualized memory */
+static inline int arch_is_kernel_text(unsigned long addr)
+{
+	return
+		(L1_CODE_LENGTH &&
+		 addr >= (unsigned long)_stext_l1 &&
+		 addr <  (unsigned long)_etext_l1)
+		||
+		(L2_LENGTH &&
+		 addr >= (unsigned long)_stext_l2 &&
+		 addr <  (unsigned long)_etext_l2);
+}
+#define arch_is_kernel_text(addr) arch_is_kernel_text(addr)
+
+static inline int arch_is_kernel_data(unsigned long addr)
+{
+	return
+		(L1_DATA_A_LENGTH &&
+		 addr >= (unsigned long)_sdata_l1 &&
+		 addr <  (unsigned long)_ebss_l1)
+		||
+		(L1_DATA_B_LENGTH &&
+		 addr >= (unsigned long)_sdata_b_l1 &&
+		 addr <  (unsigned long)_ebss_b_l1)
+		||
+		(L2_LENGTH &&
+		 addr >= (unsigned long)_sdata_l2 &&
+		 addr <  (unsigned long)_ebss_l2);
+}
+#define arch_is_kernel_data(addr) arch_is_kernel_data(addr)
+
+#include <asm-generic/sections.h>
+
 #endif
Signature · 1 line
1.6.3.1
#4 lore raw
In reply to Mike Frysinger
Quoted 6 lines · On Wed, 17 Jun 2009 12:22:21 -0400 Mike Frysinger <[email protected]> wrote:

Some ports (like the Blackfin arch) have a discontiguous memory map which means there may be text or data that falls outside of the standard range of the start/end text/data symbols. Creating some helper functions allows these non-standard ports to declare these regions without adversely affecting anyone else.

The patches look OK to me.

I assumed they're for 2.6.32.

Quoted 12 lines

index 4ce48e8..ee19462 100644

include/asm-generic/sections.h +5 -0
@@ -20,4 +20,20 @@ extern char __start_rodata[], __end_rodata[];
 #define dereference_function_descriptor(p) (p)
 #endif
 
+/* random extra sections (if any).  Override
+ * in asm/sections.h */
+#ifndef arch_is_kernel_text
+static inline int arch_is_kernel_text(unsigned long addr)
+{

include/asm-generic/sections.h extern char __start_rodata[], __end_rodata[]; · line 37

Quoted 10 lines
include/asm-generic/sections.h +10 -0
+	return 0;
+}
+#endif
+
+#ifndef arch_is_kernel_data
+static inline int arch_is_kernel_data(unsigned long addr)
+{
+	return 0;
+}
+#endif

I suppose that for completeness and consistency etc really we should have

#define arch_is_kernel_text arch_is_kernel_text
#define arch_is_kernel_data arch_is_kernel_data

in here.

#5 lore raw
Quoted 10 lines · Andrew Morton
Quoted 5 lines · On Wed, 17 Jun 2009 12:22:21 -0400 Mike Frysinger wrote:

Some ports (like the Blackfin arch) have a discontiguous memory map which means there may be text or data that falls outside of the standard range of the start/end text/data symbols.  Creating some helper functions allows these non-standard ports to declare these regions without adversely affecting anyone else.

The patches look OK to me.

I assumed they're for 2.6.32.

it's for whatever is easiest to merge

Quoted 25 lines
Quoted 12 lines

index 4ce48e8..ee19462 100644

include/asm-generic/sections.h +5 -0
@@ -20,4 +20,20 @@ extern char __start_rodata[], __end_rodata[];
  #define dereference_function_descriptor(p) (p)
  #endif
 
+/* random extra sections (if any).  Override
+ * in asm/sections.h */
+#ifndef arch_is_kernel_text
+static inline int arch_is_kernel_text(unsigned long addr)
+{

include/asm-generic/sections.h extern char __start_rodata[], __end_rodata[]; · line 37

Quoted 10 lines
include/asm-generic/sections.h +10 -0
+     return 0;
+}
+#endif
+
+#ifndef arch_is_kernel_data
+static inline int arch_is_kernel_data(unsigned long addr)
+{
+     return 0;
+}
+#endif

I suppose that for completeness and consistency etc really we should have

Quoted 4 lines

#define arch_is_kernel_text arch_is_kernel_text
#define arch_is_kernel_data arch_is_kernel_data

in here.

*shrug* other places that use this style dont include these defines for completeness as the define muck is for the header to know about (arches providing their own version), not any source code -- they shouldnt know anything about the ifdef stuff. i dont care much either way.
-mike

#6 lore raw
Quoted 9 lines · On Tue, 23 Jun 2009 21:48:03 -0400 Mike Frysinger <[email protected]> wrote:
Quoted 6 lines

I suppose that for completeness and consistency etc really we should have

#define arch_is_kernel_text arch_is_kernel_text
#define arch_is_kernel_data arch_is_kernel_data

in here.

*shrug* other places that use this style dont include these defines for completeness

Examples?

All the ones I can find do things like

#ifndef vmcore_elf_check_arch_cross
#define vmcore_elf_check_arch_cross(x) 0
#endif

Quoted 3 lines

as the define muck is for the header to know about (arches providing their own version), not any source code -- they shouldnt know anything about the ifdef stuff.

Failing to do the #define will have various tricky failure modes. But it's more a question of "what is the _right_ thing to do", then doing that consistently.

Quoted 1 line

i dont care much either way.

Someone has to.