Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp11078ybf; Wed, 26 Feb 2020 07:58:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxqshrIX4kEnC733iLsxGacqfr6ztrlfs9E8AjJq5g79/hQSawc4G5i2o1QWTxJpXREUbRN X-Received: by 2002:a9d:1284:: with SMTP id g4mr3418489otg.47.1582732694117; Wed, 26 Feb 2020 07:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582732694; cv=none; d=google.com; s=arc-20160816; b=nvDEA/LAG2vBwzpnLsT0vijDvGlqFNbCpLDaQ7Stq2oY8UNo8kNdpD9DAZieRsui9H R9nyVsQ+nrPEkUFsMMdcZcvp6C3WOnCuZ0C8idARg6YsTOIXPUDJ4j1uMc6Bh0V9gbTr 6BVZmgmKCsbmhNX95arr275t9k9p+8xwTq+ZfPIEgayN7YHovx9hXcrzf4KCk9YMEpkM fzNshkppNu6oATn47rsYRIt4aVufnYZUUrYavQIfTkMc91j6kW52/Wjnvh7uz/dFvBMt 0MQg8IFVrvOXtkcrRK6f4gz68OqMQUIuPEqGnDp2lxgvZ/sWgjdUM74IlVEep7fiqfsJ 5gTQ== 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=5syNXz7W2Byh9xvwmdEkp0dVfvKw7DSMxa4rwtQSx+A=; b=IwCyIS6abiGdn6ZGhz+P2JzSiEzTJK1ndXSyaxN1iaxEkp7hZPNtebZGhF4dTEtPpD yXJYhTidAkL1UZxvaJnvOIS1DZUhPDLgbkEyHEAQ2o7CIYFGzpTuC5Dc999KvWqHbS5w aurci46ULCJA1mIjkEga5K02cPejwJxX9tvzQ+IGF5jvcMFvQrxR+cXcLoYTx12riPof 3uTjsPSH8rDmEo0nd+ox/IclAPRG0vl2fCyMIxYAZ+TUy1OYBPWErBpvkwn7sCHVSSS2 N9IqDLKzGqCfLnjYZnGarsvl5SmrjkTrFeAEEHleLqtowRke2KATw8WnNFXmAOS4xgpw R2Yg== 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 t1si796otp.25.2020.02.26.07.58.01; Wed, 26 Feb 2020 07:58:14 -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 S1728866AbgBZP5l (ORCPT + 99 others); Wed, 26 Feb 2020 10:57:41 -0500 Received: from foss.arm.com ([217.140.110.172]:38110 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728806AbgBZP5j (ORCPT ); Wed, 26 Feb 2020 10:57:39 -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 B80C330E; Wed, 26 Feb 2020 07:57:38 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 01F6C3F819; Wed, 26 Feb 2020 07:57:38 -0800 (PST) From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Alexander Viro , 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=20Mart=C5=A1enko?= , Thomas Gleixner , Florian Weimer , Sudakshina Das , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, Dave Martin , Mark Rutland , Mark Brown Subject: [PATCH v7 07/11] arm64: unify native/compat instruction skipping Date: Wed, 26 Feb 2020 15:57:10 +0000 Message-Id: <20200226155714.43937-8-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200226155714.43937-1-broonie@kernel.org> References: <20200226155714.43937-1-broonie@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Martin Skipping of an instruction on AArch32 works a bit differently from AArch64, mainly due to the different CPSR/PSTATE semantics. Currently arm64_skip_faulting_instruction() is only suitable for AArch64, and arm64_compat_skip_faulting_instruction() handles the IT state machine but is local to traps.c. Since manual instruction skipping implies a trap, it's a relatively slow path. So, make arm64_skip_faulting_instruction() handle both compat and native, and get rid of the arm64_compat_skip_faulting_instruction() special case. Signed-off-by: Dave Martin Reviewed-by: Mark Rutland Signed-off-by: Mark Brown --- arch/arm64/kernel/traps.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index b8c714dda851..bc9f4292bfc3 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -272,6 +272,8 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, } } +static void advance_itstate(struct pt_regs *regs); + void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) { regs->pc += size; @@ -282,6 +284,9 @@ void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) */ if (user_mode(regs)) user_fastforward_single_step(current); + + if (regs->pstate & PSR_MODE32_BIT) + advance_itstate(regs); } static LIST_HEAD(undef_hook); @@ -644,19 +649,12 @@ static void advance_itstate(struct pt_regs *regs) compat_set_it_state(regs, it); } -static void arm64_compat_skip_faulting_instruction(struct pt_regs *regs, - unsigned int sz) -{ - advance_itstate(regs); - arm64_skip_faulting_instruction(regs, sz); -} - 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; pt_regs_write_reg(regs, reg, arch_timer_get_rate()); - arm64_compat_skip_faulting_instruction(regs, 4); + arm64_skip_faulting_instruction(regs, 4); } static const struct sys64_hook cp15_32_hooks[] = { @@ -676,7 +674,7 @@ static void compat_cntvct_read_handler(unsigned int esr, struct pt_regs *regs) pt_regs_write_reg(regs, rt, lower_32_bits(val)); pt_regs_write_reg(regs, rt2, upper_32_bits(val)); - arm64_compat_skip_faulting_instruction(regs, 4); + arm64_skip_faulting_instruction(regs, 4); } static const struct sys64_hook cp15_64_hooks[] = { @@ -697,7 +695,7 @@ void do_cp15instr(unsigned int esr, struct pt_regs *regs) * There is no T16 variant of a CP access, so we * always advance PC by 4 bytes. */ - arm64_compat_skip_faulting_instruction(regs, 4); + arm64_skip_faulting_instruction(regs, 4); return; } -- 2.20.1