From patchwork Fri Oct 18 17:25:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 176914 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1160719ill; Fri, 18 Oct 2019 10:27:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7XPpzC0XLnCGVz4sNrPpIH6IH5bSZ4EEcNUPtoVv2I7L6n2QFj4pM9mRblvi6PHGLwZ0P X-Received: by 2002:a50:9fcd:: with SMTP id c71mr10898010edf.139.1571419674099; Fri, 18 Oct 2019 10:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571419674; cv=none; d=google.com; s=arc-20160816; b=toQX38VKVoNQeyKZmnW5Skxe6Mq1ktmzqYIySCKchJT+Av++ytdBeSWfZv4h2bGBNz tn5Dh9wO+xK/2cl3wQ2snBTMkjwji33Yl/2sG4YfDsHccIB8qEe1/wWjg9C258SeSllg Vt68KZqdKWFEx1XTmEBq0vZnADINuVdkPW8lfYGyQuouhA2HTcuZKJEdeW5sbavO6imv ofbAZ/SnV2lknoTpLpXlSRwxvZgvLLgT1pHaqno2YHv6O+QXqG2blZkVzXsUUHoshbYZ kVfTycc7/41gA/SDLNc+gM2ZEAsWkQEd0LcWIsuqL5o9PtTsPN6a48fCr4Dehk7wqrI/ cFdg== 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=QwD4OkrfkOicDrXNccYtfaX1wWxbtZKTqqdS7nnU2Sw=; b=vcCiI+uFTLev4uRTPtXXxICYU3UWWWOqsvcnk3M+y6Qei/Q1punGSEvkdouZ88naB2 Y9J2h3Cxj4cJITUm8HvBl8v6V1GwyjN0RIR/MMSNhOMf53/4y2Dt8al4KSsrC+63cIQ2 2KZhvsxyB/6Y5Jtlio7r5650tlBI+HkSJxfuA2pBVSWdb64MVtGmRYGW2VM22LavviZX YkLzOu7cA05C9VmQFmhmhjyGceiYrefXZfxqjnZKuvHn/YBFpagscbv6Q+fIWpZvYST6 sdp/x5UlSMW7M0iXfPscXrSADfT8wOPk7iOPZTaDSVYuqoLeRTv1pq052W0bccGkuZC4 Joiw== 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 j13si3953650ejb.98.2019.10.18.10.27.53; Fri, 18 Oct 2019 10:27:54 -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 S2505545AbfJRR1v (ORCPT + 26 others); Fri, 18 Oct 2019 13:27:51 -0400 Received: from [217.140.110.172] ([217.140.110.172]:47222 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727068AbfJRR1p (ORCPT ); Fri, 18 Oct 2019 13:27:45 -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 9C4A414BF; Fri, 18 Oct 2019 10:27:11 -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 CB2D03F718; Fri, 18 Oct 2019 10:27:08 -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 12/12] KVM: arm64: BTI: Reset BTYPE when skipping emulated instructions Date: Fri, 18 Oct 2019 18:25:45 +0100 Message-Id: <1571419545-20401-13-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. * Add { } around if () clause that was unbalanced by the previous patch. --- arch/arm64/include/asm/kvm_emulate.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index d69c1ef..f41bfdee 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -450,10 +450,12 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, static inline void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr) { - if (vcpu_mode_is_32bit(vcpu)) + if (vcpu_mode_is_32bit(vcpu)) { kvm_skip_instr32(vcpu, is_wide_instr); - else + } else { *vcpu_pc(vcpu) += 4; + *vcpu_cpsr(vcpu) &= ~PSR_BTYPE_MASK; + } /* advance the singlestep state machine */ *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS;