From patchwork Wed Jul 4 15:55:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 939458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=st.com Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41LQkq3SRwz9s3q for ; Thu, 5 Jul 2018 02:03:15 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 9A9D810002; Wed, 4 Jul 2018 18:03:12 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by helium.openadk.org (Postfix) with ESMTPS id E35A610002 for ; Wed, 4 Jul 2018 18:03:10 +0200 (CEST) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w64G0DOM007977; Wed, 4 Jul 2018 18:03:10 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2k0dnwvrs4-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 04 Jul 2018 18:03:10 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BF35D31; Wed, 4 Jul 2018 16:03:08 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 88304AEB5; Wed, 4 Jul 2018 16:03:08 +0000 (GMT) Received: from gnb.st.com (10.75.127.44) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 4 Jul 2018 18:03:07 +0200 From: Christophe Lyon To: , Date: Wed, 4 Jul 2018 17:55:32 +0200 Message-ID: <20180704155605.1892-20-christophe.lyon@st.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180704155605.1892-1-christophe.lyon@st.com> References: <20180704155605.1892-1-christophe.lyon@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-04_06:, , signatures=0 Subject: [uclibc-ng-devel] [PATCH 19/32] [FDPIC] nptl: Disable fork and atfork on MMU-less systems. X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" They do not work on MMU-less systems. For atfork, implement a hidden function that always returns EPERM. * libpthread/nptl/sysdeps/unix/sysv/linux/fork.c: Disable if __ARCH_USE_MMU__ is not defined. * libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init): Handle __ARCH_USE_MMU__. * libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c: Likewise. * libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c index 9b96152..429fb90 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c @@ -28,6 +28,7 @@ #include #include +#ifdef __ARCH_USE_MMU__ unsigned long int *__fork_generation_pointer; @@ -206,3 +207,5 @@ fork (void) return pid; } libc_hidden_def(fork) + +#endif /* __ARCH_USE_MMU__ */ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c index 0df9951..0cdbcfe 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c @@ -40,10 +40,14 @@ __libc_pthread_init ( void (*reclaim) (void)) { /* Remember the pointer to the generation counter in libpthread. */ +#ifdef __ARCH_USE_MMU__ __fork_generation_pointer = ptr; +#endif /* Called by a child after fork. */ +#ifdef __ARCH_USE_MMU__ __register_atfork (NULL, NULL, reclaim, NULL); +#endif #ifndef TLS_MULTIPLE_THREADS_IN_TCB return &__libc_multiple_threads; diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c index b745f9d..55835e5 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c @@ -24,6 +24,7 @@ #include +#ifdef __ARCH_USE_MMU__ /* Lock to protect allocation and deallocation of fork handlers. */ int __fork_lock = LLL_LOCK_INITIALIZER; @@ -118,6 +119,18 @@ __linkin_atfork (struct fork_handler *newp) while (catomic_compare_and_exchange_bool_acq (&__fork_handlers, newp, newp->next) != 0); } +#else +int +__register_atfork ( + void (*prepare) (void), + void (*parent) (void), + void (*child) (void), + void *dso_handle) +{ + return EPERM; +} +libc_hidden_def (__register_atfork) +#endif #if 0 libc_freeres_fn (free_mem) @@ -145,4 +158,3 @@ libc_freeres_fn (free_mem) } } #endif - diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c index 69e2621..e958e71 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c @@ -22,7 +22,7 @@ #include #include - +#ifdef __ARCH_USE_MMU__ void __unregister_atfork ( void *dso_handle) @@ -120,3 +120,11 @@ __unregister_atfork ( deleted = deleted->next; } } +#else +void +__unregister_atfork ( + void *dso_handle) +{ + /* Nothing to do. */ +} +#endif