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 A4D44F419A7 for ; Wed, 15 Apr 2026 13:18:16 +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=RW4T4uGJg0raQ67Umd+DR5lYzITBIU3rOWBEEJiLHw4=; b=rS09Rk52kQhgYJm8HACAJRyPD9 99+iBM93bO4P8KjRHKnihscwoUz6Cfe1WOlv4TeCTBFVEsKyOx0tndjJdkiTCXHPFg9p0JKIeCHRw MqKvCgtQWThbW4y5DN4+xGd8/tMZ+9ehmB2rsCwDQOVKmXUjUXHoYDnXcGycT1IaoE1uTQIEcLXvg YhMM+EQrGdfGOh+Tb6ywjt32Gqvg4LK8CYW2F9+ms1i+cwL5oOaBugkrpZZufZBLB4d5YNd2XjGuY JmDSL0zHXPDOlj6Aq5Q/IFq52FWRMcOfegt0T0EnKxE/gjenkIYVDmASwZW+uPTM6qwTgRJR5vmK5 6svUFzRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wD08B-00000001BBk-02Du; Wed, 15 Apr 2026 13:18:11 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wD089-00000001BBU-1wBi for linux-arm-kernel@lists.infradead.org; Wed, 15 Apr 2026 13:18:09 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 643DD60018; Wed, 15 Apr 2026 13:18:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14A5FC2BCB7; Wed, 15 Apr 2026 13:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776259088; bh=7wyF43cvwqS1HBxQZBnmvqLRYeltHv0EooUbNO/BtCI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qOTMUBGj4NQQWxXSKXswoOXgojLmcnzFA6dA9T8pIYPqGadHGr/Yyj8TRv7AaFljR r7THkp/hYshJ4ag15PE/OpZ8AIrvi6EzPwVk2wLhFZya+FC8h310hIQ55UihLxZUL7 c1AtDVS3YG7Pv7saSM+HSReMjOdBhBqOWhuNlZbpAQ/U6QeP5vq6gv/XLDE5vVheBl 5vSoE9qQn0434sS1Aygqjz7gRjN9GVtHMgUuJgUh75LIoBU4mrtT4MYR91Lpx7omwQ cDdY2FdMYyma6cRn0XvDaHBDl9SAlL9feAG+68dVlnPvYN0AmCwkyqdsNAgNaAgBOb tXUByVTdqy6iA== 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.98.2) (envelope-from ) id 1wD085-0000000BsIb-3JCq; Wed, 15 Apr 2026 13:18:05 +0000 Date: Wed, 15 Apr 2026 14:18:05 +0100 Message-ID: <86bjfk2whe.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Will Deacon , Vincent Donnefort , Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: Re: [PATCH] KVM: arm64: pkvm: Adopt MARKER() to define host hypercall ranges In-Reply-To: References: <20260414160528.2218858-1-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: tabba@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, will@kernel.org, vdonnefort@google.com, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, 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-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 Wed, 15 Apr 2026 10:56:17 +0100, Fuad Tabba wrote: > > Hi Marc, > > On Tue, 14 Apr 2026 at 17:05, Marc Zyngier wrote: > > > > The EL2 code defines ranges of host hypercalls that are either > > enabled at boot-time only, used by [nh]VHE KVM, or reserved to pKVM. > > > > The way these ranges are delineated is error prone, as the enum symbols > > defining the limits are expressed in terms of actual function symbols. > > This means that should a new function be added, special care must be > > taken to also update the limit symbol. > > > > Improve this by reusing the mechanism introduced for the vcpu_sysreg > > enum, which uses a MARKER() macro and some extra trickery to make > > the limit symbol standalone. Crucially, the limit symbol has the > > same value as the *following* symbol. > > > > The handle_host_hcall() function is then updated to make use of > > the new limit definitions and get rid of the brittle default > > upper limit. This allows for some more strict checks at build > > time, and the removal of an comparison at run time. > > This is pretty neat. There is still the issue of a hole, i.e., adding > an enum in the middle but forgetting to add a function, but that is > caught in handle_host_hcall(). I can't think of an easy way to catch > that though (xarray that initializes both?) Yeah, there isn't a simple way to do that at compile-time, unfortunately. One thing that could be done is to have a blanket initialisation with an illegal value, override all the entries you want, and then check at KVM init time for the presence of the canary value. If you find it, abort the KVM initialisation. With that, you can drop the NULL test on the handling path. > > > > Signed-off-by: Marc Zyngier > > Tested-by: Fuad Tabba > Reviewed-by: Fuad Tabba Thanks, M. -- Without deviation from the norm, progress is not possible.