From patchwork Fri Apr 3 20:31:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 38736 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by sourceware.org (Postfix) with ESMTPS id 4276D388B805 for ; Fri, 3 Apr 2020 20:32:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4276D388B805 Received: by mail-qk1-x732.google.com with SMTP id u4so9472387qkj.13 for ; Fri, 03 Apr 2020 13:32:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ztSQfytMOk8OXXtNqZVY9UIbLAE+i1P6qr2Eq531+RU=; b=Rc5fnUHvyLfsVoxmuO6RpdUIOySf3nvszGt9xQNhFE79MUcmSRmgbkJyVoD53HeeZS x1QIzuiQYfztTsKaRlaqo3hf533DS7nmcrw4tqKWc0D7xMUfZ78QqXDFWmJpVQtMg27y ZxvfFoj1Wlu/O9h80chxLv+xfRNIcDS0XvEbuTXT+YMiv6Rc8nHiHKVF0EMfYnO2DIIF WqxdHRUgVW4s+4PpG/fpHTIH6W5yefdiRdxoje1/kt2JtZU23o5E2WqsCRbDzV7LQyr+ Jn8JS7dfA0Paf9pFgx+VN44FYNLgwFQX0cVrjrIyafkuRI2upL+bFYNbsk/rfd0Mylc5 yhsA== X-Gm-Message-State: AGi0PubnHtB04XvtRU3FkVRzEZB9FWdrLoOuj4BTmC6Fdukkb3mzcLgI dToALzMo8GF6uRYrEGquAntCqh3mlMM= X-Google-Smtp-Source: APiQypLtIb0LXPHc6boPLUzLjllUk25DBAlB+85rQBoF9jmkCahBwDqPg4/r+etKDMFszs3Szr9+JQ== X-Received: by 2002:a37:27c1:: with SMTP id n184mr6901777qkn.67.1585945944599; Fri, 03 Apr 2020 13:32:24 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id d141sm7063535qke.68.2020.04.03.13.32.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:32:24 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v4 11/21] nptl: microblaze: Fix Race conditions in pthread cancellation [BZ#12683] Date: Fri, 3 Apr 2020 17:31:51 -0300 Message-Id: <20200403203201.7494-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403203201.7494-1-adhemerval.zanella@linaro.org> References: <20200403203201.7494-1-adhemerval.zanella@linaro.org> X-Spam-Status: No, score=-26.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Fri, 03 Apr 2020 20:32:26 -0000 This patch adds the microblaze modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked against a build and make check run-built-tests=no for microblaze-linux-gnu. --- sysdeps/microblaze/nptl/tcb-offsets.sym | 3 + .../sysv/linux/microblaze/syscall_cancel.S | 61 +++++++++++++++++++ sysdeps/unix/sysv/linux/microblaze/sysdep.h | 1 + 3 files changed, 65 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S diff --git a/sysdeps/microblaze/nptl/tcb-offsets.sym b/sysdeps/microblaze/nptl/tcb-offsets.sym index 614f0dfed6..bb39e23d57 100644 --- a/sysdeps/microblaze/nptl/tcb-offsets.sym +++ b/sysdeps/microblaze/nptl/tcb-offsets.sym @@ -8,3 +8,6 @@ MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads) TID_OFFSET thread_offsetof (tid) + +-- Not strictly offsets, used on syscall_cancel.S +TCB_CANCELED_BITMASK CANCELED_BITMASK diff --git a/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S b/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S new file mode 100644 index 0000000000..74d22f3560 --- /dev/null +++ b/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S @@ -0,0 +1,61 @@ +/* Cancellable syscall wrapper. Linux/microblaze version. + Copyright (C) 2020 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 + +/* 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) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + lwi r3,r5,0 + andi r3,r3,TCB_CANCELED_BITMASK + bneid r3,1f + addk r12,r6,r0 + + addk r5,r7,r0 + addk r6,r8,r0 + addk r7,r9,r0 + addk r8,r10,r0 + lwi r9,r1,56 + lwi r10,r1,60 + brki r14,8 + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + + nop + lwi r15,r1,0 + rtsd r15,8 + addik r1,r1,28 + +1: + brlid r15, __syscall_do_cancel + nop + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h index d500172114..7d96cdf6ac 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h @@ -22,6 +22,7 @@ #include #include #include +#include /* Defines RTLD_PRIVATE_ERRNO. */ #include