mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
sections: provide internal __is_kernel() and __is_kernel_text() helper
An internal __is_kernel() helper which only check the kernel address ranges, and an internal __is_kernel_text() helper which only check text section ranges. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kefeng Wang <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
0a96c902d4
commit
8f6e42e833
2 files changed
+31
-2
No files matched your search
@@ -172,4 +172,33 @@ static inline bool is_kernel_inittext(unsigned long addr)
|
||||
addr < (unsigned long)_einittext;
|
||||
}
|
||||
|
||||
/**
|
||||
* __is_kernel_text - checks if the pointer address is located in the
|
||||
* .text section
|
||||
*
|
||||
* @addr: address to check
|
||||
*
|
||||
* Returns: true if the address is located in .text, false otherwise.
|
||||
* Note: an internal helper, only check the range of _stext to _etext.
|
||||
*/
|
||||
static inline bool __is_kernel_text(unsigned long addr)
|
||||
{
|
||||
return addr >= (unsigned long)_stext &&
|
||||
addr < (unsigned long)_etext;
|
||||
}
|
||||
|
||||
/**
|
||||
* __is_kernel - checks if the pointer address is located in the kernel range
|
||||
*
|
||||
* @addr: address to check
|
||||
*
|
||||
* Returns: true if the address is located in the kernel range, false otherwise.
|
||||
* Note: an internal helper, only check the range of _stext to _end.
|
||||
*/
|
||||
static inline bool __is_kernel(unsigned long addr)
|
||||
{
|
||||
return addr >= (unsigned long)_stext &&
|
||||
addr < (unsigned long)_end;
|
||||
}
|
||||
|
||||
#endif /* _ASM_GENERIC_SECTIONS_H_ */
|
||||
@@ -26,14 +26,14 @@ struct module;
|
||||
|
||||
static inline int is_kernel_text(unsigned long addr)
|
||||
{
|
||||
if ((addr >= (unsigned long)_stext && addr < (unsigned long)_etext))
|
||||
if (__is_kernel_text(addr))
|
||||
return 1;
|
||||
return in_gate_area_no_mm(addr);
|
||||
}
|
||||
|
||||
static inline int is_kernel(unsigned long addr)
|
||||
{
|
||||
if (addr >= (unsigned long)_stext && addr < (unsigned long)_end)
|
||||
if (__is_kernel(addr))
|
||||
return 1;
|
||||
return in_gate_area_no_mm(addr);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user