From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 5D1673857701 for ; Mon, 10 Apr 2023 20:46:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D1673857701 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x234.google.com with SMTP id w19so4030204oiv.13 for ; Mon, 10 Apr 2023 13:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681159590; x=1683751590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0zhXmpXeeV0xUTqi6HqdyHwlPgZM86eBOqBRCdA+MHw=; b=z5YDsULe1PDpZIuXWVrzuC4SKvuaWSTVPQd6nmFt+4Ei9ny2gqxOLMsRf6Ey5oWh8D kDoBgdKNEX5MDpsunGBteaymBbwdCOid4Gbs3ILIJ7nDZMv6YhW/QVbrfI7hRzQS7nf8 q8cni/27n3bIWg2IZIytbTy4I2Jg3nlowQLngCILJGTFog44Zdpq1cquEDRIhDazpD9j plTsUlitx03UD4E4H7ULAf4Qepauhd2DKKa5ceRzz826dhvPLKFz66FTvYCAAn8z/l91 kiACg+Xw0hmnp++QveGyHYEtDWP+2uuEzfmm5FAeceHU9jQnuubMZsDavtY6gp4Nr2eC 3xyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681159590; x=1683751590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0zhXmpXeeV0xUTqi6HqdyHwlPgZM86eBOqBRCdA+MHw=; b=kdrdrq+a1SrVr6TvnTStqhROqfbr0ioF0omgLNjX4G3w1yT0DDSkBmLMbx3CN8wbgl xn/H5JOuhsZEzQSWxZNSQPd7Q2WSJFt5jFx4EUkLsZcmWVHEovW/xw2TLZGyzQsf6v9A mXGOu7XN1ljfkR15dkR/IEXIvj6bQnHhTb1F1D7SSq3BZohKKNDnnYQ/3wfy68sDsYyW 31oCzZYucxwOPiqnWbdW0144TO20yB1jQGf6Lm9WQDL+CMzOgLTssY79eDjLx/88V4NK +QKF5rFP2WwvguQfTKZ1JhwjXmN9ggJst0K3mR9CDCQLhsjEDEVi8QHqIN1kFatpy/2B pgXQ== X-Gm-Message-State: AAQBX9frrCQTiP/GAt2EGOmomjK16+WZRg9lLkj5x5oHFWulCoSmYRmF 8tNzx5u/T8DC2gJms9+ZcMvbGFlSDnqMMwGLH3k2Kg== X-Google-Smtp-Source: AKy350ahrXrO5ttzIrwTOHcyir2wbC2t35IlVMO+ONFEy0q459xWhHHJslxIOr4kUWT63yMI/SkeLA== X-Received: by 2002:aca:1b0a:0:b0:38b:5349:e112 with SMTP id b10-20020aca1b0a000000b0038b5349e112mr4844286oib.46.1681159588986; Mon, 10 Apr 2023 13:46:28 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:55a1:d59a:609a:284:6ed]) by smtp.gmail.com with ESMTPSA id p5-20020acabf05000000b003896f132821sm4865732oif.41.2023.04.10.13.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 13:46:28 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v5 14/22] nios2: Fix Race conditions in pthread cancellation [BZ#12683] Date: Mon, 10 Apr 2023 17:46:06 -0300 Message-Id: <20230410204614.4129551-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230410204614.4129551-1-adhemerval.zanella@linaro.org> References: <20230410195907.4123869-1-adhemerval.zanella@linaro.org> <20230410204614.4129551-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: By adding the required syscall_cancel.S. Checked against a build and make check run-built-tests=no for nios2-linux-gnu. --- .../unix/sysv/linux/nios2/syscall_cancel.S | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_cancel.S diff --git a/sysdeps/unix/sysv/linux/nios2/syscall_cancel.S b/sysdeps/unix/sysv/linux/nios2/syscall_cancel.S new file mode 100644 index 0000000000..19d0795886 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nios2/syscall_cancel.S @@ -0,0 +1,95 @@ +/* Cancellable syscall wrapper. Linux/nios2 version. + Copyright (C) 2023 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 +#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) */ + +ENTRY (__syscall_cancel_arch) +#ifdef SHARED + addi sp, sp, -8 + stw r22, 0(sp) + nextpc r22 +1: + movhi r8, %hiadj(_gp_got - 1b) + addi r8, r8, %lo(_gp_got - 1b) + stw ra, 4(sp) + add r22, r22, r8 +#else + addi sp, sp, -4 + cfi_def_cfa_offset (4) + stw ra, 0(sp) + cfi_offset (31, -4) +#endif + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + ldw r3, 0(r4) + andi r3, r3, TCB_CANCELED_BITMASK + bne r3, zero, 3f + mov r10, r6 + mov r2, r5 +#ifdef SHARED +# define STACK_ADJ 4 +#else +# define STACK_ADJ 0 +#endif + ldw r9, (16 + STACK_ADJ)(sp) + mov r5, r7 + ldw r8, (12 + STACK_ADJ)(sp) + ldw r7, (8 + STACK_ADJ)(sp) + ldw r6, (4 + STACK_ADJ)(sp) + mov r4, r10 + trap + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + beq r7, zero, 2f + sub r2, zero, r2 +2: +#ifdef SHARED + ldw ra, 4(sp) + ldw r22, 0(sp) + addi sp, sp, 8 +#else + ldw ra, (0 + STACK_ADJ)(sp) + cfi_remember_state + cfi_restore (31) + addi sp, sp, 4 + cfi_def_cfa_offset (0) +#endif + ret + +3: +#ifdef SHARED + ldw r2, %call(__syscall_do_cancel)(r22) + callr r2 +#else + cfi_restore_state + call __syscall_do_cancel +#endif + +END (__syscall_cancel_arch) -- 2.34.1