From patchwork Thu May 2 18:00:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13651956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2437C4345F for ; Thu, 2 May 2024 18:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=z2+Ah/SliIIdf4gHGqoU0cxWYe+b18qSXu8ae9VOWCg=; b=cYX/JQU8b1ij54 xMHl2SZpUWF3tGUuixpxwvOBI7ywBkofRPATsBjgql9N6KvTmP0aBX8fV+y4wYDYkbnfq2EAy4m/6 aMoS/td77F5JbIRqLTtDiAouwpnWDYgDIsyxPWyhB1m8sNlUKsvllhZ7L4IGz1I6LSSzusgTbNvnV yGF7O3SmEoUp+o+m5Jbe2eYNxGIqjbsO+y8Fzl4dabZK5rat4jy0hgxWmN+FNGYTCFKnG/tJ+SH+c Skx32zYij0zOZ0v6GBNPjp97ZzKjduorHKvfb06UMGhET2MRgBMO/f6dBHcw42FI/M934qiAad7Pc 1485FSEfjoVdiAC7WTuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2ajN-0000000DWwa-1kC5; Thu, 02 May 2024 18:00:29 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2ajK-0000000DWv2-1VeT for linux-arm-kernel@lists.infradead.org; Thu, 02 May 2024 18:00:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B1BEA61A1D; Thu, 2 May 2024 18:00:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DF9FC116B1; Thu, 2 May 2024 18:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714672825; bh=2ElUwF2ICPzqg1r6ina1TYny/zo1oJOeLgbtQE/BZ90=; h=From:To:Cc:Subject:Date:From; b=Eq1s56iN93KlGgj7TsME+Dhgna/x6TQYGutHM2Bnu6yGiqTdS9k9YOcEIha9PMxMc cBnQPXEWuH+/B6VEcGU4YfTcbr0fin1ycnI6rBUXo6K7Jt45N88YZz3C8WtR5YO5uN IsO+J6O0dCQNVNkxP9MvY647auZ0sv48r6e30cyaylZpVAu42vH6cOYT0EtsXbbeTe toCht87/iIZOV5x4jdNLRFyJ0cuSQP18Gm050d4l78vpwwdz/JpVSXdgyuZDayN2XI wvsE7aX7AX6d5fy51AZcWb3ECEy6jp+9qwSvAdenO5yv9KX485/KQihBOJQLwErOLG ZU+WPeecAvdQA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1s2ajH-00A53o-HM; Thu, 02 May 2024 19:00:23 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: [PATCH] KVM: arm64: Correct BTYPE/SS in host SMC emulation Date: Thu, 2 May 2024 19:00:20 +0100 Message-Id: <20240502180020.3215547-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240502_110026_880199_3BB8BB68 X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When taking a trap for an SMC instruction on the host, we must stau true to the letter of the architecture and perform all the actions that the CPU would otherwise do. Among those are clearing the BTYPE and SS bits. Just do that. Fixes: a805e1fb3099 ("KVM: arm64: Add SMC handler in nVHE EL2") Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h index 4fdfeabefeb4..b1afb7b59a31 100644 --- a/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h +++ b/arch/arm64/kvm/hyp/include/hyp/adjust_pc.h @@ -47,7 +47,13 @@ static inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) */ static inline void kvm_skip_host_instr(void) { + u64 spsr = read_sysreg_el2(SYS_SPSR); + write_sysreg_el2(read_sysreg_el2(SYS_ELR) + 4, SYS_ELR); + + spsr &= ~(PSR_BTYPE_MASK | DBG_SPSR_SS); + + write_sysreg_el2(spsr, SYS_SPSR); } #endif