From patchwork Thu Aug 15 12:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13764779 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 ECB11C3DA7F for ; Thu, 15 Aug 2024 13:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MVwXgNHCjCOdCkgAKUw2SEdaVTKVjE2/H2GV1qE7Cxc=; b=Q/1PW9tNQxtZiLEa3HEg6aCK0L Elft8UomX8Ia5YlpIQPvjOiQ+rfQWDtDxwqfUwvwVVrIfbluJjN/cQh1dW38jbjJlmMvqHfWaSOIc Ig3s7/qCWNe2/0XP7/lgq2rmmjHvDQN07j8FdveElNNdXUYKV93D1dlgH/IjgTC2//NuIhA2hIppU YagrsFxOwS/+90oJy64UTl0nYO9SnVaQsRuE40sOCGHECzwLRJkLML/UAY9rR5vLwknuY8hZQNscG bS4aGsTAiDbJqTPqq/sSZoJ/lCRh9qVVfxVDHtFGriGPnHs7rrXssxc+SYhg1UTZBcaRcnlJ1nrqv xGwAjoqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seaA0-00000009yyu-1BhX; Thu, 15 Aug 2024 13:05:00 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sea5I-00000009xj8-0IHb for linux-arm-kernel@lists.infradead.org; Thu, 15 Aug 2024 13:00:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4FB8761E79; Thu, 15 Aug 2024 13:00:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21AFFC32786; Thu, 15 Aug 2024 13:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723726806; bh=FdXzmEqnicsBQJVaq32QPKRzq71MPgC+SurKqoL/YQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LDaecOHqkuS1WEzQu0tJ9ifE23c9GA3A0Gdvv9guwT2/B1XQGBP2a4l5cJFVwcgvT g8wEo2VBlmnCipVCHNO8MIyUQzt/r2gf5JGQXP8E2QsQD4I8X55uYR0HWi1r+sCK4w JI5gtgsKHR3fxuMLGjXJH98PlPtc5BnQxu3YscIVkK6IHkttUw5Am22LwzV8kFMZDY +DCsUHxnKIxe6A510tZ/GnoEwuQSr7GSsdEPHOlRXq6oosJ6DiRAq5f7h9+af4OJLH dO1ba8A7+uVU4sI8eBnN6eWpliF8KoDQey8NUi1KW2wsbRrYeHVLIwZQMcqCKDGY69 IYFLEo1JiULDQ== 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 1sea5E-003xld-5h; Thu, 15 Aug 2024 14:00:04 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: [PATCH 08/11] KVM: arm64: Conditionnaly enable FEAT_LS64* instructions Date: Thu, 15 Aug 2024 13:59:56 +0100 Message-Id: <20240815125959.2097734-9-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815125959.2097734-1-maz@kernel.org> References: <20240815125959.2097734-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.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-20240815_060008_359620_9CB4DB42 X-CRM114-Status: UNSURE ( 9.98 ) 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 Enable the FEAT_LS64* features by setting the corresponding HCRX_EL2 bits in the vcpu context when these features are exposed to the guest. The effective value programmed into the HW will change depending on what a NV guest will program in its own HCRX_EL2 view. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/sys_regs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 39c2ee15dc0a..cfd1a1bb9675 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -4570,6 +4570,15 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu) if (kvm_has_feat(kvm, ID_AA64MMFR3_EL1, TCRX, IMP)) vcpu->arch.hcrx_el2 |= HCRX_EL2_TCR2En; + + if (kvm_has_feat(kvm, ID_AA64ISAR1_EL1, LS64, LS64_V)) + vcpu->arch.hcrx_el2 |= HCRX_EL2_EnASR; + + if (kvm_has_feat(kvm, ID_AA64ISAR1_EL1, LS64, LS64)) + vcpu->arch.hcrx_el2 |= HCRX_EL2_EnALS; + + if (kvm_has_feat(kvm, ID_AA64ISAR1_EL1, LS64, LS64_ACCDATA)) + vcpu->arch.hcrx_el2 |= HCRX_EL2_EnAS0; } if (test_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, &kvm->arch.flags))