From patchwork Mon Aug 12 03:31:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11089263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B39314DB for ; Mon, 12 Aug 2019 03:31:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D53127DCD for ; Mon, 12 Aug 2019 03:31:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10F8D27F86; Mon, 12 Aug 2019 03:31:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FD1027DCD for ; Mon, 12 Aug 2019 03:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726573AbfHLDbf (ORCPT ); Sun, 11 Aug 2019 23:31:35 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39533 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbfHLDbe (ORCPT ); Sun, 11 Aug 2019 23:31:34 -0400 Received: by mail-wr1-f65.google.com with SMTP id t16so13199976wra.6; Sun, 11 Aug 2019 20:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vWEzzku9YP0pC2dVc45a5odEYQH6f9+aCPyBPp3kmxo=; b=SE46LZAyzH6U02vpi2RK3qP0aLUW1s+/BySNKx1Vx4S8RXZICkMsI/eJv+OqXAwPP3 zvcL+q8quy9DClR6kQeC2lScNnSM+ejjox7aOtH5YfkUQwBYBgn/2tfaqVFaY5PaboST lkmwAEWyFKNvfXTrltJpGO+rWBYvxYpWbEhUVcR0Y8ftxIA+BwLfv2xdTsS1ywqc8Nwq DjDFHd0hqOILYBuv+Hdku+V8EeM67hr3aueaUlu9dmvJXUjVs75WpAeguDfsiSjI9PNp Y8QYv175125TSd/rQ63ui22KWJSxRI+34UAgeSBdM1PVSGCTDQZBjm8Vy6trqLCHRipJ mEDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vWEzzku9YP0pC2dVc45a5odEYQH6f9+aCPyBPp3kmxo=; b=KdMnbGsrAuHssIOgZBC79FZbMuA5XtI3xzqd2kmCt9wxaHlrpzceS5dto4b+TSOfcn ZDDwbYcqBCflYaerKpwJetTS16J8q1uCi+ai6A1B3uEVTrVqs/blxfagjuVU/f7hacHB PSQMB1FGANv7YmY/kb4bCAwiEx+dPAPWgzrpMPT/u2LquIbhB5LWPl2OFSW3N67+FR9T mvUuRi/WUokUaV3VQbMMRbrVFL4ChlMd+o7Cyi9XePa2p527rJzc0fgEldlA42ZOP3v5 zODYvLPr1SYrAtv8uRCLrI3Oex6NvHsVoFy5G3lAqYSsJ7GUM6ZXEBDMIYo5U/JUxzzW Y/2A== X-Gm-Message-State: APjAAAUo3qYi/zEVIIzkGL5viLdHWD3FJkQlLPuAvlMY8Kg86RcKAtkk x5Efcqhw8NuHyfk+IXMxisQ= X-Google-Smtp-Source: APXvYqxmGrFmRa688YKY6KKrrvbIKQnMYH/dlZ8HtOC/RsQAE59TS2Ihfg/5QMeiJhniZfHANkVALg== X-Received: by 2002:adf:f04d:: with SMTP id t13mr37798273wro.133.1565580691538; Sun, 11 Aug 2019 20:31:31 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id f12sm117299330wrg.5.2019.08.11.20.31.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 20:31:31 -0700 (PDT) From: Nathan Chancellor To: Ralf Baechle , Paul Burton , James Hogan Cc: Nick Desaulniers , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 1/5] MIPS: Don't use bc_false uninitialized in __mm_isBranchInstr Date: Sun, 11 Aug 2019 20:31:16 -0700 Message-Id: <20190812033120.43013-2-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0.rc2 In-Reply-To: <20190812033120.43013-1-natechancellor@gmail.com> References: <20190812033120.43013-1-natechancellor@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clang warns: arch/mips/kernel/branch.c:148:8: error: variable 'bc_false' is used uninitialized whenever switch case is taken [-Werror,-Wsometimes-uninitialized] case mm_bc2t_op: ^~~~~~~~~~ arch/mips/kernel/branch.c:157:8: note: uninitialized use occurs here if (bc_false) ^~~~~~~~ arch/mips/kernel/branch.c:149:8: error: variable 'bc_false' is used uninitialized whenever switch case is taken [-Werror,-Wsometimes-uninitialized] case mm_bc1t_op: ^~~~~~~~~~ arch/mips/kernel/branch.c:157:8: note: uninitialized use occurs here if (bc_false) ^~~~~~~~ arch/mips/kernel/branch.c:142:4: note: variable 'bc_false' is declared here int bc_false = 0; ^ 2 errors generated. When mm_bc1t_op and mm_bc2t_op are taken, the bc_false initialization does not happen, which leads to a garbage value upon use, as illustrated below with a small sample program. $ mipsel-linux-gnu-gcc --version | head -n1 mipsel-linux-gnu-gcc (Debian 8.3.0-2) 8.3.0 $ clang --version | head -n1 ClangBuiltLinux clang version 9.0.0 (git://github.com/llvm/llvm-project 544315b4197034a3be8acd12cba56a75fb1f08dc) (based on LLVM 9.0.0svn) $ cat test.c #include static void switch_scoped(int opcode) { switch (opcode) { case 1: case 2: { int bc_false = 0; bc_false = 4; case 3: case 4: printf("\t* switch scoped bc_false = %d\n", bc_false); } } } static void function_scoped(int opcode) { int bc_false = 0; switch (opcode) { case 1: case 2: { bc_false = 4; case 3: case 4: printf("\t* function scoped bc_false = %d\n", bc_false); } } } int main(void) { int opcode; for (opcode = 1; opcode < 5; opcode++) { printf("opcode = %d:\n", opcode); switch_scoped(opcode); function_scoped(opcode); printf("\n"); } return 0; } $ mipsel-linux-gnu-gcc -std=gnu89 -static test.c && \ qemu-mipsel a.out opcode = 1: * switch scoped bc_false = 4 * function scoped bc_false = 4 opcode = 2: * switch scoped bc_false = 4 * function scoped bc_false = 4 opcode = 3: * switch scoped bc_false = 2147483004 * function scoped bc_false = 0 opcode = 4: * switch scoped bc_false = 2147483004 * function scoped bc_false = 0 $ clang -std=gnu89 --target=mipsel-linux-gnu -m32 -static test.c && \ qemu-mipsel a.out opcode = 1: * switch scoped bc_false = 4 * function scoped bc_false = 4 opcode = 2: * switch scoped bc_false = 4 * function scoped bc_false = 4 opcode = 3: * switch scoped bc_false = 2147483004 * function scoped bc_false = 0 opcode = 4: * switch scoped bc_false = 2147483004 * function scoped bc_false = 0 Move the definition up so that we get the right behavior and mark it __maybe_unused as it will not be used when CONFIG_MIPS_FP_SUPPORT isn't enabled. Fixes: 6a1cc218b9cc ("MIPS: branch: Remove FP branch handling when CONFIG_MIPS_FP_SUPPORT=n") Link: https://github.com/ClangBuiltLinux/linux/issues/603 Signed-off-by: Nathan Chancellor --- arch/mips/kernel/branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c index 1db29957a931..2c38f75d87ff 100644 --- a/arch/mips/kernel/branch.c +++ b/arch/mips/kernel/branch.c @@ -58,6 +58,7 @@ int __mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, unsigned long *contpc) { union mips_instruction insn = (union mips_instruction)dec_insn.insn; + int __maybe_unused bc_false = 0; if (!cpu_has_mmips) return 0; @@ -139,7 +140,6 @@ int __mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, #ifdef CONFIG_MIPS_FP_SUPPORT case mm_bc2f_op: case mm_bc1f_op: { - int bc_false = 0; unsigned int fcr31; unsigned int bit; From patchwork Mon Aug 12 03:31:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11089271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 740F514DB for ; Mon, 12 Aug 2019 03:31:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63DDF27DCD for ; Mon, 12 Aug 2019 03:31:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5787327F86; Mon, 12 Aug 2019 03:31:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72A2627DCD for ; Mon, 12 Aug 2019 03:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbfHLDbf (ORCPT ); Sun, 11 Aug 2019 23:31:35 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46925 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfHLDbf (ORCPT ); Sun, 11 Aug 2019 23:31:35 -0400 Received: by mail-wr1-f66.google.com with SMTP id z1so103319548wru.13; Sun, 11 Aug 2019 20:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CIiORaxsknShCfRL75nn07wOJCPKFADThWQpO+7rVHs=; b=REkzW2FUBdfwjt8SG6zkKNG2pEIOqqyOP2yzOlSdGozMLfLnoluynhn025S+HivChz U1+db6NzVUPDXrBAX823rdwC8tmmAdJIBp4wtCnwYKVgOJ1L8XkGye7yE57cNPnAihMy PWIzuL2KSWQXis50w/eUGuLZ354Nkb1ZuJYXjTpO+ucGx3XaWib83cNY7Y6ELEEH6pxb nvURelBgS9WXqo6xlJqAXywsuzkubg3o1YIGXYxjRH+NFwUy+W4VvGKSb6sAl+ChN53h RTDDXeNQck58h4F8Df30RvZOsNGeu2BI36jezR2x7Emt1XU4rdzJhCoVX+Gk6S4ckPFZ 3SaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CIiORaxsknShCfRL75nn07wOJCPKFADThWQpO+7rVHs=; b=fPK9N8eBCJ+Ql/+kIqs6uYrq4XHd5R4RpVOYsgCdLxoQi0EF/Ii1kBRWldufdOR6lY tbgEVMpbjmIe0OrvOCR6Gw1LXSLz4hgeVmzSKs9jrAy9i4TUj6qP7yrFF2d0Y0PJyXQn XjK6/mej9SJJD959eZVwmz0e794HO9YVVznOC3DOHQjsfCXdSiyvWbfcBo0Ko/ZCJhc6 fwj8BAG0hP9Vs3XjULVDaC9yZbljpf7rniGGmo7eb30JovOcEityCvaOxYRI59GbHeNB JbXozjJ6wXuTaUm05xW/tGTTkK/EqN7AzAnqkMLcSnlHsr0+oP43mFgw3989ombH6l1p a71g== X-Gm-Message-State: APjAAAWlHAu9IZm0SXhoyktzZzruVFV/Ep7tKl8eULCT43PYDdxjPXgn g/jCxg4ze60r/W82RD7MLS8= X-Google-Smtp-Source: APXvYqxtDSZUjQr/+MByGolBL7ow/DNNzEu+D63hZIlHg20khUaLSJzrBbSnipi0bAR2bu1xADrSpg== X-Received: by 2002:a5d:6ccd:: with SMTP id c13mr39563914wrc.4.1565580692982; Sun, 11 Aug 2019 20:31:32 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id f12sm117299330wrg.5.2019.08.11.20.31.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 20:31:32 -0700 (PDT) From: Nathan Chancellor To: Ralf Baechle , Paul Burton , James Hogan Cc: Nick Desaulniers , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 2/5] MIPS/ptrace: Update mips_get_syscall_arg's return type Date: Sun, 11 Aug 2019 20:31:17 -0700 Message-Id: <20190812033120.43013-3-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0.rc2 In-Reply-To: <20190812033120.43013-1-natechancellor@gmail.com> References: <20190812033120.43013-1-natechancellor@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clang warns: arch/mips/include/asm/syscall.h:136:3: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized] ret |= mips_get_syscall_arg(args++, task, regs, i++); ^~~ arch/mips/include/asm/syscall.h:129:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 0 1 error generated. It's not wrong; however, it's not an issue in practice because ret is only assigned to, not read from. ret could just be initialized to zero but looking into it further, ret has been unused since it was first added in 2012 so just get rid of it and update mips_get_syscall_arg's return type since none of the return values are ever checked. If it is ever needed again, this commit can be reverted and ret can be properly initialized. Fixes: c0ff3c53d4f9 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.") Link: https://github.com/ClangBuiltLinux/linux/issues/604 Signed-off-by: Nathan Chancellor --- arch/mips/include/asm/syscall.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h index 83bb439597d8..25fa651c937d 100644 --- a/arch/mips/include/asm/syscall.h +++ b/arch/mips/include/asm/syscall.h @@ -54,7 +54,7 @@ static inline void mips_syscall_update_nr(struct task_struct *task, task_thread_info(task)->syscall = regs->regs[2]; } -static inline unsigned long mips_get_syscall_arg(unsigned long *arg, +static inline void mips_get_syscall_arg(unsigned long *arg, struct task_struct *task, struct pt_regs *regs, unsigned int n) { unsigned long usp __maybe_unused = regs->regs[29]; @@ -63,23 +63,24 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg, case 0: case 1: case 2: case 3: *arg = regs->regs[4 + n]; - return 0; + return; #ifdef CONFIG_32BIT case 4: case 5: case 6: case 7: - return get_user(*arg, (int *)usp + n); + get_user(*arg, (int *)usp + n); + return; #endif #ifdef CONFIG_64BIT case 4: case 5: case 6: case 7: #ifdef CONFIG_MIPS32_O32 if (test_tsk_thread_flag(task, TIF_32BIT_REGS)) - return get_user(*arg, (int *)usp + n); + get_user(*arg, (int *)usp + n); else #endif *arg = regs->regs[4 + n]; - return 0; + return; #endif default: @@ -126,21 +127,13 @@ static inline void syscall_get_arguments(struct task_struct *task, { unsigned int i = 0; unsigned int n = 6; - int ret; /* O32 ABI syscall() */ if (mips_syscall_is_indirect(task, regs)) i++; while (n--) - ret |= mips_get_syscall_arg(args++, task, regs, i++); - - /* - * No way to communicate an error because this is a void function. - */ -#if 0 - return ret; -#endif + mips_get_syscall_arg(args++, task, regs, i++); } extern const unsigned long sys_call_table[]; From patchwork Mon Aug 12 03:31:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11089269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2EC714DB for ; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3C6A27DCD for ; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D81F127F86; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3225227F7F for ; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbfHLDbi (ORCPT ); Sun, 11 Aug 2019 23:31:38 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40379 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbfHLDbg (ORCPT ); Sun, 11 Aug 2019 23:31:36 -0400 Received: by mail-wr1-f65.google.com with SMTP id r1so4223967wrl.7; Sun, 11 Aug 2019 20:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pX+X19b0YkyFPAZFTnPH3TVfzRvutgNdCw+9iXgOsdU=; b=Lpamp3vwhT6x6dNvYdI8KXfkPXFp3I/7a5n3xAvi8vvW7qbgTAiRVJVwHcBDS0QT17 6K58SPa1RiEEEUerqHKSs3K0Lcfl1g7mp4QgrtoFF/YsJDlcPLQ78v2SLYSiits6PD+e 9I2LL3B5b0nW6hNNgH9oXaoTmGOtmr6Jwa4MQ9OlmFBzxjTMopq6O7L3DteVnyvWtGBQ GvDlBFM0+e/a7Yb0p7ReWk+e/EtcPT8QoxMylka6UUGkfwEU/Ib3KkwVmgSevFJ/gKYS 5f/sJEZw9Xnqsj45MH7KLCLuNwP/XAIc3NNy3thRGB5XY/98q2i8AzpqiiJbk9yakcpI 99FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pX+X19b0YkyFPAZFTnPH3TVfzRvutgNdCw+9iXgOsdU=; b=AhaiZJIOAXmG4WC9vVgIMoA6W6T+pt9DsRXEMUZn819aDLjBCpPF8dVurg7KF+GAyp IYp9eslQ9CjoHojtdt64oe7AeljA+aPeqe3/TZEuYZ8Ir0FqIVKwWG590newTqmYqXEw 5FdVnVoTs9H5yhunX8JippNxlQz2aXTibtKlk4qXRfIdK6gdfyJYgxquFRxbL7Oax2DN ZVG3be+fi0zOolSdgzfgyV4NCgFdonlomWfG/SfU7pb6CBpDjTEqZ3o1mG7jnwobu7x0 qirQerJ9TaHAy0AeT3BiL3vDeZEhww67oFQ1b3Dp+TmkKrLy4LL5vbtJTLdS7w/eF86s Srdw== X-Gm-Message-State: APjAAAWD61mRgWYn+E/7qjTguFCtqPyxOJPF0h07OgaLeMgTgIUnlSI7 u3bHiV43kEATLMcwy8IUvKU= X-Google-Smtp-Source: APXvYqzrIM/kxH8lA8H5QgWfz0l/KTO5OiXZQmgM4dB0M8sIgxXNQSrjbZOfjWipcsl6J7ATAfXeKA== X-Received: by 2002:adf:b613:: with SMTP id f19mr5713852wre.192.1565580694370; Sun, 11 Aug 2019 20:31:34 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id f12sm117299330wrg.5.2019.08.11.20.31.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 20:31:33 -0700 (PDT) From: Nathan Chancellor To: Ralf Baechle , Paul Burton , James Hogan Cc: Nick Desaulniers , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Vladimir Serbinenko , Jussi Kivilinna , Nathan Chancellor Subject: [PATCH 3/5] lib/mpi: Fix for building for MIPS32 with Clang Date: Sun, 11 Aug 2019 20:31:18 -0700 Message-Id: <20190812033120.43013-4-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0.rc2 In-Reply-To: <20190812033120.43013-1-natechancellor@gmail.com> References: <20190812033120.43013-1-natechancellor@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vladimir Serbinenko clang doesn't recognise =l / =h assembly operand specifiers but apparently handles C version well. lib/mpi/generic_mpih-mul1.c:37:24: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb); ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/mpi/longlong.h:652:20: note: expanded from macro 'umul_ppmm' : "=l" ((USItype)(w0)), \ ~~~~~~~~~~^~~ lib/mpi/generic_mpih-mul1.c:37:3: error: invalid output constraint '=h' in asm umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb); ^ lib/mpi/longlong.h:653:7: note: expanded from macro 'umul_ppmm' "=h" ((USItype)(w1)) \ ^ 2 errors generated. Fixes: 5ce3e312ec5c ("crypto: GnuPG based MPI lib - header files (part 2)") Link: https://github.com/ClangBuiltLinux/linux/issues/605 Link: https://github.com/gpg/libgcrypt/commit/1ecbd0bca31d462719a2a6590c1d03244e76ef89 Signed-off-by: Vladimir Serbinenko [jk: add changelog, rebase on libgcrypt repository, reformat changed line so it does not go over 80 characters] Signed-off-by: Jussi Kivilinna [nc: Added build error and tags to commit message Added Vladimir's signoff with his permission Adjusted Jussi's comment to wrap at 73 characters Modified commit subject to mirror MIPS64 commit Removed space between defined and (__clang__)] Signed-off-by: Nathan Chancellor --- lib/mpi/longlong.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h index 3bb6260d8f42..8a1507fc94dd 100644 --- a/lib/mpi/longlong.h +++ b/lib/mpi/longlong.h @@ -639,7 +639,8 @@ do { \ ************** MIPS ***************** ***************************************/ #if defined(__mips__) && W_TYPE_SIZE == 32 -#if (__GNUC__ >= 5) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 4) +#if defined(__clang__) || (__GNUC__ >= 5) || (__GNUC__ == 4 && \ + __GNUC_MINOR__ >= 4) #define umul_ppmm(w1, w0, u, v) \ do { \ UDItype __ll = (UDItype)(u) * (v); \ From patchwork Mon Aug 12 03:31:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11089267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31A98746 for ; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F7A27DCD for ; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1526627F86; Mon, 12 Aug 2019 03:31:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B3CD27F7F for ; Mon, 12 Aug 2019 03:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbfHLDbi (ORCPT ); Sun, 11 Aug 2019 23:31:38 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33547 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfHLDbi (ORCPT ); Sun, 11 Aug 2019 23:31:38 -0400 Received: by mail-wm1-f68.google.com with SMTP id p77so9967109wme.0; Sun, 11 Aug 2019 20:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XMXycnbWce+UbHDUEMzCA5GYy2ZL0FeWSfMNGV83HYk=; b=RSssZDQZI5E1WNiEoK8bq05Ikm9QZ+rPBWB9lbPt9P+0BhxSYiDfhnfhzBA59cC8sZ B4yA3aAWDw4yONakpXjKdVspeFrzNV/hw25jlh6Z1JdYaPA1HT31SYRIjHr2PDEXMZ+A +t0lsWe/ikHKcqzY/rOieBz8ntTQXKsoEsCrAjdaAfMf7JVxXSloKBf09pOFvhLRvSQM w0NkBKisbSX9aoA0vU1FDQHNrm5lz9+nfdL4Z6/gANQ5ohNjksHC+8EKlZRdTivBulsS leTzsX2C5BhEkB734XIYKO1fCoh8p95VxXVZaudiedFqpAudmHXFgU4+fUsxfHmYrbi8 Ttsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XMXycnbWce+UbHDUEMzCA5GYy2ZL0FeWSfMNGV83HYk=; b=B0C1G2p1rRaPDRxgJhlpFCVwMmZP42C/fwbVnCOP/smZSTecsHucwVxOjWsdGaLuJt ScGXFRNZ1XfYXW/J69g+yMCVEnFXOrIQC5fn4dZVjXkNdh2taJkbfvUFh7KM4EEnymhx NQZ/1SxxAH54KAQbc8y+v36Fa+QNEQYl2GDnOsrBbeK+IesMXZsl1M4LFykdczcnPKtp FYojX8/RF/AtX9hGNIAm5Zxqkpv1r7ur+HYAwKvbT2WLqyc8Ksf2L7ks76PxW1gK3UG4 J4pno7/uMLqRy7R5BlMKaGAjGSAZMcgYkEr8IDB65868nO31gU1529NlV4/h3ArdCL9R Bffw== X-Gm-Message-State: APjAAAWko8lQYwc4+8tahNaYXcBc5EeJQs50guQ7AUf/5LIO7N2KSidz /2tSENVafPVmUYFkmMy2a14= X-Google-Smtp-Source: APXvYqwzB/UTyeXNHuh5wTyPS+UJ020FG9M7u3PcN0r6+cmxCdQkw3YnAHwNnx6NmYzpbmsWZImSCw== X-Received: by 2002:a05:600c:228e:: with SMTP id 14mr425013wmf.101.1565580695864; Sun, 11 Aug 2019 20:31:35 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id f12sm117299330wrg.5.2019.08.11.20.31.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 20:31:35 -0700 (PDT) From: Nathan Chancellor To: Ralf Baechle , Paul Burton , James Hogan Cc: Nick Desaulniers , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Werner Koch , Nathan Chancellor Subject: [PATCH 4/5] lib/mpi: Fix for building for MIPS64 with Clang Date: Sun, 11 Aug 2019 20:31:19 -0700 Message-Id: <20190812033120.43013-5-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0.rc2 In-Reply-To: <20190812033120.43013-1-natechancellor@gmail.com> References: <20190812033120.43013-1-natechancellor@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Werner Koch * mpi/longlong.h [MIPS64][__clang__]: Use the C version like we already do for 32 bit MIPS clang errors: lib/mpi/generic_mpih-mul1.c:37:24: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb); ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/mpi/longlong.h:652:20: note: expanded from macro 'umul_ppmm' : "=l" ((USItype)(w0)), \ ~~~~~~~~~~^~~ lib/mpi/generic_mpih-mul1.c:37:3: error: invalid output constraint '=h' in asm umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb); ^ lib/mpi/longlong.h:653:7: note: expanded from macro 'umul_ppmm' "=h" ((USItype)(w1)) \ ^ 2 errors generated. Fixes: 5ce3e312ec5c ("crypto: GnuPG based MPI lib - header files (part 2)") Link: https://github.com/ClangBuiltLinux/linux/issues/605 Link: https://github.com/gpg/libgcrypt/commit/e7ae0ae243c8978a67c802169183187d88557be8 Signed-off-by: Werner Koch [nc: Added build error and tags to commit message Modified subject line Removed GnuPG-bug-id Removed space between defined and (__clang__)] Signed-off-by: Nathan Chancellor --- lib/mpi/longlong.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h index 8a1507fc94dd..5636e6a09f7a 100644 --- a/lib/mpi/longlong.h +++ b/lib/mpi/longlong.h @@ -688,7 +688,8 @@ do { \ : "d" ((UDItype)(u)), \ "d" ((UDItype)(v))); \ } while (0) -#elif (__GNUC__ >= 5) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 4) +#elif defined(__clang__) || (__GNUC__ >= 5) || (__GNUC__ == 4 && \ + __GNUC_MINOR__ >= 4) #define umul_ppmm(w1, w0, u, v) \ do { \ typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \ From patchwork Mon Aug 12 03:31:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11089265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D82C314DB for ; Mon, 12 Aug 2019 03:31:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7AAB27DCD for ; Mon, 12 Aug 2019 03:31:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B914727F86; Mon, 12 Aug 2019 03:31:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BD8027DCD for ; Mon, 12 Aug 2019 03:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbfHLDbn (ORCPT ); Sun, 11 Aug 2019 23:31:43 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39799 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfHLDbj (ORCPT ); Sun, 11 Aug 2019 23:31:39 -0400 Received: by mail-wm1-f66.google.com with SMTP id u25so10453813wmc.4; Sun, 11 Aug 2019 20:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GrCFpyZQs6ZZ7O7d1Qhq+Unb0hfalC6XSsvlDHakE4Y=; b=B97T+c1I1vatW4tiiitsJZHGgKkqj1IPibjG98ElVQTjSQbyiiT11RUFtWCnTlzmj0 oIddJjbFaRgCT3ZWBGy4eHkPsZI1US0lqWapGeF/nq/AsnCRYYcy8+n7LZg6JKQyCZDD YKwpDHv4w1gMdaBjwfUNEIKzhRuxDiDSzMOVY3W+wap9xY+hWszZd94QJj9KB5uio1dx h9Oo2MwKHk33NtD2uHGzeGJqDo96x0geSMFaGeUF7rWTJipqnXQEMZRo6qqoewPPDnOg zZxPLNA01zyM2Oc0jS+zS1Pz+41cN8BY7mkOIbJEheSWemp7hfY1DJx8D8mzDqLVpK1F wZLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GrCFpyZQs6ZZ7O7d1Qhq+Unb0hfalC6XSsvlDHakE4Y=; b=mWekkriKKZh4u/mjTn40mgWf50C9EgsV7GWH8bZnT/Gdb+DhH8c95xV7zf3AJ9Jqi3 g3omKad/+ewSdoj6Nbierx9fDJkwjmKcVMupvQDAqGBl9lHlGlABbCdNoTEMiiOHOxZg qq12W1JOFUumxm9dUk7y7wu9pxO2D2ypvYzimGtkTnCYd0ETVYJERbOH+K/hk8BRhz/T TQkH/CpjZRFJ2BtcTWsMk8+HCCN2bdZC6DeUYa/p3gpXgHBwMcS6E+m7Ab4GL2jfSsVL ym7/71/9PTpHPkV2ayX14vK4nd70zR6DvDZoluwUJB6Ra37a4jAYeDka/YeagvFjBp5r uUtg== X-Gm-Message-State: APjAAAWq40dPxa8DA8SiCN8AZxI6a/OBWj9CkA921PEILYd2acH1IAcZ QndYCAlA36kUesK2Bvhbckk= X-Google-Smtp-Source: APXvYqwHzHLvP7jzbcZ7GguxbaQufHwAcSthXLU14mLGLeTK6o86gecLOX3PCLCxQA6I2ZObCXhS+Q== X-Received: by 2002:a1c:9a4b:: with SMTP id c72mr24779104wme.102.1565580697186; Sun, 11 Aug 2019 20:31:37 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id f12sm117299330wrg.5.2019.08.11.20.31.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 11 Aug 2019 20:31:36 -0700 (PDT) From: Nathan Chancellor To: Ralf Baechle , Paul Burton , James Hogan Cc: Nick Desaulniers , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 5/5] MIPS: tlbex: Explicitly cast _PAGE_NO_EXEC to a boolean Date: Sun, 11 Aug 2019 20:31:20 -0700 Message-Id: <20190812033120.43013-6-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0.rc2 In-Reply-To: <20190812033120.43013-1-natechancellor@gmail.com> References: <20190812033120.43013-1-natechancellor@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clang warns: arch/mips/mm/tlbex.c:634:19: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand] if (cpu_has_rixi && _PAGE_NO_EXEC) { ^ ~~~~~~~~~~~~~ arch/mips/mm/tlbex.c:634:19: note: use '&' for a bitwise operation if (cpu_has_rixi && _PAGE_NO_EXEC) { ^~ & arch/mips/mm/tlbex.c:634:19: note: remove constant to silence this warning if (cpu_has_rixi && _PAGE_NO_EXEC) { ~^~~~~~~~~~~~~~~~ 1 error generated. Explicitly cast this value to a boolean so that clang understands we intend for this to be a non-zero value. Fixes: 00bf1c691d08 ("MIPS: tlbex: Avoid placing software PTE bits in Entry* PFN fields") Link: https://github.com/ClangBuiltLinux/linux/issues/609 Signed-off-by: Nathan Chancellor --- arch/mips/mm/tlbex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index eb21277f4141..071d48593464 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -629,7 +629,7 @@ static __maybe_unused void build_convert_pte_to_entrylo(u32 **p, return; } - if (cpu_has_rixi && _PAGE_NO_EXEC) { + if (cpu_has_rixi && !!_PAGE_NO_EXEC) { if (fill_includes_sw_bits) { UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL)); } else {