Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1279760ybg; Fri, 18 Oct 2019 15:07:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxr+yPAroPHIaZE/0BIAOWhGPkUpD1vVHIfyqjKn9jaIdGeCBFWlqGvtwLRMtIXjfv7OZwl X-Received: by 2002:a50:f152:: with SMTP id z18mr12047732edl.263.1571436472095; Fri, 18 Oct 2019 15:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571436472; cv=none; d=google.com; s=arc-20160816; b=hFTKOIeuDk2v87dPNpfel7IZDniccnRdKAnRz/5NRTGvA69+dIXTcywUSe8T6oGD3y CWOJCQEPevOrBqf124hS8vUL7Z/ML84iTg3BOD+wYE6fbPxl6dz6YRDG9BF7gwYJyhDr wWK8ekq9Z4ufZrrfeZMb1pTWmMUMplLuEFNnQ02SvOXIKFFgkBzlMNEv8aKtMXtn23+Y 9Tb2KmSwTMexj6PTjeWOotGmtQHhyW4XmKeT1KRSrqC8GvZQSBolf3ltylLdXkKmMwzP dsEagYHk9z/r+QyzWybB7qL1ncsOWTfbi3CB4LqR/Kqtnpoi9En7ONuwRNlrJhMv8kRy aOUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mZYYIsx3vUti8Ycvb0HYKD/nT0xKewtlb0GUV8Tj5DI=; b=yZdSaOHHB81wwKc6oKSFVpWfpHkf8nrF2qXyN2iXuDT3/KHj+5gxamOOVtSwjRzsR0 x0nO7wAfPWB5mx3CdfphgVVZ63PGJUKUYMgg1LIKlXTmo+8Td+OkcpMdBzQ3j+sJmcZA Ub20Kke17Gh2d7l6bS21h4RCFcCVBHYu3uwzw2VHMzBpeI5iuJrqW8jl0kRTTVU+bmNc OlYtQCGQyTgiSH14Q+cRg7VoTbP6QRyCSGpcdCXYdK0zgfQnsXWWvSgo7iommOPxtLr6 ykqy8aP8xJVGsicXOGEY5T+YuV/38Zn/y+YX29Voem35cjjiHlmRfM184TRE5ZTJ5x6r mDaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Pwk+v2yJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c54si4692189edb.230.2019.10.18.15.07.22; Fri, 18 Oct 2019 15:07:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Pwk+v2yJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503040AbfJQRhw (ORCPT + 99 others); Thu, 17 Oct 2019 13:37:52 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34740 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436664AbfJQRhv (ORCPT ); Thu, 17 Oct 2019 13:37:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mZYYIsx3vUti8Ycvb0HYKD/nT0xKewtlb0GUV8Tj5DI=; b=Pwk+v2yJPT7+7nzztfWftAKoLT bv/NDDLmM6PBXWEsg3UPzBLgxXvTK18YjvYKXtxsyavi/ogzsBSzxTbgOsI+qXwEZpdORB7lvdtSd ZSTRV2p7i78niV0o3fY6iaAm+PALza57H9Cza88XaAPDRu/FF28tjY33wlRRqTvvmotVo5zTgVaiO xDSTNx9zx5WOr1cIXoaQUyg3SPPywrj+XeyoibcC7XUDApmHs/AFIWWTTWHWNihUvbqpPm9J1dj93 rhR0kbRA3Q9oBLmmkcKUpyEUERP8N84wZIYlq1itNPJ8Rf+KW5cRk1azyFKGyGRo7vv4yTv0rAnOs rq8gQ7vg==; Received: from [2001:4bb8:18c:d7b:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL9ig-0007Gy-I7; Thu, 17 Oct 2019 17:37:50 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/15] riscv: cleanup do_trap_break Date: Thu, 17 Oct 2019 19:37:30 +0200 Message-Id: <20191017173743.5430-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017173743.5430-1-hch@lst.de> References: <20191017173743.5430-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we always compile the get_break_insn_length inline function we can remove the ifdefs and let dead code elimination take care of the warn branch that is now unreadable because the report_bug stub always returns BUG_TRAP_TYPE_BUG. Signed-off-by: Christoph Hellwig --- arch/riscv/kernel/traps.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 1ac75f7d0bff..10a17e545f43 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -111,7 +111,6 @@ DO_ERROR_INFO(do_trap_ecall_s, DO_ERROR_INFO(do_trap_ecall_m, SIGILL, ILL_ILLTRP, "environment call from M-mode"); -#ifdef CONFIG_GENERIC_BUG static inline unsigned long get_break_insn_length(unsigned long pc) { bug_insn_t insn; @@ -120,28 +119,15 @@ static inline unsigned long get_break_insn_length(unsigned long pc) return 0; return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL); } -#endif /* CONFIG_GENERIC_BUG */ asmlinkage void do_trap_break(struct pt_regs *regs) { - if (user_mode(regs)) { - force_sig_fault(SIGTRAP, TRAP_BRKPT, - (void __user *)(regs->sepc)); - return; - } -#ifdef CONFIG_GENERIC_BUG - { - enum bug_trap_type type; - - type = report_bug(regs->sepc, regs); - if (type == BUG_TRAP_TYPE_WARN) { - regs->sepc += get_break_insn_length(regs->sepc); - return; - } - } -#endif /* CONFIG_GENERIC_BUG */ - - die(regs, "Kernel BUG"); + if (user_mode(regs)) + force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc); + else if (report_bug(regs->sepc, regs) == BUG_TRAP_TYPE_WARN) + regs->sepc += get_break_insn_length(regs->sepc); + else + die(regs, "Kernel BUG"); } #ifdef CONFIG_GENERIC_BUG -- 2.20.1