From mboxrd@z Thu Jan 1 00:00:00 1970 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 BA1ECC7115B for ; Mon, 23 Jun 2025 18:08:03 +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-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MQdvVTKpzNkLTZybZns+H2aWruuVgE9rlHzV6MJBbOk=; b=WrC/GfuqoOSm2EbCEVUEwYg9ZJ 5+sBF5G7i+XCf2E4svfTE6QM5iXF8mi59MnkQZneGM2vkOj5IiooNiTZGrOtJw+vUADWOkSKeclo6 xbDDjh7Gu3Gokja57E6g4twa/Wu+mz3Ku0NrzHzAXiXXZUulB7nbNQ4s1ltJJqejh29OZEi7yUt3+ rUhv/S11KhuKN9ZC57WC5Eb2XE3bmJNENqtj0rqLLTuBYM/92nzGIvSAxYpQUQTY9rUHaWox5ez5h WOGxRwHZMs4zi650UWIJyRCmvUZnKOwZPDzvoiCn03Of2rbitm7gxdYSbfQsRBC2YxwORxbXwEnQ8 v+KcUXDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uTlaH-00000003e12-2BQA; Mon, 23 Jun 2025 18:07:57 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uTiIp-000000034wF-2UlG for linux-arm-kernel@lists.infradead.org; Mon, 23 Jun 2025 14:37:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7D0505C5C52; Mon, 23 Jun 2025 14:35:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2F0AC4CEEA; Mon, 23 Jun 2025 14:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750689462; bh=LkXLA8jsAZ04YeCznvkOb8RamvDKLqS/ZHmbnRhwhQk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Niq4LtXjHbHUjFfDP3moHzC6rmL9DvzHA9l14hHgXw1W3QEyGBfVqs4grTOUCBiVM AFXW1j6vnMOeJl/W9lOAUkyGixW4NYRu8oKnb8+EVrKsaStr0qz5Uebsi+S7E7Dxt0 s9YycwCBlWTosGNlGb85BxP4KA5RZLgYxrbbxcrwDq1OcnTV3zjyz7cD9y6+huKxXJ MYdqaavAgh4uPBQdTd7hTKcPJVcd926U4u6deLBtVlgpZj6k0jaYF+1pjzg3d4mpOg 5uJ/jxAgD8WcfqSCQXT2F3N/vbIslu8c8yRJfOUCH/U0HBDAzfa/wrd/W//cgjT8mL 9xEtBkweg+MhA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uTiIm-009EAI-8S; Mon, 23 Jun 2025 15:37:40 +0100 Date: Mon, 23 Jun 2025 15:37:39 +0100 Message-ID: <865xgmcymk.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: Raghavendra Rao Ananta , Mingwei Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v3 3/4] KVM: arm64: Introduce attribute to control GICD_TYPER2.nASSGIcap In-Reply-To: References: <20250613155239.2029059-1-rananta@google.com> <20250613155239.2029059-4-rananta@google.com> <87frftfpg7.wl-maz@kernel.org> <868qliddzt.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, rananta@google.com, mizhang@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org 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-20250623_073743_715419_49CA6A8A X-CRM114-Status: GOOD ( 37.90 ) 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 On Mon, 23 Jun 2025 10:25:53 +0100, Oliver Upton wrote: > > On Mon, Jun 23, 2025 at 10:05:42AM +0100, Marc Zyngier wrote: > > On Mon, 23 Jun 2025 09:40:46 +0100, > > Oliver Upton wrote: > > > > > > On Sat, Jun 21, 2025 at 09:50:48AM +0100, Marc Zyngier wrote: > > > > On Fri, 13 Jun 2025 16:52:37 +0100, Raghavendra Rao Ananta wrote: > > > > > @@ -683,8 +714,14 @@ static int vgic_v3_has_attr(struct kvm_device *dev, > > > > > return 0; > > > > > case KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES: > > > > > return 0; > > > > > + default: > > > > > + return -ENXIO; > > > > > } > > > > > + case KVM_DEV_ARM_VGIC_GRP_FEATURES: > > > > > + return attr->attr != KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap ? > > > > > + -ENXIO : 0; > > > > > > > > Do we really want to advertise KVM_DEV_ARM_VGIC_FEATURE_nASSGIcap even > > > > when we don't have GICv4.1? This seems rather odd. My take on this API > > > > is that this should report whether the feature is configurable, making > > > > it backward compatible with older versions of KVM. > > > > > > So this was because of me, as I wanted nASSGIcap to behave exactly like > > > the ID registers. I do think exposing the capability unconditionally is > > > useful, as otherwise there's no way to definitively say whether or not > > > the underlying platform supports GICv4.1. > > > > > > KVM_HAS_DEVICE_ATTR can't be used alone for probing since old kernels > > > use GICv4.1 but don't expose the attribute. > > > > > > Does that make sense? > > > > My own reasoning is that if we expose the capability, userspace is > > able to use it and rely on it to take effect (VPE allocation error > > notwithstanding). This is not the case with this approach, and that's > > at odds with the other attributes. > > > > But taking a step back: if we want to control the nASSGIcap bit, why > > don't we allow writing to GICD_TYPER2 from userspace? This does > > matches your view that we treat it as an ID register (GICD_TYPER2 > > matches this definition if you squint hard enough). It also avoids > > adding new UAPI with unusual semantics. > > This approach would bring its own set of complications. At least right > now we allocate vPEs at vgic_init() but prevent register accesses prior > to initialization. If we want to bake this thing into GICD_TYPER2 > directly we either need to relax this register to be accessed before > init or defer the vPE allocation later on. > > I'm worried that the latter approach is gonna be a mess, and the > attribute was done to avoid a one-off accessor in the VGIC state. But if > you'd like to see it done that way then that's OK with me. I'm not convinced we need to change much. For example, we already allow userspace writes to GICD_IIDR to set the version of the emulation prior to vgic_init(). It doesn't feel like allowing TYPER2 writes to occur in a similar spot require anything invasive. Thanks, M. -- Without deviation from the norm, progress is not possible.