From patchwork Wed Dec 11 15:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 181257 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp700852ile; Wed, 11 Dec 2019 07:43:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyF2qZDr8jx2yDHwAH72udOkK5p3OjTNISAv/Hbwcmo6PSYmsEVe/1QSUm0/anXpeZRlNWw X-Received: by 2002:aca:b588:: with SMTP id e130mr3113627oif.169.1576078995604; Wed, 11 Dec 2019 07:43:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576078995; cv=none; d=google.com; s=arc-20160816; b=MWxk9x5kTpwdgjb2EbbsOfkR02dZOViUvhrRARVQteNbhE4Hl1+FiWWeYmNGwqbxPZ OwjCzou4gq2rYRNUu3/RRtvs8ET4WFu8q9khEisjDx8RhMvlBC33Xhe6XawuqvvSr6IL KYzJoAk6IsHLagXa3SgUPcfQ6KZeQMhkLVM5nO2oCgqTmZTGsrfW4OzqSnKzRoqeDH3y bSWpn1ElvfydbGwLHsvobBWe9ihy4/AWyYukHkZc/M8A8ZAEkpcj4MkSR9vfH5xK8E8K OsQAKi1dqy/u0fLWOeM1gIJp+l7Zy59xKQNgu/7F1IR5p9YG8k8nph6g7+RsHHJ0KQck IfCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4S0cpP+tUnagHySWs6Aqtio4TuIshfpQY80/KGMhtso=; b=U/VSijFL4mopX8D/s/jnQvEtP0Rh3o0vVsmM0Z+SFJaC22eF2gEF3K8fIfdMYukJw5 0G2sjBce/TzfHOGwfEevO07fg33zFsb+9xBs2w0tM7sTRKspvB2JPbhS6jcwZgXeX/HC JvlhLGADw6XheZQDWWKPTQAWrTuV/HochW5yyJgzUU2YEcTXRKPMJN9M0Kb9H7hOOBz+ KajMVtyI1YNOy7UtO/Qo4+Vdjga0IeITeNwWNBrXUHkLDmuB7PkJN79GBwIEB53Nw/0t Qcn5UIoZyrbxXNrHZfxBXi1+geaCC5KF6+K9YebgIbCmBlgmS6xFe5w+3GbrhzFBBF1E gHrw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si1340581oie.52.2019.12.11.07.43.15; Wed, 11 Dec 2019 07:43:15 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388729AbfLKPnO (ORCPT + 27 others); Wed, 11 Dec 2019 10:43:14 -0500 Received: from foss.arm.com ([217.140.110.172]:35582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387912AbfLKPnM (ORCPT ); Wed, 11 Dec 2019 10:43:12 -0500 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 799B4DA7; Wed, 11 Dec 2019 07:43:11 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C52103F52E; Wed, 11 Dec 2019 07:43:10 -0800 (PST) From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Paul Elliott , Peter Zijlstra , Yu-cheng Yu , Amit Kachhap , Vincenzo Frascino , Marc Zyngier , Eugene Syromiatnikov , Szabolcs Nagy , "H.J. Lu" , Andrew Jones , Kees Cook , Arnd Bergmann , Jann Horn , Richard Henderson , =?utf-8?q?Kristina_Mart=C5=A1enko?= , Thomas Gleixner , Florian Weimer , Sudakshina Das , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Dave Martin , Mark Brown Subject: [PATCH v4 09/12] arm64: traps: Shuffle code to eliminate forward declarations Date: Wed, 11 Dec 2019 15:42:03 +0000 Message-Id: <20191211154206.46260-10-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191211154206.46260-1-broonie@kernel.org> References: <20191211154206.46260-1-broonie@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Martin Hoist the IT state handling code earlier in traps.c, to avoid accumulating forward declarations. No functional change. Signed-off-by: Dave Martin Signed-off-by: Mark Brown --- arch/arm64/kernel/traps.c | 101 ++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 52 deletions(-) -- 2.20.1 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index de01e5041d4d..bf79d8024fbe 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -269,7 +269,55 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, } } -static void advance_itstate(struct pt_regs *regs); +#ifdef CONFIG_COMPAT +#define PSTATE_IT_1_0_SHIFT 25 +#define PSTATE_IT_1_0_MASK (0x3 << PSTATE_IT_1_0_SHIFT) +#define PSTATE_IT_7_2_SHIFT 10 +#define PSTATE_IT_7_2_MASK (0x3f << PSTATE_IT_7_2_SHIFT) + +static u32 compat_get_it_state(struct pt_regs *regs) +{ + u32 it, pstate = regs->pstate; + + it = (pstate & PSTATE_IT_1_0_MASK) >> PSTATE_IT_1_0_SHIFT; + it |= ((pstate & PSTATE_IT_7_2_MASK) >> PSTATE_IT_7_2_SHIFT) << 2; + + return it; +} + +static void compat_set_it_state(struct pt_regs *regs, u32 it) +{ + u32 pstate_it; + + pstate_it = (it << PSTATE_IT_1_0_SHIFT) & PSTATE_IT_1_0_MASK; + pstate_it |= ((it >> 2) << PSTATE_IT_7_2_SHIFT) & PSTATE_IT_7_2_MASK; + + regs->pstate &= ~PSR_AA32_IT_MASK; + regs->pstate |= pstate_it; +} + +static void advance_itstate(struct pt_regs *regs) +{ + u32 it; + + /* ARM mode */ + if (!(regs->pstate & PSR_AA32_T_BIT) || + !(regs->pstate & PSR_AA32_IT_MASK)) + return; + + it = compat_get_it_state(regs); + + /* + * If this is the last instruction of the block, wipe the IT + * state. Otherwise advance it. + */ + if (!(it & 7)) + it = 0; + else + it = (it & 0xe0) | ((it << 1) & 0x1f); + + compat_set_it_state(regs, it); +} void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) { @@ -575,34 +623,6 @@ static const struct sys64_hook sys64_hooks[] = { {}, }; - -#ifdef CONFIG_COMPAT -#define PSTATE_IT_1_0_SHIFT 25 -#define PSTATE_IT_1_0_MASK (0x3 << PSTATE_IT_1_0_SHIFT) -#define PSTATE_IT_7_2_SHIFT 10 -#define PSTATE_IT_7_2_MASK (0x3f << PSTATE_IT_7_2_SHIFT) - -static u32 compat_get_it_state(struct pt_regs *regs) -{ - u32 it, pstate = regs->pstate; - - it = (pstate & PSTATE_IT_1_0_MASK) >> PSTATE_IT_1_0_SHIFT; - it |= ((pstate & PSTATE_IT_7_2_MASK) >> PSTATE_IT_7_2_SHIFT) << 2; - - return it; -} - -static void compat_set_it_state(struct pt_regs *regs, u32 it) -{ - u32 pstate_it; - - pstate_it = (it << PSTATE_IT_1_0_SHIFT) & PSTATE_IT_1_0_MASK; - pstate_it |= ((it >> 2) << PSTATE_IT_7_2_SHIFT) & PSTATE_IT_7_2_MASK; - - regs->pstate &= ~PSR_AA32_IT_MASK; - regs->pstate |= pstate_it; -} - static bool cp15_cond_valid(unsigned int esr, struct pt_regs *regs) { int cond; @@ -623,29 +643,6 @@ static bool cp15_cond_valid(unsigned int esr, struct pt_regs *regs) return aarch32_opcode_cond_checks[cond](regs->pstate); } -static void advance_itstate(struct pt_regs *regs) -{ - u32 it; - - /* ARM mode */ - if (!(regs->pstate & PSR_AA32_T_BIT) || - !(regs->pstate & PSR_AA32_IT_MASK)) - return; - - it = compat_get_it_state(regs); - - /* - * If this is the last instruction of the block, wipe the IT - * state. Otherwise advance it. - */ - if (!(it & 7)) - it = 0; - else - it = (it & 0xe0) | ((it << 1) & 0x1f); - - compat_set_it_state(regs, it); -} - static void compat_cntfrq_read_handler(unsigned int esr, struct pt_regs *regs) { int reg = (esr & ESR_ELx_CP15_32_ISS_RT_MASK) >> ESR_ELx_CP15_32_ISS_RT_SHIFT;