Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1317762ybg; Fri, 18 Oct 2019 15:50:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyt0eASPTwj4PwWy2qmkxe+4kTJe27TB/cJ3NedWo7IqgBI6ELLzZEbqlYDzinzIbe82lgC X-Received: by 2002:a05:6402:2042:: with SMTP id bc2mr12502554edb.12.1571439044017; Fri, 18 Oct 2019 15:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571439044; cv=none; d=google.com; s=arc-20160816; b=LviYFm5NAZx/LUhCJ5rOy0gcwijyKaLmpBIDEp5CZCGYsU01KGdr29e3+2C/AVW9zi 6vyEgJJKin7qa3lzvgorNAWstY2zrGArklb3Xw80fd1YKgnpqYhxi/E/zJ4DDJ7JzybK 6TpILLtHw8qa0Nu6lj2csZh3bV4LTGIPIaBgIVKdLu4/IRzXt/Jv5PBZ5Us8pnebj2GZ VzB6KzOZMj+C2PbkRwGG8u7yZSQzv/eTfxa43vjfUHkhH3FCB2jMxX9BxoPUx0/Kv9LY vJ9V9ehbfQe4abDX0RY/g9aq4hVM12Uu/sIAPQ0ZapdCt+qzOH3TRc3D/0ChB1TtIEMY XKWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=b9R5y98NMKaH6jPS3dt8xcB/piVcBix4tD337dUVV+U=; b=cnAHQLkD+9UuOe9Hn2pmgrbLQKoH/Zstk+IWbWYv4VJSC2qcTZQ04MR9KuGncIn5js gxaia4BM9N2HzEZoVr9SBNLIqL8/pLlT1BxONkowu+dCqyrfwZOJN46JHuwgGh9MuZb4 syGkq9hLomc4qoDBFeH6QL7RxNQZKXK2u8EvsQNqlVz8GdPYd/W5150rYUpV78yIvtH7 +ygwr9W9aFYjffA1beUPrQJ6DUJymNN/EyOC94bfmqQ1hT8SysQM1cu4ljt4HW46FyBQ Y/Vj2z0YdfdXslOi6SxcJfThWaidIY/jXgiy4TqBzIhSJ2/bTLeuSIww7ZMJY6joLS04 1/zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=lr3v4oXM; 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 l5si886192ejr.304.2019.10.18.15.50.21; Fri, 18 Oct 2019 15:50:44 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=lr3v4oXM; 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 S2437272AbfJRFfU (ORCPT + 99 others); Fri, 18 Oct 2019 01:35:20 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46904 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727399AbfJRFfT (ORCPT ); Fri, 18 Oct 2019 01:35:19 -0400 Received: by mail-wr1-f66.google.com with SMTP id o18so4726925wrv.13 for ; Thu, 17 Oct 2019 22:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b9R5y98NMKaH6jPS3dt8xcB/piVcBix4tD337dUVV+U=; b=lr3v4oXMaRG5gAZxgoVM3k6FFXgrbPR30EKD0XeOzoTPooPshQgi/yBeZU9Fddzbk0 s6eQnTxY+kbK4MsX0PYmszVhgXYLC+DCYcUnrqoolsWhpgNywn7Fq30K70sVNdw91KFk TzaG076OeZ5IpoWli4BM2pL6chZGiBpYUuZyaBgLzmK1BIQu/2+7ifsZCooc8xO/G3WC HUIkK1Ijgg7FL3FTDhnof/SnW+LCZkqMCr433uM3yHy0EC+kGV46R+88Ss4W64/2e9tF KIPKJ4FQWeK3t4KCOZXPCgpnGY7s7MGgGHWdvkCHrHS94RLVUlLFl0L9mZ2QiRFcAf0w ZKHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=b9R5y98NMKaH6jPS3dt8xcB/piVcBix4tD337dUVV+U=; b=aCExtKyIAZVQNjfB71I7/R1ZKMR0+7Ksdm0g2i6fzFc5AtO1H021fQwxjkOeOaoywf UOt1rGcSzAlBokLALDGI5+90ZI5sf3JsKPrykmjBcx4dvBDvMh1VwrS7OByoCpkboFH+ UHiwLfo+4s12kgbvx1NbE/PXYKYUWJ/Bp7Oc9/3mEL9YYF6xCi8/MOc3bfe+6Le/Tp0O P6rzy1Wp6jw6ynDW3XiAXzvd7axuSthKAR52hV+jpU78SPT308zwbnn1b0bpNGSe+MGy NhgFwb2mwzNgBpAMQE79gGWrlJh68WtTeft76jlIY3cSPT8XtI+QTpHoHpvtyEVKKb/o pkBA== X-Gm-Message-State: APjAAAVovHKV/bM0n8AnKeWoccaKM7qTjupxc8qEmtV3YQX2AidrAziv aLW7YMA9Zq49gAw9MXUrsmlvNsV6YQD3wt2Tiv8nCOvTiNU= X-Received: by 2002:a5d:42c2:: with SMTP id t2mr5328686wrr.251.1571367079285; Thu, 17 Oct 2019 19:51:19 -0700 (PDT) MIME-Version: 1.0 References: <20191017173743.5430-1-hch@lst.de> <20191017173743.5430-3-hch@lst.de> In-Reply-To: <20191017173743.5430-3-hch@lst.de> From: Anup Patel Date: Fri, 18 Oct 2019 08:21:08 +0530 Message-ID: Subject: Re: [PATCH 02/15] riscv: cleanup do_trap_break To: Christoph Hellwig Cc: Palmer Dabbelt , Paul Walmsley , Damien Le Moal , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 11:07 PM Christoph Hellwig wrote: > > 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 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv LGTM. Reviewed-by: Anup Patel Regards, Anup