From patchwork Wed Dec 11 15:42:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 181258 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp700901ile; Wed, 11 Dec 2019 07:43:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxZ63i/NmFLfY6O8NDGUyvW5iLo/76jhaQGjlNXEud/XQ/o69yhyYg5JrAubtAsRCPz3ija X-Received: by 2002:aca:a9cd:: with SMTP id s196mr3320527oie.166.1576078998222; Wed, 11 Dec 2019 07:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576078998; cv=none; d=google.com; s=arc-20160816; b=SEk2UvD2ELDL5/zYc/bdQ7IPdWcnL+ZUGvp3OMfy+/njTW+rbXC/kwb+p9jUzm/0rb z9OSc7JHdqGQbhLh6UuwZ2JWWFL1UZVnLkz1AT2ht4WFJ30hubi7eTvmQL/hqV8ullgo f4Mcv+ii9Kpg9HzXb8VrMB1ie+p8yvnllfNlVhi9qs607oFxdakwNm06NgqWsJL5S0bV y1ttWYSy09D+0chU5bNnJchvubO1CSzp+xEoVKEjsD92LjVgr6kM3c0U7I4YGntBTJnh GeCbo2foNg8lYHT0tKm2YB6Q97db+vXTJG/BOmyoAfof5727EekXDRnaQsKTCf3AsbrL 4d4w== 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=eQNn68b3ary2zQb2XowfkyoxB7ExLQgUtCBhoPy5M+E=; b=rydDukSqJ8++0hAO/Wnn4eEL9anKqQiUQ+sTQFkzaGPzmThlD+Vw1dxKIaiPlOF6ND 8aocJuh7CfWgEqDsvnRxWmqSi70hSNk1j3B9nJaUCKkwFcToHmY7TniUkuS+vT3ENinU pMdUAeWlqRhfTU2QMnHs0lRAPOVfc2THTwuIxKH675AuAUm+UVqqFVOt4SITfE21DF2x F3RtmgonIOVWZO2pfeMZAIjBahPxPcD+fCbShYIg7AP9Xyf+xt5P8jibAoKXiI5rrEVf holEjYhZewAmP/Dfxe/01MBtQc5JKVLtLT/dIkySqNef2deoLpJMNlulDoxm9Q18Stqk BeLA== 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.17; Wed, 11 Dec 2019 07:43:18 -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 S2387797AbfLKPnO (ORCPT + 27 others); Wed, 11 Dec 2019 10:43:14 -0500 Received: from foss.arm.com ([217.140.110.172]:35554 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388698AbfLKPnJ (ORCPT ); Wed, 11 Dec 2019 10:43:09 -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 28A7130E; Wed, 11 Dec 2019 07:43:08 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 75FC63F52E; Wed, 11 Dec 2019 07:43:07 -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 Rutland , Mark Brown Subject: [PATCH v4 08/12] arm64: unify native/compat instruction skipping Date: Wed, 11 Dec 2019 15:42:02 +0000 Message-Id: <20191211154206.46260-9-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 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(-) -- 2.20.1 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 84c7a88dd617..de01e5041d4d 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -269,6 +269,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; @@ -279,6 +281,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); @@ -641,19 +646,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[] = { @@ -673,7 +671,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[] = { @@ -694,7 +692,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; }