From patchwork Mon Apr 10 19:58:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 67575 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B24523856DE0 for ; Mon, 10 Apr 2023 20:00:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B24523856DE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681156806; bh=4c1Cdq3y3Z3nLFCWo1PuNDPNGFCLuoukjw+2JSxH5Dc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JJ1bZNo2IyeMbxRlLotO2jd9MHxlsAGV6LDXy6NbId+y7EKGazdJMm2hN1+nns7cz VsjSvyZophI8rI+xVK4ZqloGH/dCcIPvOGCNIegWpCR6UbycIOZl/ob6lXVTff/igf qFm/L8H76gFNtSgIZmkUrPopfUWoYPrf6AhK749E= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by sourceware.org (Postfix) with ESMTPS id 31B2A385772F for ; Mon, 10 Apr 2023 19:59:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31B2A385772F Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1842cddca49so7410740fac.1 for ; Mon, 10 Apr 2023 12:59:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681156763; x=1683748763; 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=4c1Cdq3y3Z3nLFCWo1PuNDPNGFCLuoukjw+2JSxH5Dc=; b=VbtDJgXf2zH5/xots6B3Q0Bn+yTKxHZGU0EbcNmAcLn9Y++cDJyRU8RBj9odk5jDjE mqIZCcEPCC78LuK5MHOw7VNGSxTowZHucAy9OcnfZby7LkCl98vuTUwqWmbs0Ut0bKi/ vXvy1enOfq3e62uMCUBBAadPHnmze8mNPF3f6NAFjM9qf7HzVfvo7wVNlvSy4USFgYil hBPl36fkdaisMBSsPRK7UuTg3RIiZ4vlYbb33uCpPfRNPxCpdVFaB9FnHQWxESObZt++ yRAyhD3HcjHuYv7kUQksLw7vFIFjk+1/Uk3mA2n+k7AhOa7SqVfm21kGTLS6j3EWTrBd MsBA== X-Gm-Message-State: AAQBX9cUmw9VHr8iHSe92WJPCf2Cg/+VLysk9z3nUXVT91qHYBt02KId Nq+Uxfy8qa77DWSgqhvGAMhgvl9DLdA2L3/h17EdQA== X-Google-Smtp-Source: AKy350b+uZTbM8DSjd1GTH65g7zxWzhEstFlwr+NkwHwIJC9POCZmwj6qBk0bo9DGi69olTxEeFfuw== X-Received: by 2002:a05:6870:241b:b0:177:88c7:eff7 with SMTP id n27-20020a056870241b00b0017788c7eff7mr6637651oap.48.1681156762488; Mon, 10 Apr 2023 12:59:22 -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.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 12:59:21 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 06/22] arm: Fix Race conditions in pthread cancellation [BZ#12683] Date: Mon, 10 Apr 2023 16:58:51 -0300 Message-Id: <20230410195907.4123869-7-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 X-Spam-Status: No, score=-12.6 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 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" By adding the required syscall_cancel.S. Checked on arm-linux-gnueabihf. --- sysdeps/unix/sysv/linux/arm/syscall_cancel.S | 78 ++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/arm/syscall_cancel.S diff --git a/sysdeps/unix/sysv/linux/arm/syscall_cancel.S b/sysdeps/unix/sysv/linux/arm/syscall_cancel.S new file mode 100644 index 0000000000..6b899306e3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/syscall_cancel.S @@ -0,0 +1,78 @@ +/* Cancellable syscall wrapper. Linux/arm 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 [r0] __syscall_cancel_arch (int *cancelhandling [r0], + long int nr [r1], + long int arg1 [r2], + long int arg2 [r3], + long int arg3 [SP], + long int arg4 [SP+4], + long int arg5 [SP+8], + long int arg6 [SP+12]) */ + + .syntax unified + +ENTRY (__syscall_cancel_arch) + .fnstart + mov ip, sp + stmfd sp!, {r4, r5, r6, r7, lr} + .save {r4, r5, r6, r7, lr} + + cfi_adjust_cfa_offset (20) + cfi_rel_offset (r4, 0) + cfi_rel_offset (r5, 4) + cfi_rel_offset (r6, 8) + cfi_rel_offset (r7, 12) + cfi_rel_offset (lr, 16) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ldr r0, [r0] + tst r0, #TCB_CANCELED_BITMASK + bne 1f + + /* Issue a 6 argument syscall, the nr [r1] being the syscall + number. */ + mov r7, r1 + mov r0, r2 + mov r1, r3 + ldmfd ip, {r2, r3, r4, r5, r6} + svc 0x0 + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + ldmfd sp!, {r4, r5, r6, r7, lr} + cfi_adjust_cfa_offset (-20) + cfi_restore (r4) + cfi_restore (r5) + cfi_restore (r6) + cfi_restore (r7) + cfi_restore (lr) + BX (lr) + +1: + ldmfd sp!, {r4, r5, r6, r7, lr} + b __syscall_do_cancel + .fnend +END (__syscall_cancel_arch)