From patchwork Thu Oct 10 18:44:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 175825 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2683728ill; Thu, 10 Oct 2019 11:46:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrdSOd7PeIUhX87dCoCl8q6I29cCl1cWf7pamA3FlsAjS3na8bZ2jMRfAj1rZItNIElQNd X-Received: by 2002:a17:906:f15:: with SMTP id z21mr9721078eji.119.1570733169817; Thu, 10 Oct 2019 11:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570733169; cv=none; d=google.com; s=arc-20160816; b=fSIhr2pohaDlttJ5XwoTunZ8R6WMAMC8y3oPNyeL2L36RnVcW73Iybx9mRiRuXI+7Z F20DOiUycgMKzvJySbdfX1PsNz6ToaCf6sV2KElaVJsWqTdTVTrU61mOHbPbpOtvnPzD ttSfA5Y4uKxKTYtOP1ut5nZTWusupGW7S5Lei0KAEnt//qMTZhBT/Xjj1dkK1ghnxz1I cVazV7M+W1pXz5NY+QtFRSY8uLNhVq4dtsOnUTliYymhsiC0yuL+oDqjvzQoxJI2W2Oz Z8hyiZ9qbGz5L9Jr/sJx1+riWTOjtmWapLnqfVRGcYK3v/pLSZOR0NuN4ds7wkqZnucy QsAA== 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=4usNhHJ/m7K6k262ByI2Uu+K1GDKdnOUpYdfRp1F45U=; b=cJK5rr2XFLU9QPw+YrcbqUre3GOpPvOnO7ADxxh6gHMYntzxDWJ2vwsotnFPpbBwX5 WaDYWmln7TZv6u5vbE3pT4qsgPcnSrNfS2waHpVWznCUHobk/BLvBK2MYljXOBA02gd1 w2AcjsWHOa3vNdUKF+RAqoZsTEGAp5EiasjjoHM1pFSKhzKcDoaBiKQvtuXKzaISqzl7 UupmfzNWqHvKtf/nV70EqJL4Yw0yVBp+BQ/m89KpiEmUZTYUhZ5byYMCo5PBIiP8lR6n B/O27Tputg9N/68e+sXQOPln3Slx7DuqPwoyJsRmy1q2cvZKSE60sxEMAiTvWuKimN0W whqg== 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 c21si3610043ejs.390.2019.10.10.11.46.09; Thu, 10 Oct 2019 11:46:09 -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 S1727321AbfJJSqJ (ORCPT + 22 others); Thu, 10 Oct 2019 14:46:09 -0400 Received: from foss.arm.com ([217.140.110.172]:38594 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727307AbfJJSqF (ORCPT ); Thu, 10 Oct 2019 14:46:05 -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 0D0C61570; Thu, 10 Oct 2019 11:46:05 -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 41B7D3F703; Thu, 10 Oct 2019 11:46:02 -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?= , 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 v2 12/12] KVM: arm64: BTI: Reset BTYPE when skipping emulated instructions Date: Thu, 10 Oct 2019 19:44:40 +0100 Message-Id: <1570733080-21015-13-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1570733080-21015-1-git-send-email-Dave.Martin@arm.com> References: <1570733080-21015-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 --- arch/arm64/include/asm/kvm_emulate.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.1.4 diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index d69c1ef..33957a12 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -452,8 +452,10 @@ static inline void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr) { if (vcpu_mode_is_32bit(vcpu)) kvm_skip_instr32(vcpu, is_wide_instr); - else + else { *vcpu_pc(vcpu) += 4; + *vcpu_cpsr(vcpu) &= ~(u64)PSR_BTYPE_MASK; + } /* advance the singlestep state machine */ *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS;