Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jul 2021 07:10:22 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 21629e2a4564 - main - Modify exec_sysvec_init() to allow non-native abi to setup their sysentvecs.
Message-ID:  <202107200710.16K7AMeY030205@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=21629e2a456446bff101813a16f8cba046f44176

commit 21629e2a456446bff101813a16f8cba046f44176
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-07-20 06:53:21 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2021-07-20 06:53:21 +0000

    Modify exec_sysvec_init() to allow non-native abi to setup their sysentvecs.
    
    For future use in the Linux emulation layer modify the exec_sysvec_init()
    to allow non-native abi to fill sv_timekeep_base and sv_shared_page_obj.
    
    Reviewed by:            kib
    Differential revision:  https://reviews.freebsd.org/D30898
    MFC after:              2 weeks
---
 sys/kern/kern_sharedpage.c | 43 ++++++++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/sys/kern/kern_sharedpage.c b/sys/kern/kern_sharedpage.c
index 6f14117abf39..335f49b7a9f6 100644
--- a/sys/kern/kern_sharedpage.c
+++ b/sys/kern/kern_sharedpage.c
@@ -308,27 +308,43 @@ exec_sysvec_init(void *param)
 #ifdef RANDOM_FENESTRASX
 	ptrdiff_t base;
 #endif
+	u_int flags;
 
 	sv = (struct sysentvec *)param;
-	if ((sv->sv_flags & SV_SHP) == 0)
+	flags = sv->sv_flags;
+	if ((flags & SV_SHP) == 0)
 		return;
+	MPASS(sv->sv_shared_page_obj == NULL);
+	MPASS(sv->sv_shared_page_base != 0);
+
 	sv->sv_shared_page_obj = shared_page_obj;
-	sv->sv_sigcode_base = sv->sv_shared_page_base +
-	    shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode);
-	if ((sv->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD)
-		return;
-	if ((sv->sv_flags & SV_TIMEKEEP) != 0) {
+	if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) {
+		sv->sv_sigcode_base = sv->sv_shared_page_base +
+		    shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode);
+	}
+	if ((flags & SV_TIMEKEEP) != 0) {
 #ifdef COMPAT_FREEBSD32
-		if ((sv->sv_flags & SV_ILP32) != 0) {
-			KASSERT(compat32_svtk == NULL,
-			    ("Compat32 already registered"));
-			compat32_svtk = alloc_sv_tk_compat32();
+		if ((flags & SV_ILP32) != 0) {
+			if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) {
+				KASSERT(compat32_svtk == NULL,
+				    ("Compat32 already registered"));
+				compat32_svtk = alloc_sv_tk_compat32();
+			} else {
+				KASSERT(compat32_svtk != NULL,
+				    ("Compat32 not registered"));
+			}
 			sv->sv_timekeep_base = sv->sv_shared_page_base +
 			    compat32_svtk->sv_timekeep_off;
 		} else {
 #endif
-			KASSERT(host_svtk == NULL, ("Host already registered"));
-			host_svtk = alloc_sv_tk();
+			if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) {
+				KASSERT(host_svtk == NULL,
+				    ("Host already registered"));
+				host_svtk = alloc_sv_tk();
+			} else {
+				KASSERT(host_svtk != NULL,
+				    ("Host not registered"));
+			}
 			sv->sv_timekeep_base = sv->sv_shared_page_base +
 			    host_svtk->sv_timekeep_off;
 #ifdef COMPAT_FREEBSD32
@@ -336,7 +352,8 @@ exec_sysvec_init(void *param)
 #endif
 	}
 #ifdef RANDOM_FENESTRASX
-	if ((sv->sv_flags & SV_RNG_SEED_VER) != 0) {
+	if ((flags & (SV_ABI_MASK | SV_RNG_SEED_VER)) ==
+	    (SV_ABI_FREEBSD | SV_RNG_SEED_VER)) {
 		/*
 		 * Only allocate a single VDSO entry for multiple sysentvecs,
 		 * i.e., native and COMPAT32.



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