From patchwork Tue Oct 30 18:59:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fredrik Noring X-Patchwork-Id: 991028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-96853-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nocrew.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="jR9tMX63"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42l14H4V0qz9s8r for ; Wed, 31 Oct 2018 05:59:59 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=Yh7iTJ2YhHgdhchw 88J75uAxRPvzNFNiUPPdv7X5GWrUR+lXwIX1HIFB5wHYkuGbzTH8iyLaLfZx1WhH lTqI9aWgjhXDXRSfEHmSxEzqN10EfTPdIfcSh5Io+kydlzuOCfb4TeiAD+/LPm1F ylgtLn7O97LnCbo9MyEyJQDUNNk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=ookfJ92t6zfn/I7ISGuoV2 HcBQs=; b=jR9tMX63Pgq3vR/xHttojBemr83BQQux/7xEnytPYreOVcZ4Mlbj8M B/VKJoersv84lCfmbNAEk4/8o+tPtTlb35Kjxyuhn8oCZrLaAWdxMK0mm6pmI5fH re9SWjQPHHYkPQlZ4LwTnDwz007tv1dXicT2SulvnILFEQqZZSR0o= Received: (qmail 61228 invoked by alias); 30 Oct 2018 18:59:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 60367 invoked by uid 89); 30 Oct 2018 18:59:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Hx-languages-length:1691, designation, Hx-spam-relays-external:ESMTPA X-HELO: pio-pvt-msa1.bahnhof.se Date: Tue, 30 Oct 2018 19:59:48 +0100 From: Fredrik Noring To: "Maciej W. Rozycki" , Joseph Myers , libc-alpha@sourceware.org Cc: =?utf-8?q?J=C3=BCrgen?= Urban Subject: [PATCH v2] MIPS: Use `.set mips2' to emulate LL/SC for the R5900 too Message-ID: <3fb8c58bc662b93e68a992adfb099ad233b40ea2.1540925714.git.noring@nocrew.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) GAS treats the R5900 as MIPS III, with some modifications. The MIPS III designation means that the GNU C Library will try to assemble the LL and SC instructions, even though they are not implemented in the R5900. GAS will therefore produce the following errors: Error: opcode not supported on this processor: r5900 (mips3) `ll $2,0($4)' Error: opcode not supported on this processor: r5900 (mips3) `sc $6,0($4)' The MIPS II ISA override as used here enables the kernel to trap and emulate the LL and SC instructions, as required. This change has been tested by compiling the GNU C Library 2.27 with a GCC 8.2.0 cross-compiler for mipsr5900el-unknown-linux-gnu under Gentoo. Reviewed-by: Maciej W. Rozycki --- Thank you very much for your reviews, Maciej and Joseph, It turns out that `.set arch=mips' isn't needed, so the patch can be simplified. Please find the updated v2 patch here. Changes in v2: - Discard `set arch=mips2' since this isn't needed - Add space before `(' as per GNU style - Amend note explaining R5900 exception --- sysdeps/mips/sys/tas.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysdeps/mips/sys/tas.h b/sysdeps/mips/sys/tas.h index d5ed013e28..22cee94f7a 100644 --- a/sysdeps/mips/sys/tas.h +++ b/sysdeps/mips/sys/tas.h @@ -38,10 +38,11 @@ __NTH (_test_and_set (int *__p, int __v)) { int __r, __t; + /* The R5900 reports itself as MIPS III but it does not have LL/SC. */ __asm__ __volatile__ ("/* Inline test and set */\n" ".set push\n\t" -#if _MIPS_SIM == _ABIO32 && __mips < 2 +#if _MIPS_SIM == _ABIO32 && (__mips < 2 || defined (_MIPS_ARCH_R5900)) ".set mips2\n\t" #endif "sync\n\t"