Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 2020 12:10:38 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357695 - in head: sys/kern sys/sys usr.bin/procstat
Message-ID:  <202002091210.019CAciS006085@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Feb  9 12:10:37 2020
New Revision: 357695
URL: https://svnweb.freebsd.org/changeset/base/357695

Log:
  Add AT_BSDFLAGS auxv entry.
  
  The intent is to provide bsd-specific flags relevant to interpreter
  and C runtime.  I did not want to reuse AT_FLAGS which is common ELF
  auxv entry.
  
  Use bsdflags to report kernel support for sigfastblock(2).  This
  allows rtld and libthr to safely infer the syscall presence without
  SIGSYS.  The tunable kern.elf{32,64}.sigfastblock blocks reporting.
  
  Tested by:	pho
  Disscussed with:	cem, emaste, jilles
  Sponsored by:	The FreeBSD Foundation
  Differential revision:	https://reviews.freebsd.org/D12773

Modified:
  head/sys/kern/imgact_elf.c
  head/sys/sys/elf_common.h
  head/usr.bin/procstat/procstat_auxv.c

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c	Sun Feb  9 11:53:37 2020	(r357694)
+++ head/sys/kern/imgact_elf.c	Sun Feb  9 12:10:37 2020	(r357695)
@@ -183,6 +183,11 @@ SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, stack_gap, CTLFLAG
     __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE))
     ": maximum percentage of main stack to waste on a random gap");
 
+static int __elfN(sigfastblock) = 1;
+SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, sigfastblock,
+    CTLFLAG_RWTUN, &__elfN(sigfastblock), 0,
+    "enable sigfastblock for new processes");
+
 static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];
 
 #define	aligned(a, t)	(rounddown2((u_long)(a), sizeof(t)) == (u_long)(a))
@@ -1366,6 +1371,8 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *i
 		AUXARGS_ENTRY(pos, AT_HWCAP, *imgp->sysent->sv_hwcap);
 	if (imgp->sysent->sv_hwcap2 != NULL)
 		AUXARGS_ENTRY(pos, AT_HWCAP2, *imgp->sysent->sv_hwcap2);
+	AUXARGS_ENTRY(pos, AT_BSDFLAGS, __elfN(sigfastblock) ?
+	    ELF_BSDF_SIGFASTBLK : 0);
 	AUXARGS_ENTRY(pos, AT_NULL, 0);
 
 	free(imgp->auxargs, M_TEMP);

Modified: head/sys/sys/elf_common.h
==============================================================================
--- head/sys/sys/elf_common.h	Sun Feb  9 11:53:37 2020	(r357694)
+++ head/sys/sys/elf_common.h	Sun Feb  9 12:10:37 2020	(r357695)
@@ -954,8 +954,9 @@ typedef struct {
 #define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
 #define	AT_HWCAP	25	/* CPU feature flags. */
 #define	AT_HWCAP2	26	/* CPU feature flags 2. */
+#define	AT_BSDFLAGS	27	/* ELF BSD Flags. */
 
-#define	AT_COUNT	27	/* Count of defined aux entry types. */
+#define	AT_COUNT	28	/* Count of defined aux entry types. */
 
 /*
  * Relocation types.
@@ -1456,5 +1457,6 @@ typedef struct {
 #define	R_X86_64_TLSDESC	36
 #define	R_X86_64_IRELATIVE	37
 
+#define	ELF_BSDF_SIGFASTBLK	0x0001	/* Kernel supports fast sigblock */
 
 #endif /* !_SYS_ELF_COMMON_H_ */

Modified: head/usr.bin/procstat/procstat_auxv.c
==============================================================================
--- head/usr.bin/procstat/procstat_auxv.c	Sun Feb  9 11:53:37 2020	(r357694)
+++ head/usr.bin/procstat/procstat_auxv.c	Sun Feb  9 12:10:37 2020	(r357695)
@@ -197,6 +197,12 @@ procstat_auxv(struct procstat *procstat, struct kinfo_
 			    prefix, "AT_HWCAP2", (u_long)auxv[i].a_un.a_val);
 			break;
 #endif
+#ifdef AT_BSDFLAGS
+		case AT_BSDFLAGS:
+			xo_emit("{dw:/%s}{Lw:/%-16s/%s}{:AT_BSDFLAGS/%#lx}\n",
+			    prefix, "AT_BSDFLAGS", (u_long)auxv[i].a_un.a_val);
+			break;
+#endif
 		default:
 			xo_emit("{dw:/%s}{Lw:/%16ld/%ld}{:UNKNOWN/%#lx}\n",
 			    prefix, auxv[i].a_type, auxv[i].a_un.a_val);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002091210.019CAciS006085>