From patchwork Mon Apr 10 20:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 67582 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 6F7D93856947 for ; Mon, 10 Apr 2023 20:46:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F7D93856947 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681159610; bh=G2KtuY6ABrOdTmyYx3FKChSr/BBKWFQ+inuuVnqWZMQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=e6gFPcprZH/Bpjz1pPUsUMFe6ADuEWNoFnceT/X/gHrJxcxtT6lImVjHyHnetIJSk PJt3WleQEELWPcjnJ9fxhMe/ht80tXELJVJy8EWXxY/0a4Nl/hmokGWhu5PAFIIwBv 8TxfB3cCC7IUUjXh0T7A2MMBWS7eRdf8pWvKfdWM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id C10803858C5E for ; Mon, 10 Apr 2023 20:46:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C10803858C5E Received: by mail-oi1-x22f.google.com with SMTP id f14so22454778oiw.10 for ; Mon, 10 Apr 2023 13:46:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681159583; x=1683751583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G2KtuY6ABrOdTmyYx3FKChSr/BBKWFQ+inuuVnqWZMQ=; b=GdXH6uf3ZN564z/2UxAmyUxhHAbGf892n2tF81fdvOzyLO99TeBSjHKFHjsd+OMP5V WWyR3oWfV9ZHML1hTlLJa56dQ/Zpo5ZrQbXVKNZUPhj0nDGIdOQiLaYim2ds88Zqenh4 b4kPfSfJNJ4X/kIdAc0Hff3wEjdly5mR0ufwDJUN5LQVCTVeGskRKFjiD12wWwi0vLpC Ln1zjBBfhAecjo4DlrN5p3Fe+T7VWaB1kBZBu24cCO5nrK8e2/9r0/RXf4RQAmjInact QK35HzwgLxJjJLwZ7j878dN6Ug+aKbEUe1r3nBJWFcrPjUllpF8QZTNchqqSv9EUI6YF rY6w== X-Gm-Message-State: AAQBX9dGFuxL0/ifMDs7YSYHLyJnH7e4N7kuMrtvZ4ETyPWZaXkyGlw+ EyULaxcJkv2NbEuS6RXmTDuOel40sxMPNZyvH1mcxg== X-Google-Smtp-Source: AKy350Y+4fTrQ3jNn/X2Zcz89v2Cuy9m2YigzniYGtL9erhaszruwGzZZg9FGuGlO4nzxw8mv30DZg== X-Received: by 2002:a05:6808:919:b0:388:f18a:37db with SMTP id w25-20020a056808091900b00388f18a37dbmr5661579oih.0.1681159582067; Mon, 10 Apr 2023 13:46:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 13:46:21 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Andrew Waterman Subject: [PATCH v5 10/22] riscv: Fix Race conditions in pthread cancellation [BZ#12683] Date: Mon, 10 Apr 2023 17:46:02 -0300 Message-Id: <20230410204614.4129551-2-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 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 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 Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" By adding the required syscall_cancel.S. Reviewed-by: Andrew Waterman --- .../unix/sysv/linux/riscv/syscall_cancel.S | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_cancel.S diff --git a/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S b/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S new file mode 100644 index 0000000000..742c748d09 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S @@ -0,0 +1,67 @@ +/* Cancellable syscall wrapper. Linux/riscv 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) */ + +#ifdef SHARED + .option pic +#else + .option nopic +#endif + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + lw t1, 0(a0) + /* if (*ch & CANCELED_BITMASK) */ + andi t1, t1, TCB_CANCELED_BITMASK + bne t1, zero, 1f + + mv t3, a1 + mv a0, a2 + mv a1, a3 + mv a2, a4 + mv a3, a5 + mv a4, a6 + mv a5, a7 + mv a7, t3 + scall + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + ret + +1: + addi sp, sp, -16 + cfi_def_cfa_offset (16) + REG_S ra, (16-SZREG)(sp) + cfi_offset (ra, -SZREG) + call __syscall_do_cancel + +END (__syscall_cancel_arch)