Move sysinit and sysuninit linker sets in the data (writeable) section.

Both sets are sorted in place, and with the introduction of read-only
permissions on the amd64 kernel text, the sorting override depended on
CR0.WP turned off.  Make it correct by moving the sets into writeable
part of the KVA, also fixing boot on machines where hand-off from BIOS
to OS occurs with CR0.WP set.

Based on submission by:	Peter Lei <peter.lei@ieee.org>
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2018-03-21 10:26:39 +00:00
parent 36b61ad380
commit 661722e76f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331290
2 changed files with 7 additions and 5 deletions

View File

@ -259,7 +259,7 @@ sysinit_tslog_shim(const void * data)
sysinit_tslog_shim, \
&uniquifier ## _sys_init_tslog \
}; \
DATA_SET(sysinit_set,uniquifier ## _sys_init)
DATA_WSET(sysinit_set,uniquifier ## _sys_init)
#else
#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \
static struct sysinit uniquifier ## _sys_init = { \
@ -268,7 +268,7 @@ sysinit_tslog_shim(const void * data)
func, \
(ident) \
}; \
DATA_SET(sysinit_set,uniquifier ## _sys_init)
DATA_WSET(sysinit_set,uniquifier ## _sys_init)
#endif
#define SYSINIT(uniquifier, subsystem, order, func, ident) \
@ -285,7 +285,7 @@ sysinit_tslog_shim(const void * data)
func, \
(ident) \
}; \
DATA_SET(sysuninit_set,uniquifier ## _sys_uninit)
DATA_WSET(sysuninit_set,uniquifier ## _sys_uninit)
#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
C_SYSUNINIT(uniquifier, subsystem, order, \

View File

@ -56,12 +56,13 @@
* Private macros, not to be used outside this header file.
*/
#ifdef __GNUCLIKE___SECTION
#define __MAKE_SET(set, sym) \
#define __MAKE_SET_QV(set, sym, qv) \
__GLOBL(__CONCAT(__start_set_,set)); \
__GLOBL(__CONCAT(__stop_set_,set)); \
static void const * __MAKE_SET_CONST \
static void const * qv \
__set_##set##_sym_##sym __section("set_" #set) \
__used = &(sym)
#define __MAKE_SET(set, sym) __MAKE_SET_QV(set, sym, __MAKE_SET_CONST)
#else /* !__GNUCLIKE___SECTION */
#error this file needs to be ported to your compiler
#endif /* __GNUCLIKE___SECTION */
@ -71,6 +72,7 @@
*/
#define TEXT_SET(set, sym) __MAKE_SET(set, sym)
#define DATA_SET(set, sym) __MAKE_SET(set, sym)
#define DATA_WSET(set, sym) __MAKE_SET_QV(set, sym, )
#define BSS_SET(set, sym) __MAKE_SET(set, sym)
#define ABS_SET(set, sym) __MAKE_SET(set, sym)
#define SET_ENTRY(set, sym) __MAKE_SET(set, sym)