From patchwork Mon Apr 10 20:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 67591 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 518043834684 for ; Mon, 10 Apr 2023 20:48:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 518043834684 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681159707; bh=AsTeusHYh3gPGXyOTH+U5eHT2trnNdZH7CplkDr7av0=; 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=ZawPPCJulG/d2q2MzZsFv0d9n/6N5GzbeItUasmLCu0rMoFr3IqEgErrQ3k8lcRFF GDs+5j0ouJF4lzu335Swv2hlc1R5VWvFeehbv5GDvs53JZISaTtE/xBzoGq1JswWTC OonyZ7O/p0HnXNWU9OOXlImWpkQ4XlViYkKlKaHI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 4ED56385773A for ; Mon, 10 Apr 2023 20:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4ED56385773A Received: by mail-oi1-x233.google.com with SMTP id bf5so4073583oib.8 for ; Mon, 10 Apr 2023 13:46:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681159603; x=1683751603; 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=AsTeusHYh3gPGXyOTH+U5eHT2trnNdZH7CplkDr7av0=; b=CQwtB0V9y+VEr50Fk9YnDi75OH7ig3Oeeikc4eIh29x2IqrWm3IYQP1TQ/g5WsO3ZG yD+r7HZYW56ul0ZudQq2aAEpZA+QyNULlhL26GV7rh84b8t+oiCNCW/f4jmzWljbODBP mu3+9bVGpbn9nkU2jMVAzbvgNcrmos1mAI+5doLQRzvFuKihqWIrvDd155R5tqSyOoGZ Pv9jDQeNRMMk8K9XYWrlPhfBR5GBFkvgVhExlDKcVGfR1nC6YNEy/L9WGGG8bSo9cNSk 4notfM4TYg1f7NsB4pMPOiaqncADSg0U+jqWHpireCxqQl/T4057tyqui/GUmSLBQoYV edPg== X-Gm-Message-State: AAQBX9dT2Ou7C1F109I2iIayk277r7tUziEjbjcpgaaXHc2Y/P7ucYxw mt0mJy1LJ+xBqhTZN1KRmsLiej7TV76JphkVKdQizQ== X-Google-Smtp-Source: AKy350auYyenYzU/tgJOQ6NrU8ZLnyKJCrsJXAKmpUYou4pS2FfVILWHiFcbpq8iNwU54pwf76LIbQ== X-Received: by 2002:a05:6808:4244:b0:384:1793:90cf with SMTP id dp4-20020a056808424400b00384179390cfmr3817056oib.0.1681159603332; Mon, 10 Apr 2023 13:46:43 -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.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 13:46:42 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 22/22] loongarch: Fix Race conditions in pthread cancellation [BZ#12683] Date: Mon, 10 Apr 2023 17:46:14 -0300 Message-Id: <20230410204614.4129551-14-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.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 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 against a build and make check run-built-tests=no for loongarch64-linux-gnu-lp64d. --- .../sysv/linux/loongarch/syscall_cancel.S | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S diff --git a/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S b/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S new file mode 100644 index 0000000000..574252fec1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/loongarch/syscall_cancel.S @@ -0,0 +1,54 @@ +/* Cancellable syscall wrapper. Linux/loongarch 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 + +ENTRY (__syscall_cancel_arch) + + .global __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + ldptr.w $r12,$r4,0 + andi $r12,$r12,TCB_CANCELED_BITMASK + bnez $r12,1f + + /* Issue a 6 argument syscall. */ + or $r13,$r5,$r0 + or $r4,$r6,$r0 + or $r5,$r7,$r0 + or $r6,$r8,$r0 + or $r7,$r9,$r0 + or $r8,$r10,$r0 + or $r9,$r11,$r0 + or $r11,$r13,$r0 + syscall 0 + + .global __syscall_cancel_arch_end +__syscall_cancel_arch_end: + jr $r1 +1: + addi.d $r3,$r3,-16 + cfi_def_cfa_offset (16) + st.d $r1,$r3,8 + cfi_offset (1, -8) + bl __syscall_do_cancel + +END (__syscall_cancel_arch)