From patchwork Tue Aug 20 10:03:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13769830 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 C82EAC5320E for ; Tue, 20 Aug 2024 10:11:14 +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=zInLeaZl/ooyKZ5v/AvYBI0xr+OUQrwFcP5mIc3uiMY=; b=g+3bAagUrPphpoXvCyIl7hbN9T NP7H17AhWVjoLzMAKvcvOnNSVOAB7sJFVp/Bh1RqHzL8gRN2gPDJjlUOrjx/LutD+9/5SD2fGhiVu zyMh5dif3K7MVfqGvn/jluIzNpdF17QGcE394ExqSW9k6orXk9GLxCVqt3qc1Z4D9gdn+TYDd6qwl hkuSYhIOUX8qEYCgmy3gBQSOdEGtPiGOQnKN5/PBhyDP7lcgPc8pDROqbZrIxczrJxqWXVLVj/oz+ C2RcH/LNHG6omzAjXKIVgrfaX1PyuAAzCiPIMazV/lUDN8bfUqSzvNAsYhRQ9lxTD2uwU3qi25VNu XrGq/VBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgLpP-00000004jmN-1MKN; Tue, 20 Aug 2024 10:11:03 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgLkq-00000004iMl-1hqT for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Aug 2024 10:06:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=zInLeaZl/ooyKZ5v/AvYBI0xr+OUQrwFcP5mIc3uiMY=; b=Aq71xxbwY+1TWYBHSmVKIoKrq4 STwf8kNYo4IRF54+bTxDt3gmMdB+mmqdJ0E1n4VlAMnjwvpeXMGYtVqO4GE7dEsU9Lz3pLMCO+GIS qQWWf7qIGz7OWIqPAvoWoFu8jdxCN95Ih8jhspxVt9sKdXWYxOIl4d1AvaMtnGKt4y/fGvw8UCIDm QqyE93+kUs/5Ii+q+Mn7SQNaIxdKgpP6/taTI6fgywPuNuHqImv2YhTdajBpqcPE8ks9FDM5W4f4O XRaJVp1DQRj1FomOTr4KXK9c88U2FrUzs3zyc1qUFbwROOfymnSblH8vKaD3r38ejO7tEjYmFekP7 mD/aPaPg==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgLkn-00000009JIS-1pgc for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 10:06:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4002D60DF6; Tue, 20 Aug 2024 10:06:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E6CDC4AF09; Tue, 20 Aug 2024 10:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724148374; bh=E/nM2POA+NHfwljXrvdH/h3sCeH2WrlMJBrRxe2DE3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvLW+venMugjBN9tE9/DVQaHmIKVBdRPqOvldK1YfJfy+l4W/U4TFGDGL8S/cHK1E 5A+aTOX405kRoeL+xYLuVhmJQucnNyTa1+Z2l95BB98Tyd8XFPQVgisV202C6A4O1N rXi/acM8WkXGEjHAEmcNSIVEjH7o3G2321oa+ZESDvgOkB9Wjp/z/S7kp6Bl5g8mxM 43FetMu3l98hjdjE4CpPq5SbYosLhYslPFd+KGdMbu2YgHaWnfLHOyLBfKzpmarWCt Tx/IbWoY4DdeU0O0QVWDZtl1ZWiRAPNnVmQB4d62wnrHkWW7mLRpppZjDFZchWKBFA W1R/ZYQvUhBjQ== 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 1sgLki-005Dk2-3i; Tue, 20 Aug 2024 11:06:12 +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 , Alexander Potapenko Subject: [PATCH 06/12] KVM: arm64: Zero ID_AA64PFR0_EL1.GIC when no GICv3 is presented to the guest Date: Tue, 20 Aug 2024 11:03:43 +0100 Message-Id: <20240820100349.3544850-7-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240820100349.3544850-1-maz@kernel.org> References: <20240820100349.3544850-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, glider@google.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-20240820_110617_720683_B53B7F30 X-CRM114-Status: GOOD ( 12.07 ) 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 In order to be consistent, we shouldn't advertise a GICv3 when none is actually usable by the guest. Wipe the feature when these conditions apply, and allow the field to be written from userspace. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/sys_regs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index bc2d54da3827..7d00d7e359e1 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2365,7 +2365,6 @@ static const struct sys_reg_desc sys_reg_descs[] = { ID_AA64PFR0_EL1_MPAM | ID_AA64PFR0_EL1_SVE | ID_AA64PFR0_EL1_RAS | - ID_AA64PFR0_EL1_GIC | ID_AA64PFR0_EL1_AdvSIMD | ID_AA64PFR0_EL1_FP), }, ID_SANITISED(ID_AA64PFR1_EL1), @@ -4634,6 +4633,11 @@ int kvm_finalize_sys_regs(struct kvm_vcpu *vcpu) guard(mutex)(&kvm->arch.config_lock); + if (!kvm_has_gicv3(kvm)) { + kvm->arch.id_regs[IDREG_IDX(SYS_ID_AA64PFR0_EL1)] &= ~ID_AA64PFR0_EL1_GIC_MASK; + kvm->arch.id_regs[IDREG_IDX(SYS_ID_PFR1_EL1)] &= ~ID_PFR1_EL1_GIC_MASK; + } + if (vcpu_has_nv(vcpu)) { int ret = kvm_init_nv_sysregs(kvm); if (ret)