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 BEFA3C001DE for ; Mon, 31 Jul 2023 17:03:23 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vg0Pnj14cuXiEw0/LONYfbTklTUcUa9rcAFvwbJ40/o=; b=i7RdZ1Sybl5tGr OM1kojxiL7jG03LBww7qW5R0c2qp34rRj6lMcfaZhzi0UkcJYCmR+bTQEBZaVygp/A6trVN8Q3Ckh a035y3hPHtV+Kk+T++eSByh7T+Np4V8wbHp3/W5z39o05XKPRcTk1pxpluSLEhcfu7jBZQeRv8aHI hxMtRSdNgoiNd02c33/ja5AKLIOxf+6HmCPnfEgsU3mZQt0pR2VI3aldl/CZqEViEgkUIobWuvgfC JSHDyrV7UawqbzMRcKyM4wB3vpjOVqNoDlGh+OBIW3O49Kn+D5tSlz0cAdQFlLpo6v8t3B9dWbmrA AKq1Fo76y4L7MVYYIyog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQWIP-00Gjlj-0z; Mon, 31 Jul 2023 17:03:01 +0000 Received: from out-88.mta1.migadu.com ([2001:41d0:203:375::58]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQWIL-00Gjkr-2k for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2023 17:03:00 +0000 Date: Mon, 31 Jul 2023 10:02:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690822973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=q4aDTEIrJywenjhfbG8yboiQILyqizo5vlKZ1bSMxlk=; b=gGEekKkQTDUSJrfZjaiI5kxTm4QtmjLE9qRIi8zD74QBW08ItkmnOBzN9t9TYgvhxW2vdd MQy6dVizpNWkbduvGm4ht1x9B9O12x4NLAALd8jhm0BDdErG38hyDDR4ttw4boCOxtm7ZK nZTAuEWk2big1Lmd3mXwrUZt7iiRFlE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Eric Auger , Mark Brown , Mark Rutland , Will Deacon , Alexandru Elisei , Andre Przywara , Chase Conklin , Ganapatrao Kulkarni , Darren Hart , Miguel Luis , James Morse , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH v2 14/26] KVM: arm64: nv: Add trap forwarding infrastructure Message-ID: References: <20230728082952.959212-1-maz@kernel.org> <20230728082952.959212-15-maz@kernel.org> <87fs57qdm2.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87fs57qdm2.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230731_100258_664565_0A966CF9 X-CRM114-Status: GOOD ( 27.82 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Jul 29, 2023 at 10:19:17AM +0100, Marc Zyngier wrote: > On Fri, 28 Jul 2023 19:33:31 +0100, > Oliver Upton wrote: > > Correct me if I'm wrong, but I don't think the compiler is going to > > whine if any of these bitfields are initialized with a larger value than > > can be represented... Do you think some BUILD_BUG_ON() is in order to > > ensure that trap_group fits in ::cgt? > > > > BUILD_BUG_ON(__NR_TRAP_IDS__ >= BIT(10)); > > Indeed. This might also apply to ::fgt, and I want to add some sanity > checks to verify that the whole union isn't larger than a 'void *', as > we rely on that. Agreed on both. > > > +/* > > > + * Map encoding to trap bits for exception reported with EC=0x18. > > > + * These must only be evaluated when running a nested hypervisor, but > > > + * that the current context is not a hypervisor context. When the > > > + * trapped access matches one of the trap controls, the exception is > > > + * re-injected in the nested hypervisor. > > > + */ > > > +static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = { > > > +}; > > > + > > > +static DEFINE_XARRAY(sr_forward_xa); > > > + > > > +static union trap_config get_trap_config(u32 sysreg) > > > +{ > > > + return (union trap_config) { > > > + .val = xa_to_value(xa_load(&sr_forward_xa, sysreg)), > > > + }; > > > > Should we be checking for NULL here? AFAICT, the use of sentinel values > > in the trap_group enum would effectively guarantee each trap_config has > > a nonzero value. > > if xa_load() returns NULL, xa_to_value() will still give us a 0, which > is an indication of a sysreg that isn't present in the trap > configuration. This can happen if we trap something that isn't yet > supported in NV, which is quite common. This allows us to use features > on the host without having to immediately write the same support for > NV guests. That's fine by me, I couldn't piece it together where a value of 0 is explicitly handled as having no trap config. > But this is obviously a temporary situation. At some point, I'll > become a total bastard and demand that people treat NV as a first > class citizen. One day ;-). No time like the present! -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel