svn commit: r331290 - head/sys/sys

Konstantin Belousov kib at FreeBSD.org
Wed Mar 21 10:26:40 UTC 2018


Author: kib
Date: Wed Mar 21 10:26:39 2018
New Revision: 331290
URL: https://svnweb.freebsd.org/changeset/base/331290

Log:
  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 at ieee.org>
  MFC after:	1 week

Modified:
  head/sys/sys/kernel.h
  head/sys/sys/linker_set.h

Modified: head/sys/sys/kernel.h
==============================================================================
--- head/sys/sys/kernel.h	Wed Mar 21 09:57:29 2018	(r331289)
+++ head/sys/sys/kernel.h	Wed Mar 21 10:26:39 2018	(r331290)
@@ -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,		\

Modified: head/sys/sys/linker_set.h
==============================================================================
--- head/sys/sys/linker_set.h	Wed Mar 21 09:57:29 2018	(r331289)
+++ head/sys/sys/linker_set.h	Wed Mar 21 10:26:39 2018	(r331290)
@@ -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)


More information about the svn-src-head mailing list