From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B2AF260591; Mon, 23 Jun 2025 14:37:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750689463; cv=none; b=fgKsg7CGQniOhDq3ZB0Nht0gDQJ1JhIkYhF83ebRsfOi1OdNtXi+eGl1X+9RYBIP/rUA542FERd0BPv75AeV2L4RXyWhaOmSq2vKFqXbXYsoVnWuNr3But5dnJRyN10ZmItPrdIPltMK2A34R6MB8NEwc1t96AguOKw12CDkwHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750689463; c=relaxed/simple; bh=LkXLA8jsAZ04YeCznvkOb8RamvDKLqS/ZHmbnRhwhQk=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=r+kos3sD83ZrpdtsNugNPtm3XfUaaH+9h3Y8GTuso92TpYOQlYCzCC6nmyY2YjzoFc8qlzMLF8vWnYhd+jWOUXy73HIrHxNZgEMJ0Ixu40aEEVdZWVJWZOjZGBczjXCb0brIfwiJJxFeeLFmopR2jmrMMVfuVtt6YJ1SRRwtERc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Niq4LtXj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Niq4LtXj" 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) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.