From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A097C4338F for ; Wed, 4 Aug 2021 08:37:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CCE860E97 for ; Wed, 4 Aug 2021 08:37:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236621AbhHDIh0 (ORCPT ); Wed, 4 Aug 2021 04:37:26 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:58473 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236493AbhHDIhW (ORCPT ); Wed, 4 Aug 2021 04:37:22 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GflTw4r3dz9sVl; Wed, 4 Aug 2021 10:37:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4YTPUHOfzsKL; Wed, 4 Aug 2021 10:37:08 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4GflTw3XfSz9sVg; Wed, 4 Aug 2021 10:37:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3336A8B7A3; Wed, 4 Aug 2021 10:37:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 3ppPbVI8GWdy; Wed, 4 Aug 2021 10:37:08 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A0F328B7A1; Wed, 4 Aug 2021 10:37:07 +0200 (CEST) Subject: Re: [PATCH] powerpc: Remove MSR_PR check in interrupt_exit_{user/kernel}_prepare() To: Nicholas Piggin , Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <1628064412.48kzr1eula.astroid@bobo.none> From: Christophe Leroy Message-ID: Date: Wed, 4 Aug 2021 10:37:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <1628064412.48kzr1eula.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 04/08/2021 à 10:08, Nicholas Piggin a écrit : > Excerpts from Christophe Leroy's message of August 4, 2021 3:27 pm: >> In those hot functions that are called at every interrupt, any saved >> cycle is worth it. >> >> interrupt_exit_user_prepare() and interrupt_exit_kernel_prepare() are >> called from three places: >> - From entry_32.S >> - From interrupt_64.S >> - From interrupt_exit_user_restart() and interrupt_exit_kernel_restart() >> >> In entry_32.S, there are inambiguously called based on MSR_PR: >> >> interrupt_return: >> lwz r4,_MSR(r1) >> addi r3,r1,STACK_FRAME_OVERHEAD >> andi. r0,r4,MSR_PR >> beq .Lkernel_interrupt_return >> bl interrupt_exit_user_prepare >> ... >> .Lkernel_interrupt_return: >> bl interrupt_exit_kernel_prepare >> >> In interrupt_64.S, that's similar: >> >> interrupt_return_\srr\(): >> ld r4,_MSR(r1) >> andi. r0,r4,MSR_PR >> beq interrupt_return_\srr\()_kernel >> interrupt_return_\srr\()_user: /* make backtraces match the _kernel variant */ >> addi r3,r1,STACK_FRAME_OVERHEAD >> bl interrupt_exit_user_prepare >> ... >> interrupt_return_\srr\()_kernel: >> addi r3,r1,STACK_FRAME_OVERHEAD >> bl interrupt_exit_kernel_prepare >> >> In interrupt_exit_user_restart() and interrupt_exit_kernel_restart(), >> MSR_PR is verified respectively by BUG_ON(!user_mode(regs)) and >> BUG_ON(user_mode(regs)) prior to calling interrupt_exit_user_prepare() >> and interrupt_exit_kernel_prepare(). >> >> The verification in interrupt_exit_user_prepare() and >> interrupt_exit_kernel_prepare() are therefore useless and can be removed. >> >> Signed-off-by: Christophe Leroy > > Probably okay to do now things are ironing out. > > Unless we want to make a new define for interrupt handler debug and put > a bunch of these asserts under it. There's quite a lot more here, and > in asm/interrupt.h, etc. But that one is so trivial that I'm not sure there is any point in keeping it even as a kind of additional DEBUG level, unless you want those BUG_ONs because you don't trust the compiler. Christophe > > Thanks, > Nick > >> --- >> arch/powerpc/kernel/interrupt.c | 2 -- >> 1 file changed, 2 deletions(-) >> >> diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c >> index 21bbd615ca41..f26caf911ab5 100644 >> --- a/arch/powerpc/kernel/interrupt.c >> +++ b/arch/powerpc/kernel/interrupt.c >> @@ -465,7 +465,6 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs) >> >> if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x)) >> BUG_ON(!(regs->msr & MSR_RI)); >> - BUG_ON(!(regs->msr & MSR_PR)); >> BUG_ON(arch_irq_disabled_regs(regs)); >> CT_WARN_ON(ct_state() == CONTEXT_USER); >> >> @@ -499,7 +498,6 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs) >> if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x) && >> unlikely(!(regs->msr & MSR_RI))) >> unrecoverable_exception(regs); >> - BUG_ON(regs->msr & MSR_PR); >> /* >> * CT_WARN_ON comes here via program_check_exception, >> * so avoid recursion. >> -- >> 2.25.0 >> >>