hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/asm-generic/sections.h
....@@ -60,8 +60,8 @@
6060
6161 /* Function descriptor handling (if any). Override in asm/sections.h */
6262 #ifndef dereference_function_descriptor
63
-#define dereference_function_descriptor(p) (p)
64
-#define dereference_kernel_function_descriptor(p) (p)
63
+#define dereference_function_descriptor(p) ((void *)(p))
64
+#define dereference_kernel_function_descriptor(p) ((void *)(p))
6565 #endif
6666
6767 /* random extra sections (if any). Override
....@@ -75,6 +75,20 @@
7575
7676 #ifndef arch_is_kernel_data
7777 static inline int arch_is_kernel_data(unsigned long addr)
78
+{
79
+ return 0;
80
+}
81
+#endif
82
+
83
+/*
84
+ * Check if an address is part of freed initmem. This is needed on architectures
85
+ * with virt == phys kernel mapping, for code that wants to check if an address
86
+ * is part of a static object within [_stext, _end]. After initmem is freed,
87
+ * memory can be allocated from it, and such allocations would then have
88
+ * addresses within the range [_stext, _end].
89
+ */
90
+#ifndef arch_is_kernel_initmem_freed
91
+static inline int arch_is_kernel_initmem_freed(unsigned long addr)
7892 {
7993 return 0;
8094 }
....@@ -100,7 +114,7 @@
100114 /**
101115 * memory_intersects - checks if the region occupied by an object intersects
102116 * with another memory region
103
- * @begin: virtual address of the beginning of the memory regien
117
+ * @begin: virtual address of the beginning of the memory region
104118 * @end: virtual address of the end of the memory region
105119 * @virt: virtual address of the memory object
106120 * @size: size of the memory object
....@@ -113,7 +127,10 @@
113127 {
114128 void *vend = virt + size;
115129
116
- return (virt >= begin && virt < end) || (vend >= begin && vend < end);
130
+ if (virt < end && vend > begin)
131
+ return true;
132
+
133
+ return false;
117134 }
118135
119136 /**
....@@ -144,4 +161,18 @@
144161 return memory_intersects(__init_begin, __init_end, virt, size);
145162 }
146163
164
+/**
165
+ * is_kernel_rodata - checks if the pointer address is located in the
166
+ * .rodata section
167
+ *
168
+ * @addr: address to check
169
+ *
170
+ * Returns: true if the address is located in .rodata, false otherwise.
171
+ */
172
+static inline bool is_kernel_rodata(unsigned long addr)
173
+{
174
+ return addr >= (unsigned long)__start_rodata &&
175
+ addr < (unsigned long)__end_rodata;
176
+}
177
+
147178 #endif /* _ASM_GENERIC_SECTIONS_H_ */