svn commit: r324687 - in stable/11/sys: arm/include arm64/include kern mips/include powerpc/include riscv/include sparc64/include sys x86/include

John Baldwin jhb at FreeBSD.org
Tue Oct 17 12:45:53 UTC 2017


Author: jhb
Date: Tue Oct 17 12:45:51 2017
New Revision: 324687
URL: https://svnweb.freebsd.org/changeset/base/324687

Log:
  MFC 323579,323585: Add AT_HWCAP and AT_EHDRFLAGS on all platforms.
  
  To preserve KBI on stable/11, a new SV_HWCAP flag is added which
  indicates if the sv_hwcap field is present and valid to avoid examining
  the field in old modules.  Only sysentvec's which wish to use sv_hwcap
  need to set the flag in stable/11.
  
  323579:
  Add AT_HWCAP and AT_EHDRFLAGS on all platforms.
  
  A new 'u_long *sv_hwcap' field is added to 'struct sysentvec'.  A
  process ABI can set this field to point to a value holding a mask of
  architecture-specific CPU feature flags.  If an ABI does not wish to
  supply AT_HWCAP to processes the field can be left as NULL.
  
  The support code for AT_EHDRFLAGS was already present on all systems,
  just the #define was not present.  This is a step towards unifying the
  AT_* constants across platforms.
  
  323585:
  Add AT_EHDRFLAGS and AT_HWCAP on amd64.
  
  x86 has two separate (but identical) list of AT_* constants and the
  earlier commit to add AT_HWCAP only updated the i386 list.

Modified:
  stable/11/sys/arm/include/elf.h
  stable/11/sys/arm64/include/elf.h
  stable/11/sys/kern/imgact_elf.c
  stable/11/sys/mips/include/elf.h
  stable/11/sys/powerpc/include/elf.h
  stable/11/sys/riscv/include/elf.h
  stable/11/sys/sparc64/include/elf.h
  stable/11/sys/sys/sysent.h
  stable/11/sys/x86/include/elf.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/include/elf.h
==============================================================================
--- stable/11/sys/arm/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/arm/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -85,8 +85,9 @@ __ElfType(Auxinfo);
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
 #define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	25	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 #define	R_ARM_COUNT	33	/* Count of defined relocation types. */
 

Modified: stable/11/sys/arm64/include/elf.h
==============================================================================
--- stable/11/sys/arm64/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/arm64/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -90,8 +90,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	24	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 /* Define "machine" characteristics */
 #define	ELF_TARG_CLASS	ELFCLASS64

Modified: stable/11/sys/kern/imgact_elf.c
==============================================================================
--- stable/11/sys/kern/imgact_elf.c	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/kern/imgact_elf.c	Tue Oct 17 12:45:51 2017	(r324687)
@@ -1110,9 +1110,7 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct 
 	AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
 	AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
 	AUXARGS_ENTRY(pos, AT_BASE, args->base);
-#ifdef AT_EHDRFLAGS
 	AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags);
-#endif
 	if (imgp->execpathp != 0)
 		AUXARGS_ENTRY(pos, AT_EXECPATH, imgp->execpathp);
 	AUXARGS_ENTRY(pos, AT_OSRELDATE,
@@ -1133,6 +1131,9 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct 
 	AUXARGS_ENTRY(pos, AT_STACKPROT, imgp->sysent->sv_shared_page_obj
 	    != NULL && imgp->stack_prot != 0 ? imgp->stack_prot :
 	    imgp->sysent->sv_stackprot);
+	if ((imgp->sysent->sv_flags & SV_HWCAP) != 0 &&
+	    imgp->sysent->sv_hwcap != NULL)
+		AUXARGS_ENTRY(pos, AT_HWCAP, *imgp->sysent->sv_hwcap);
 	AUXARGS_ENTRY(pos, AT_NULL, 0);
 
 	free(imgp->auxargs, M_TEMP);

Modified: stable/11/sys/mips/include/elf.h
==============================================================================
--- stable/11/sys/mips/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/mips/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -144,8 +144,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	24	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 #define	ET_DYN_LOAD_ADDR 0x0120000
 

Modified: stable/11/sys/powerpc/include/elf.h
==============================================================================
--- stable/11/sys/powerpc/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/powerpc/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -107,8 +107,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	19	/* Number of pagesizes. */
 #define	AT_STACKPROT	21	/* Initial stack protection. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	23	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 /*
  * Relocation types.

Modified: stable/11/sys/riscv/include/elf.h
==============================================================================
--- stable/11/sys/riscv/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/riscv/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -90,8 +90,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	24	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 /* Define "machine" characteristics */
 #define	ELF_TARG_CLASS	ELFCLASS64

Modified: stable/11/sys/sparc64/include/elf.h
==============================================================================
--- stable/11/sys/sparc64/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/sparc64/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -92,8 +92,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	24	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 /* Define "machine" characteristics */
 #if __ELF_WORD_SIZE == 32

Modified: stable/11/sys/sys/sysent.h
==============================================================================
--- stable/11/sys/sys/sysent.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/sys/sysent.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -129,6 +129,7 @@ struct sysentvec {
 	void		(*sv_schedtail)(struct thread *);
 	void		(*sv_thread_detach)(struct thread *);
 	int		(*sv_trap)(struct thread *);
+	u_long		*sv_hwcap;	/* Value passed in AT_HWCAP. */
 };
 
 #define	SV_ILP32	0x000100	/* 32-bit executable. */
@@ -138,6 +139,7 @@ struct sysentvec {
 #define	SV_SHP		0x010000	/* Shared page. */
 #define	SV_CAPSICUM	0x020000	/* Force cap_enter() on startup. */
 #define	SV_TIMEKEEP	0x040000	/* Shared page timehands. */
+#define	SV_HWCAP	0x080000	/* sv_hwcap field is valid. */
 
 #define	SV_ABI_MASK	0xff
 #define	SV_ABI_ERRNO(p, e)	((p)->p_sysent->sv_errsize <= 0 ? e :	\

Modified: stable/11/sys/x86/include/elf.h
==============================================================================
--- stable/11/sys/x86/include/elf.h	Tue Oct 17 12:42:17 2017	(r324686)
+++ stable/11/sys/x86/include/elf.h	Tue Oct 17 12:45:51 2017	(r324687)
@@ -100,8 +100,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	24	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 /*
  * Relocation types.
@@ -185,8 +187,10 @@ __ElfType(Auxinfo);
 #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
 #define	AT_STACKPROT	23	/* Initial stack protection. */
+#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
+#define	AT_HWCAP	25	/* CPU feature flags. */
 
-#define	AT_COUNT	24	/* Count of defined aux entry types. */
+#define	AT_COUNT	26	/* Count of defined aux entry types. */
 
 /*
  * Relocation types.


More information about the svn-src-stable mailing list