From patchwork Sun Feb 2 17:00:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 11362027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F06D17E0 for ; Mon, 3 Feb 2020 03:46:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7B252073C for ; Mon, 3 Feb 2020 03:46:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b="n7F7JRbL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbgBCDqf (ORCPT ); Sun, 2 Feb 2020 22:46:35 -0500 Received: from [115.28.160.31] ([115.28.160.31]:36210 "EHLO mailbox.box.xen0n.name" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727088AbgBCDqf (ORCPT ); Sun, 2 Feb 2020 22:46:35 -0500 Received: from localhost.localdomain (unknown [116.236.177.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id C94B4600BF; Mon, 3 Feb 2020 11:46:24 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=xen0n.name; s=mail; t=1580701584; bh=i5XqcqvpXOcVDcAQ/cfvGjewDL60E9oWwr5PaBOEwNA=; h=From:To:Cc:Subject:Date:From; b=n7F7JRbL0SeKWbbvMlj9FGRfCk9Q+Aja+pMmwSTwPBAHBdnv+HgIsETwK84/mFRqv G7rRYDU9lavb/sVEIbggi3sZ4rGFVCr28a4atZFTZg110LmN+FZWQoYF/LCGClhYDp 20j7/jTVR985KRF6Vi69pJ3IQ2pHj6/M7duQkPs0= From: Wang Xuerui To: linux-mips@vger.kernel.org Cc: Huacai Chen , Wang Xuerui Subject: [PATCH 1/2] MIPS: loongson3-llsc-check: Downgrade failures to notices Date: Mon, 3 Feb 2020 01:00:51 +0800 Message-Id: <20200202170052.14012-1-git@xen0n.name> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Huacai Chen Local ops (and other similar cases) don't need SYNCs before LL/SC because there is only one writer, so don't always fail on missing SYNCs. Print a notice instead. [git@xen0n.name: Massaged commit message and symbol naming.] Signed-off-by: Huacai Chen Signed-off-by: Wang Xuerui --- arch/mips/tools/loongson3-llsc-check.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/mips/tools/loongson3-llsc-check.c b/arch/mips/tools/loongson3-llsc-check.c index 0ebddd0ae46f..c485950b7a36 100644 --- a/arch/mips/tools/loongson3-llsc-check.c +++ b/arch/mips/tools/loongson3-llsc-check.c @@ -138,6 +138,12 @@ static bool is_branch(uint32_t insn, int *off) } } +#define REPORT_OK 0x0 +#define REPORT_LL 0x1 +#define REPORT_BRANCH_TARGET 0x2 + +static int err_report = REPORT_OK; + static int check_ll(uint64_t pc, uint32_t *code, size_t sz) { ssize_t i, max, sc_pos; @@ -149,8 +155,8 @@ static int check_ll(uint64_t pc, uint32_t *code, size_t sz) * execute after the LL & cause erroneous results. */ if (!is_sync(le32toh(code[-1]))) { + err_report |= REPORT_LL; fprintf(stderr, "%" PRIx64 ": LL not preceded by sync\n", pc); - return -EINVAL; } /* Find the matching SC instruction */ @@ -185,9 +191,9 @@ static int check_ll(uint64_t pc, uint32_t *code, size_t sz) continue; /* ...but if not, we have a problem */ + err_report |= REPORT_BRANCH_TARGET; fprintf(stderr, "%" PRIx64 ": Branch target not a sync\n", pc + (i * 4)); - return -EINVAL; } return 0; @@ -297,6 +303,13 @@ int main(int argc, char *argv[]) goto out_munmap; } + if (err_report & REPORT_LL) + fprintf(stderr, "Notice: there are LLs not preceded by" + " syncs, please confirm manually.\n"); + if (err_report & REPORT_BRANCH_TARGET) + fprintf(stderr, "Notice: there are branches within LL/SC blocks" + " not targeting syncs, please confirm manually.\n"); + status = EXIT_SUCCESS; out_munmap: munmap(vmlinux, st.st_size); From patchwork Sun Feb 2 17:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 11362025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E994B1398 for ; Mon, 3 Feb 2020 03:46:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C90C207E0 for ; Mon, 3 Feb 2020 03:46:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen0n.name header.i=@xen0n.name header.b="azZJcnvw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbgBCDqc (ORCPT ); Sun, 2 Feb 2020 22:46:32 -0500 Received: from [115.28.160.31] ([115.28.160.31]:36214 "EHLO mailbox.box.xen0n.name" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727347AbgBCDqc (ORCPT ); Sun, 2 Feb 2020 22:46:32 -0500 Received: from localhost.localdomain (unknown [116.236.177.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 8E4886014B; Mon, 3 Feb 2020 11:46:29 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=xen0n.name; s=mail; t=1580701589; bh=CNzU9EEK2oqmzPj5vVHJIha/6hi4mr07hmSczWyOnEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=azZJcnvw9arMXJGZlvoTpPGBnREneiFl3xdcj47iZnBKdKS525rmhw6uCUbWLYg7e 6htASAyRGvXLE3JnDJ7KuKhRpjLn5AUp8m9JSQe74GdDgi3oFuIKC71petVbUuvAco Cq1S8HFEacGoXzl2afoOpRjMbzJTybqFhrP5mldc= From: Wang Xuerui To: linux-mips@vger.kernel.org Cc: Huacai Chen , Wang Xuerui Subject: [PATCH 2/2] Revert "MIPS: asm: local: add barriers for Loongson" Date: Mon, 3 Feb 2020 01:00:52 +0800 Message-Id: <20200202170052.14012-2-git@xen0n.name> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200202170052.14012-1-git@xen0n.name> References: <20200202170052.14012-1-git@xen0n.name> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Huacai Chen This reverts commit 3e86460ebe2340df6a33b35a55312cc369bdcbd0. Local ops don't need SYNCs before LL because there is only one writer, the erratum is not triggered. The LLSCCHK violations are made not to fail the build in the previous patch so just revert the additions. [git@xen0n.name: Massaged commit message.] Signed-off-by: Huacai Chen Signed-off-by: Wang Xuerui --- arch/mips/include/asm/local.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h index fef0fda8f82f..02783e141c32 100644 --- a/arch/mips/include/asm/local.h +++ b/arch/mips/include/asm/local.h @@ -37,7 +37,6 @@ static __inline__ long local_add_return(long i, local_t * l) __asm__ __volatile__( " .set push \n" " .set arch=r4000 \n" - __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_add_return \n" " addu %0, %1, %3 \n" __SC "%0, %2 \n" @@ -53,7 +52,6 @@ static __inline__ long local_add_return(long i, local_t * l) __asm__ __volatile__( " .set push \n" " .set "MIPS_ISA_ARCH_LEVEL" \n" - __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_add_return \n" " addu %0, %1, %3 \n" __SC "%0, %2 \n" @@ -86,7 +84,6 @@ static __inline__ long local_sub_return(long i, local_t * l) __asm__ __volatile__( " .set push \n" " .set arch=r4000 \n" - __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_sub_return \n" " subu %0, %1, %3 \n" __SC "%0, %2 \n" @@ -102,7 +99,6 @@ static __inline__ long local_sub_return(long i, local_t * l) __asm__ __volatile__( " .set push \n" " .set "MIPS_ISA_ARCH_LEVEL" \n" - __SYNC(full, loongson3_war) " \n" "1:" __LL "%1, %2 # local_sub_return \n" " subu %0, %1, %3 \n" __SC "%0, %2 \n"