From patchwork Fri Apr 3 20:31:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 38739 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by sourceware.org (Postfix) with ESMTPS id 61922385DC3A for ; Fri, 3 Apr 2020 20:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61922385DC3A Received: by mail-qv1-xf41.google.com with SMTP id q73so4313070qvq.2 for ; Fri, 03 Apr 2020 13:32:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=87RI9f+2ac7f86ZDx1oLVucd0xDtsbG/ubWr2xW4740=; b=EQL0OttKezIR5umlMtGFKGFf8IsppsI3PqFQGqhXzK9YqbG2t9kI/QJzs1JoXHAv+a vbkEaE606EttJ4CAh0TekVnDt7/ILH9/NQH6jWCOXQCKKQyWGtbkQON3m6SCi1wtJHqb 0RH3Xmnn0jvLlNksyEogfGCwqwLLqDOj6XjmWU/Td1a3nZAhI1mH+etvARLM9ffXaVoU 08w0LlUJdfy42/zA9Dx2kfFIC0linl+rOprfXsCWEFUh//OuxnksE78GGS5o4NPWSWgT Z0QoRGFkPUdFfjr4z9tkBXprZMfpQlY7Opdh9cyKjvAK5jNRPeiRusiApekQfPNycMoo zRUw== X-Gm-Message-State: AGi0PubwypfnjxM0068epq40x4xKtLGr9m0aWl8BLPyQuJwtbTJTI4rH FmOd2UX6ORLBLP4tBZRmVBN8PFuTeQQ= X-Google-Smtp-Source: APiQypL89eQFOxpP3Xe5YbgGuOZSO8FRWYI2MdTRRvElFoaK9QIRL+1l9ZoxJCBUtPegoC7QiJb/pQ== X-Received: by 2002:ad4:4564:: with SMTP id o4mr9972290qvu.190.1585945948725; Fri, 03 Apr 2020 13:32:28 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id d141sm7063535qke.68.2020.04.03.13.32.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:32:28 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v4 14/21] nptl: m68k: Fix Race conditions in pthread cancellation [BZ#12683] Date: Fri, 3 Apr 2020 17:31:54 -0300 Message-Id: <20200403203201.7494-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403203201.7494-1-adhemerval.zanella@linaro.org> References: <20200403203201.7494-1-adhemerval.zanella@linaro.org> X-Spam-Status: No, score=-26.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2020 20:32:30 -0000 This patch adds the m68k modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on m68k-linux-gnu. --- sysdeps/m68k/nptl/tcb-offsets.sym | 3 + sysdeps/unix/sysv/linux/m68k/syscall_cancel.S | 85 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/m68k/syscall_cancel.S diff --git a/sysdeps/m68k/nptl/tcb-offsets.sym b/sysdeps/m68k/nptl/tcb-offsets.sym index 241fb8b47c..59c9f78f8c 100644 --- a/sysdeps/m68k/nptl/tcb-offsets.sym +++ b/sysdeps/m68k/nptl/tcb-offsets.sym @@ -8,3 +8,6 @@ MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads) TID_OFFSET thread_offsetof (tid) + +-- Not strictly offsets, used on syscall_cancel.S +TCB_CANCELED_BIT CANCELED_BIT diff --git a/sysdeps/unix/sysv/linux/m68k/syscall_cancel.S b/sysdeps/unix/sysv/linux/m68k/syscall_cancel.S new file mode 100644 index 0000000000..59df082a28 --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/syscall_cancel.S @@ -0,0 +1,85 @@ +/* Cancellable syscall wrapper. Linux/m68k version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6, + __syscall_arg_t arg7) */ + + +ENTRY (__syscall_cancel_arch) +#ifdef __mcoldfire__ + lea (-16,%sp),%sp + movem.l #60,(%sp) +#else + movem.l #15360,-(%sp) +#endif + cfi_def_cfa_offset (20) + cfi_offset (2, -20) + cfi_offset (3, -16) + cfi_offset (4, -12) + cfi_offset (5, -8) + + .global __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + move.l 20(%sp),%a0 + move.l (%a0),%d0 +#ifdef __mcoldfire__ + move.w %d0,%ccr + jeq 1f +#else + btst #TCB_CANCELED_BIT,%d0 + jne 1f +#endif + + move.l 48(%sp),%a0 + move.l 44(%sp),%d5 + move.l 40(%sp),%d4 + move.l 36(%sp),%d3 + move.l 32(%sp),%d2 + move.l 28(%sp),%d1 + move.l 24(%sp),%d0 + trap #0 + + .global __syscall_cancel_arch_end +__syscall_cancel_arch_end: + +#ifdef __mcoldfire__ + movem.l (%sp),#60 + lea (16,%sp),%sp +#else + movem.l (%sp)+,#60 +#endif + rts + +1: +#ifdef PIC + bsr.l __syscall_do_cancel +#else + jsr __syscall_do_cancel +#endif +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch)