Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1666602pxb; Mon, 23 Aug 2021 01:25:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7l8qwZVBrFLhJnVuFljEL2yhw+R7HHJ8J7FIxJd6SUBCxxAqEpgSgBnugm0sqmeJ6fHUN X-Received: by 2002:a92:440f:: with SMTP id r15mr21129013ila.51.1629707149216; Mon, 23 Aug 2021 01:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629707149; cv=none; d=google.com; s=arc-20160816; b=LxxFyR35kM0aJoSsrdT/gcCAvHcRGbxABr7GicRGuOAArTc1opCPdSkk1uQ0kCWdep OxGa5r+gBfGG5KkodNhEnyIdo8dl0+hLTy/iuqvF9UCS0adUiArKW+Y++Y6Fr4P0t6La YQumnNkVyfzxfpdKGfZpahDg9CNLx1brsLoDjwpAacjoCa2lpK9LcUJn7UduPKCGeTeA aFoACQzJH/lqC1v3TTPER/PaXthJwrzjkhBjM0DzzMIHyrsVbYluUWjfjqseBuwstw0q NVt6+MVWWiprmL3kDSc4gST7dGhZ0PcAREnkTS+IRhQyUj2OUhO6InBncU3XGmvKForL rVxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=ys74Dzrcoh/yk82osZlwHZaCWZHiN75cLX49UpWT3AM=; b=Da9xLTbOqyP6eajHYlJvXHFsnqOlayijRPHsSZ9Aqpje8WGipJuHKsMIvEk7Jiju1/ M4NrZl5Fc/AvHxkIfzquGLgcYt2oKnVIIfkGZidRFTeWwEArxN/aZP4VJPCgXVmUWJhS fO/KGf+OLTyGtxjXL2AdTKLXhLMx1T3/sObWiqD5b5KsAXMeKdiqGfsuGtW1igxQNzbn n7doMg4XpQrsBu1ukO0fLeQ+d7J/pJVrQyzRihJbnzfYfYVvpUqnf/oQdOeqO9sAtJYo na93atZCbyw57meBWAqAzFwM2h3m1L1YqDV1ph+0tI/AA/bVTpVlroVQ9rkYRYnbNjqi haZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si14173506ily.49.2021.08.23.01.25.37; Mon, 23 Aug 2021 01:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235455AbhHWIZl (ORCPT + 99 others); Mon, 23 Aug 2021 04:25:41 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:43655 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235394AbhHWIZk (ORCPT ); Mon, 23 Aug 2021 04:25:40 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4GtQK44DCZz9sXW; Mon, 23 Aug 2021 10:24:56 +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 LCLwRsP_MEaD; Mon, 23 Aug 2021 10:24:56 +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 4GtQJP4L7qz9sXd; Mon, 23 Aug 2021 10:24:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 695458B78C; Mon, 23 Aug 2021 10:24:21 +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 4w-KcZf10o0n; Mon, 23 Aug 2021 10:24:21 +0200 (CEST) Received: from po9473vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 310F78B788; Mon, 23 Aug 2021 10:24:21 +0200 (CEST) Received: by po9473vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 019496BC75; Mon, 23 Aug 2021 08:24:20 +0000 (UTC) Message-Id: <385ead49ccb66a259b25fee3eebf0bd4094068f3.1629707037.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH v3 1/3] powerpc: Remove MSR_PR check in interrupt_exit_{user/kernel}_prepare() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , npiggin@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 23 Aug 2021 08:24:20 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Nicholas Piggin --- 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