18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_SECTIONS_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_SECTIONS_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <asm-generic/sections.h>
88c2ecf20Sopenharmony_ci#include <asm/extable.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciextern char __brk_base[], __brk_limit[];
118c2ecf20Sopenharmony_ciextern char __end_rodata_aligned[];
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#if defined(CONFIG_X86_64)
148c2ecf20Sopenharmony_ciextern char __end_rodata_hpage_align[];
158c2ecf20Sopenharmony_ci#endif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciextern char __end_of_kernel_reserve[];
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciextern unsigned long _brk_start, _brk_end;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistatic inline bool arch_is_kernel_initmem_freed(unsigned long addr)
228c2ecf20Sopenharmony_ci{
238c2ecf20Sopenharmony_ci	/*
248c2ecf20Sopenharmony_ci	 * If _brk_start has not been cleared, brk allocation is incomplete,
258c2ecf20Sopenharmony_ci	 * and we can not make assumptions about its use.
268c2ecf20Sopenharmony_ci	 */
278c2ecf20Sopenharmony_ci	if (_brk_start)
288c2ecf20Sopenharmony_ci		return 0;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	/*
318c2ecf20Sopenharmony_ci	 * After brk allocation is complete, space between _brk_end and _end
328c2ecf20Sopenharmony_ci	 * is available for allocation.
338c2ecf20Sopenharmony_ci	 */
348c2ecf20Sopenharmony_ci	return addr >= _brk_end && addr < (unsigned long)&_end;
358c2ecf20Sopenharmony_ci}
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#endif	/* _ASM_X86_SECTIONS_H */
38