Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3080873pxj; Mon, 17 May 2021 17:16:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSMFFbX1Yet+M+WKandWGfaYsEY8sNfO8kegi2z9ETWnG8bJwXWr1jeJRd12X0eFDKw4Al X-Received: by 2002:a17:906:5855:: with SMTP id h21mr2833736ejs.522.1621297010057; Mon, 17 May 2021 17:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621297010; cv=none; d=google.com; s=arc-20160816; b=FRl+dv6IcP6ffVnfgi7cJcKYKxT8Tw1MPz6Oz/GJvtzIbSUiNV2G7Uh3Uh8jH3qRKh 37W+VG3h3LcdgnzYvzz84wXe1KWPX9Ls7Ts079ar72M4lBi4NWKNUHbASHvDRvXYHCuC pgeUYj7ZG2WS6nxCDJXHIdsQ/wK/FO1F9YJK+gGVbaJi0+48id61yQVVQHgn+pPKDBl7 8mFqEZHGjKlCNv9uqyvNbXaPhJCUf35ybSLDJddLTNubuh57kgZhMDh1XOTOjFDG5U2f TuqgFab5XBRdN59j2LTki+TNk6tkZr/afcZ7sN41WYBxXt+18JwlbIusVHl+pQQ/tQCy kW1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LRyW+7VT3SeHq7CAgs7uTACJZlCO0ElZksLq0gXsigs=; b=JvalK7j2J5AzlZe+pm/BcLxAAWPpJKZFsNniiMiSmkGnx9+dGHZteaqz9gvI8xsUa5 aZoCD8dParCNxev6WLDlKiYcOPnK7bSCsAGdBavXS/eSCpr37yFBrkQlFpmWLIu/TeWm 1sFsUKV8p5NobcAKhC0Oku5piCLWOjtxdTGhC524l65ABTmJyt0/TYdrxci2nDS8rcn6 cACSjNXl2kuL+ERwkniLs1yyBExaWFRL6q17g1/yqIF43RlYOjC5Ag/FL44eHPpOuAYy u0jTUMAerProLDhGrumlrVGN9vsVHhAp/s+va1OoDljNcIqTd6te0irjrZhOCM8IyKEf yLXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=er+KMbF6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si8714830ejs.104.2021.05.17.17.16.27; Mon, 17 May 2021 17:16:50 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=er+KMbF6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237483AbhEQO1I (ORCPT + 99 others); Mon, 17 May 2021 10:27:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:38294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239057AbhEQOXY (ORCPT ); Mon, 17 May 2021 10:23:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B2486148E; Mon, 17 May 2021 14:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260748; bh=GbnpfRmvKGfTGeUaimrTOyM/DF0LtbD3kvDMlf3aLpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=er+KMbF6IDWmYipGdJf+gNhsWEtAKdVEKt8DDC0Q/DO28cAGuKY+yNsN6HaiXAIBV b7AdU96ZFUfTgFbSfa/j4psk0eJGC0mtGjNMLBIr9ukQ8BC+C/PIOhRbQQ/6DBf8Zo Q7s0d+AeDOiNeuEy8zWZDm/WR6IniuWB8X6hTKRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Mark Rutland , Hector Martin , James Morse , Thomas Gleixner , Will Deacon , Catalin Marinas , Sasha Levin Subject: [PATCH 5.12 215/363] arm64: entry: factor irq triage logic into macros Date: Mon, 17 May 2021 16:01:21 +0200 Message-Id: <20210517140309.843207262@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier [ Upstream commit 9eb563cdabe1d583c262042d5d44cc256f644543 ] In subsequent patches we'll allow an FIQ handler to be registered, and FIQ exceptions will need to be triaged very similarly to IRQ exceptions. So that we can reuse the existing logic, this patch factors the IRQ triage logic out into macros that can be reused for FIQ. The macros are named to follow the elX_foo_handler scheme used by the C exception handlers. For consistency with other top-level exception handlers, the kernel_entry/kernel_exit logic is not moved into the macros. As FIQ will use a different C handler, this handler name is provided as an argument to the macros. There should be no functional change as a result of this patch. Signed-off-by: Marc Zyngier [Mark: rework macros, commit message, rebase before DAIF rework] Signed-off-by: Mark Rutland Tested-by: Hector Martin Cc: James Morse Cc: Thomas Gleixner Cc: Will Deacon Acked-by: Will Deacon Link: https://lore.kernel.org/r/20210315115629.57191-5-mark.rutland@arm.com Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- arch/arm64/kernel/entry.S | 80 +++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 9b205744a233..feb9e4b9f9f2 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -493,8 +493,8 @@ tsk .req x28 // current thread_info /* * Interrupt handling. */ - .macro irq_handler - ldr_l x1, handle_arch_irq + .macro irq_handler, handler:req + ldr_l x1, \handler mov x0, sp irq_stack_entry blr x1 @@ -533,6 +533,45 @@ alternative_endif #endif .endm + .macro el1_interrupt_handler, handler:req + gic_prio_irq_setup pmr=x20, tmp=x1 + enable_da_f + + mov x0, sp + bl enter_el1_irq_or_nmi + + irq_handler \handler + +#ifdef CONFIG_PREEMPTION + ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count +alternative_if ARM64_HAS_IRQ_PRIO_MASKING + /* + * DA_F were cleared at start of handling. If anything is set in DAIF, + * we come back from an NMI, so skip preemption + */ + mrs x0, daif + orr x24, x24, x0 +alternative_else_nop_endif + cbnz x24, 1f // preempt count != 0 || NMI return path + bl arm64_preempt_schedule_irq // irq en/disable is done inside +1: +#endif + + mov x0, sp + bl exit_el1_irq_or_nmi + .endm + + .macro el0_interrupt_handler, handler:req + gic_prio_irq_setup pmr=x20, tmp=x0 + user_exit_irqoff + enable_da_f + + tbz x22, #55, 1f + bl do_el0_irq_bp_hardening +1: + irq_handler \handler + .endm + .text /* @@ -662,32 +701,7 @@ SYM_CODE_END(el1_sync) .align 6 SYM_CODE_START_LOCAL_NOALIGN(el1_irq) kernel_entry 1 - gic_prio_irq_setup pmr=x20, tmp=x1 - enable_da_f - - mov x0, sp - bl enter_el1_irq_or_nmi - - irq_handler - -#ifdef CONFIG_PREEMPTION - ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count -alternative_if ARM64_HAS_IRQ_PRIO_MASKING - /* - * DA_F were cleared at start of handling. If anything is set in DAIF, - * we come back from an NMI, so skip preemption - */ - mrs x0, daif - orr x24, x24, x0 -alternative_else_nop_endif - cbnz x24, 1f // preempt count != 0 || NMI return path - bl arm64_preempt_schedule_irq // irq en/disable is done inside -1: -#endif - - mov x0, sp - bl exit_el1_irq_or_nmi - + el1_interrupt_handler handle_arch_irq kernel_exit 1 SYM_CODE_END(el1_irq) @@ -727,15 +741,7 @@ SYM_CODE_END(el0_error_compat) SYM_CODE_START_LOCAL_NOALIGN(el0_irq) kernel_entry 0 el0_irq_naked: - gic_prio_irq_setup pmr=x20, tmp=x0 - user_exit_irqoff - enable_da_f - - tbz x22, #55, 1f - bl do_el0_irq_bp_hardening -1: - irq_handler - + el0_interrupt_handler handle_arch_irq b ret_to_user SYM_CODE_END(el0_irq) -- 2.30.2