From patchwork Fri Oct 18 17:25:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 176915 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1160764ill; Fri, 18 Oct 2019 10:27:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGP2QhwJNBPOzHYOyld+LXwsrnlo+YHNDLpho/D1gWB9FQZ+e4sQP1A18a1Oe8DrIiAI8v X-Received: by 2002:a17:906:3009:: with SMTP id 9mr9866042ejz.124.1571419677607; Fri, 18 Oct 2019 10:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571419677; cv=none; d=google.com; s=arc-20160816; b=0i0eg5YgaNP2Ag47EOXM0cJzqu0mtW6VUpUmnAJjqGo6fKM3tFKdQAEwzTL6tFLf2e gg9/CFF0yh7vD+8aNHMmuzn7Lp/LkZCmyD9Vuj1+0YH9GvyufaKKj/XtxAQgruucbFOR /QBSGQ5OwCOmrhgeNPKExNVZObli1Hm+fMmsyP9FDJD4ixXzl/TEghN2U/MyOI6rK/Et fQKXoj3h+MLeoPhdg7c6abzKQg9N4F9lN5S7MLUuBjy5Y9+K1N260phToh3yX4vWUhYP OkSQmKCUxW/H3c5DQ6GCZZVLxqQaeDeaMdryJ5RN5ZZ8XHTn62vIttueEvRu+zo3hk9W PbZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Jc8mW/K7+EAI/VUVHj4l3Cl1wkDcboPSy+AQsIC08eI=; b=hfRCFbYOVi9lufVime77Za6BKuOscAnVrtnZa5p4YjXOMwf6P+KamUBnl/mx5qzip+ 9vpoXfbgCnTiuJWDe3PFuUPuWDA6FXe0IL+f4B38iBh7U/kdguS6Zg+np3AIBFNYlSDq b0fXGKPhziHSEJsltEe4/u40MVUEP4pCmcaQ8mA9mHz2UXBKnfb3eJBxd2ZOXapVbvif Kh7qrEzWqOzxUmXkkYJNfHTowiMcy88qzDs8Y7jh6BAkj7aZCxoWtwpEJ6mVZVX8vmus fi8ZSOR1PTB7uSs8tLYh9bO6j+NaIQrb9gs4LeI2zlimT8slxpMHaRc5fcId7CRai1Zn EDVA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g19si3807736ejj.120.2019.10.18.10.27.57; Fri, 18 Oct 2019 10:27:57 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2634480AbfJRR1e (ORCPT + 26 others); Fri, 18 Oct 2019 13:27:34 -0400 Received: from [217.140.110.172] ([217.140.110.172]:47188 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S2505494AbfJRR1c (ORCPT ); Fri, 18 Oct 2019 13:27:32 -0400 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 929FB143D; Fri, 18 Oct 2019 10:27:08 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ACA573F718; Fri, 18 Oct 2019 10:27:05 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: Andrew Jones , Arnd Bergmann , Catalin Marinas , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Kees Cook , =?utf-8?q?Kristina_Mart=C5=A1enko?= , Marc Zyngier , Mark Brown , Paul Elliott , Peter Zijlstra , Richard Henderson , Sudakshina Das , Szabolcs Nagy , Thomas Gleixner , Will Deacon , Yu-cheng Yu , Amit Kachhap , Vincenzo Frascino , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 11/12] arm64: BTI: Reset BTYPE when skipping emulated instructions Date: Fri, 18 Oct 2019 18:25:44 +0100 Message-Id: <1571419545-20401-12-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571419545-20401-1-git-send-email-Dave.Martin@arm.com> References: <1571419545-20401-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since normal execution of any non-branch instruction resets the PSTATE BTYPE field to 0, so do the same thing when emulating a trapped instruction. Branches don't trap directly, so we should never need to assign a non-zero value to BTYPE here. Signed-off-by: Dave Martin --- Changes since v2: * Drop (u64) case when masking out PSR_BTYPE_MASK in arm64_skip_faulting_instruction(). PSTATE may grow, but we should address this more generally rather than with point hacks in this series. --- arch/arm64/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.1.4 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 3af2768..5c46a7b 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -331,6 +331,8 @@ void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) if (regs->pstate & PSR_MODE32_BIT) advance_itstate(regs); + else + regs->pstate &= ~PSR_BTYPE_MASK; } static LIST_HEAD(undef_hook);