From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 08D3E385771B for ; Mon, 10 Apr 2023 19:59:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08D3E385771B 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-ot1-x333.google.com with SMTP id cg19-20020a056830631300b0069f922cd5ceso2793445otb.12 for ; Mon, 10 Apr 2023 12:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681156767; x=1683748767; 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=vuz0tFwOarGWknGLvIQpj2ojEdwLGgk7PSoRumb7nA4=; b=Ga7PP2ZlvcqyIxUogcJfFe9vh/lvvry0VuVEhDo0RHPqROGZ+hkIptF/f7/TLj+uH+ 7LR1DjBA/E42QYYCfEJoxFG+/ceZcj0KuZCbCWsInKdJP/DfC2TFCMotmDk+fTVGQx2J CfNi1J73TFUY46yZur4Nyv663xaQHdjKJX23XPM6bdUKuIpBW6ajkOz0T+xvzMDW3CXB fucefRJep+MFdG4gZbqJdOaJdGUKd6Wb21h8roOp/Hd97bzt4szy3aATsavOjJfbM9Gi 8aWgnCoJqP+oXnRLm0k5zpop+8ce6NC5MkxOxk3EMAAKrr4xr/tXV2oSzIKCY2NeRYQS jRsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681156767; x=1683748767; 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=vuz0tFwOarGWknGLvIQpj2ojEdwLGgk7PSoRumb7nA4=; b=18yG0g6exYak1z93IiPuqUGDVBsKp3jcBGLw8QRHnfWsu8ODcbyHcEcUfN9/nvjQZL C4aTTMBSH439qQJZz2JuOBdBGgLjN/YQ/FLuCUZusOkIsxt7A8EbhFwwLsHq8FdWXnPf ArHqh7cn9da4uXi74GWM/EEHRRwSPtIXVNwONhPHvfgxq5cPW7X3DJnv7SzPSt7IZ6xV zNt6iyOz6YesSHVTTbxEYRd4HeOFlM9iy0wktCAHmZVqGFVfpCgLN/V/OHWXZqpgF6KQ ft9S17A2eAjixbs0H88J1fnYyYuRqUsqhpR0TMQ9bgao/tYv68bj7V/QL+2SORpmjGTp 4NlA== X-Gm-Message-State: AAQBX9cZ8p6ozFCWaDANHv94tJ2LAHA6K95bjFLsWSC+l0ub6mV4aNOz tYWl6hSt78IOW9OQdJ+RYYMUB2Iyz/h2UDjfTKu1HQ== X-Google-Smtp-Source: AKy350Z4McA3+Qi9zINJcX2RSj4jT1h+g0Qt40aMN1ir7rkl+7otHRRUChaog5+b3lTec4Lgw6qztA== X-Received: by 2002:a05:6830:10cd:b0:6a1:3d16:1c69 with SMTP id z13-20020a05683010cd00b006a13d161c69mr260149oto.22.1681156766466; Mon, 10 Apr 2023 12:59:26 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:55a1:d59a:609a:284:6ed]) by smtp.gmail.com with ESMTPSA id r7-20020a9d7507000000b006a30260ccfdsm4673293otk.11.2023.04.10.12.59.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 12:59:25 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v5 08/22] sparc: Fix Race conditions in pthread cancellation [BZ#12683] Date: Mon, 10 Apr 2023 16:58:53 -0300 Message-Id: <20230410195907.4123869-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230410195907.4123869-1-adhemerval.zanella@linaro.org> References: <20230410195907.4123869-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 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 on sparc64-linux-gnu and sparcv9-linux-gnu. --- .../sysv/linux/sparc/sparc32/syscall_cancel.S | 71 ++++++++++++++++++ .../sysv/linux/sparc/sparc64/syscall_cancel.S | 74 +++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S new file mode 100644 index 0000000000..aa5c658ce1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S @@ -0,0 +1,71 @@ +/* Cancellable syscall wrapper. Linux/sparc32 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, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + save %sp, -96, %sp + + cfi_window_save + cfi_register (%o7, %i7) + cfi_def_cfa_register (%fp) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ld [%i0], %g2 + andcc %g2, TCB_CANCELED_BITMASK, %g0 + bne,pn %icc, 2f + /* Issue a 6 argument syscall. */ + mov %i1, %g1 + mov %i2, %o0 + mov %i3, %o1 + mov %i4, %o2 + mov %i5, %o3 + ld [%fp+92], %o4 + ld [%fp+96], %o5 + ta 0x10 + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + bcc 1f + nop + sub %g0, %o0, %o0 +1: + mov %o0, %i0 + return %i7+8 + nop + +2: + call __syscall_do_cancel, 0 + nop + nop + +END (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S new file mode 100644 index 0000000000..21b0728d5a --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S @@ -0,0 +1,74 @@ +/* Cancellable syscall wrapper. Linux/sparc64 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 + + .register %g2, #scratch + +/* long int __syscall_cancel_arch (int *cancelhandling, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + save %sp, -176, %sp + + cfi_window_save + cfi_register (%o7, %i7) + cfi_def_cfa_register (%fp) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + lduw [%i0], %g2 + andcc %g2, TCB_CANCELED_BITMASK, %g0 + bne,pn %xcc, 2f + /* Issue a 6 argument syscall. */ + mov %i1, %g1 + mov %i2, %o0 + mov %i3, %o1 + mov %i4, %o2 + mov %i5, %o3 + ldx [%fp + STACK_BIAS + 176], %o4 + ldx [%fp + STACK_BIAS + 184], %o5 + ta 0x6d + + .global __syscall_cancel_arch_end +__syscall_cancel_arch_end: + + bcc,pt %xcc, 1f + nop + sub %g0, %o0, %o0 +1: + mov %o0, %i0 + return %i7+8 + nop + +2: + call __syscall_do_cancel, 0 + nop + nop + +END (__syscall_cancel_arch) -- 2.34.1