Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EE50ECAAD3 for ; Wed, 14 Sep 2022 05:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W+eVYQD9W7TzXobJkvYu6YORWv6Ln/hyHtyv1QEDUNg=; b=2rhBRiIgHTjwzX ZMGk6NoKZmJuwZKw4URWDJTTYO/iH1Vg3KXxPCeIa9M170QVn1IwVw3F7WrnW1ZQb62CdxlIJJgz/ PMeEVzLeBIUktGVDaxDS956GudM5a9LeJRCtbp+YZ7CVHVVh5r6BhJwNgVlL51Hr6l59KMRivIf0O M/KlWvl+6d+FXtztd98Vg0DNQc8alcxxAJTPbRsEi1QzCzZymFZ/cbdvNa94YoqncylZFdclTdTNP lAYRldbxFZglif88LBKhk0na/59Biq79uTUKPV++zByH5a2GgDuk2F3I/erriAsiYSTQs0ug2l+QH a05iUBO4u0SgY9rT/ABA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYLKR-007yAn-CY; Wed, 14 Sep 2022 05:52:55 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYLKM-007y54-RR for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2022 05:52:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1B2991576; Tue, 13 Sep 2022 22:52:52 -0700 (PDT) Received: from [10.162.43.6] (unknown [10.162.43.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5BD7C3F73D; Tue, 13 Sep 2022 22:53:11 -0700 (PDT) Message-ID: <369c2945-037d-156b-0679-8b26673641ce@arm.com> Date: Wed, 14 Sep 2022 11:22:40 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 3/5] arm64: consistently pass ESR_ELx to die() Content-Language: en-US To: Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: alexandru.elisei@arm.com, amit.kachhap@arm.com, broonie@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, will@kernel.org References: <20220913101732.3925290-1-mark.rutland@arm.com> <20220913101732.3925290-4-mark.rutland@arm.com> From: Anshuman Khandual In-Reply-To: <20220913101732.3925290-4-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_225251_032939_29ABB50B X-CRM114-Status: GOOD ( 24.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/13/22 15:47, Mark Rutland wrote: > Currently, bug_handler() and kasan_handler() call die() with '0' as the > 'err' value, whereas die_kernel_fault() passes the ESR_ELx value. > > For consistency, this patch ensures we always pass the ESR_ELx value to > die(). As this is only called for exceptions taken from kernel mode, > there should be no user-visible change as a result of this patch. > > For UNDEFINED exceptions, I've had to modify do_undefinstr() and its > callers to pass the ESR_ELx value. In all cases the ESR_ELx value had > already been read and was available. > > Signed-off-by: Mark Rutland > Cc: Mark Brown > Cc: Alexandru Elisei > Cc: Amit Daniel Kachhap > Cc: Catalin Marinas > Cc: James Morse > Cc: Will Deacon Reviewed-by: Anshuman Khandual > --- > arch/arm64/include/asm/exception.h | 2 +- > arch/arm64/kernel/entry-common.c | 14 +++++++------- > arch/arm64/kernel/traps.c | 14 +++++++------- > 3 files changed, 15 insertions(+), 15 deletions(-) > > diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h > index d94aecff96902..28c0275666e12 100644 > --- a/arch/arm64/include/asm/exception.h > +++ b/arch/arm64/include/asm/exception.h > @@ -58,7 +58,7 @@ asmlinkage void call_on_irq_stack(struct pt_regs *regs, > asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs); > > void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs); > -void do_undefinstr(struct pt_regs *regs); > +void do_undefinstr(struct pt_regs *regs, unsigned long esr); > void do_bti(struct pt_regs *regs); > void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr, > struct pt_regs *regs); > diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c > index c75ca36b4a491..3dd17ef6d6d8b 100644 > --- a/arch/arm64/kernel/entry-common.c > +++ b/arch/arm64/kernel/entry-common.c > @@ -379,11 +379,11 @@ static void noinstr el1_pc(struct pt_regs *regs, unsigned long esr) > exit_to_kernel_mode(regs); > } > > -static void noinstr el1_undef(struct pt_regs *regs) > +static void noinstr el1_undef(struct pt_regs *regs, unsigned long esr) > { > enter_from_kernel_mode(regs); > local_daif_inherit(regs); > - do_undefinstr(regs); > + do_undefinstr(regs, esr); > local_daif_mask(); > exit_to_kernel_mode(regs); > } > @@ -425,7 +425,7 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs) > break; > case ESR_ELx_EC_SYS64: > case ESR_ELx_EC_UNKNOWN: > - el1_undef(regs); > + el1_undef(regs, esr); > break; > case ESR_ELx_EC_BREAKPT_CUR: > case ESR_ELx_EC_SOFTSTP_CUR: > @@ -582,11 +582,11 @@ static void noinstr el0_sp(struct pt_regs *regs, unsigned long esr) > exit_to_user_mode(regs); > } > > -static void noinstr el0_undef(struct pt_regs *regs) > +static void noinstr el0_undef(struct pt_regs *regs, unsigned long esr) > { > enter_from_user_mode(regs); > local_daif_restore(DAIF_PROCCTX); > - do_undefinstr(regs); > + do_undefinstr(regs, esr); > exit_to_user_mode(regs); > } > > @@ -670,7 +670,7 @@ asmlinkage void noinstr el0t_64_sync_handler(struct pt_regs *regs) > el0_pc(regs, esr); > break; > case ESR_ELx_EC_UNKNOWN: > - el0_undef(regs); > + el0_undef(regs, esr); > break; > case ESR_ELx_EC_BTI: > el0_bti(regs); > @@ -788,7 +788,7 @@ asmlinkage void noinstr el0t_32_sync_handler(struct pt_regs *regs) > case ESR_ELx_EC_CP14_MR: > case ESR_ELx_EC_CP14_LS: > case ESR_ELx_EC_CP14_64: > - el0_undef(regs); > + el0_undef(regs, esr); > break; > case ESR_ELx_EC_CP15_32: > case ESR_ELx_EC_CP15_64: > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index da8ffef6f7c58..05999cde870a9 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -485,7 +485,7 @@ void arm64_notify_segfault(unsigned long addr) > force_signal_inject(SIGSEGV, code, addr, 0); > } > > -void do_undefinstr(struct pt_regs *regs) > +void do_undefinstr(struct pt_regs *regs, unsigned long esr) > { > /* check for AArch32 breakpoint instructions */ > if (!aarch32_break_handler(regs)) > @@ -495,7 +495,7 @@ void do_undefinstr(struct pt_regs *regs) > return; > > if (!user_mode(regs)) > - die("Oops - Undefined instruction", regs, 0); > + die("Oops - Undefined instruction", regs, esr); > > force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0); > } > @@ -760,7 +760,7 @@ void do_cp15instr(unsigned long esr, struct pt_regs *regs) > hook_base = cp15_64_hooks; > break; > default: > - do_undefinstr(regs); > + do_undefinstr(regs, esr); > return; > } > > @@ -775,7 +775,7 @@ void do_cp15instr(unsigned long esr, struct pt_regs *regs) > * EL0. Fall back to our usual undefined instruction handler > * so that we handle these consistently. > */ > - do_undefinstr(regs); > + do_undefinstr(regs, esr); > } > NOKPROBE_SYMBOL(do_cp15instr); > #endif > @@ -795,7 +795,7 @@ void do_sysinstr(unsigned long esr, struct pt_regs *regs) > * back to our usual undefined instruction handler so that we handle > * these consistently. > */ > - do_undefinstr(regs); > + do_undefinstr(regs, esr); > } > NOKPROBE_SYMBOL(do_sysinstr); > > @@ -972,7 +972,7 @@ static int bug_handler(struct pt_regs *regs, unsigned long esr) > { > switch (report_bug(regs->pc, regs)) { > case BUG_TRAP_TYPE_BUG: > - die("Oops - BUG", regs, 0); > + die("Oops - BUG", regs, esr); > break; > > case BUG_TRAP_TYPE_WARN: > @@ -1040,7 +1040,7 @@ static int kasan_handler(struct pt_regs *regs, unsigned long esr) > * This is something that might be fixed at some point in the future. > */ > if (!recover) > - die("Oops - KASAN", regs, 0); > + die("Oops - KASAN", regs, esr); > > /* If thread survives, skip over the brk instruction and continue: */ > arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel