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 54A0ECF8875 for ; Thu, 20 Nov 2025 16:18:47 +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: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0/ylRgxqtv6nFFpvQc5tMPN+5wIjd6mjqxea02uzRrc=; b=M54yqv1NS+JormJu9NqGDLpJEj ez1TncbnRln+ClVRL7j8X1NMfsX6ZWuc8qKE4jHsV+/CphRUlR+3EI4gNBfh5GGBTHRbx57UMCpt5 5yNlHmKiiV/0ydDKUNWRPmyqgHi0tKaBlERbdZdvHwHtWfqXaOuPh2s67xcyR7jW5VWG2OOR+71GW Yg5TlB5Jr2h4ZbilAPsE5SrarSyc0HMMMwcDreHHjKgoub3tKb0WaF/7Wu2UVqHP7e9eBPhk66exr k/yx1fnP3ufs/62/RIRBZ+RL57USQDL90C7sUMHHwDJcVntVT0xi17T+8tZ7ROcvsU4mSRlSdM1a8 TXr/ozBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vM7Mo-00000006zdX-10hY; Thu, 20 Nov 2025 16:18:42 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vM7Mn-00000006zcw-0Cwh for linux-arm-kernel@lists.infradead.org; Thu, 20 Nov 2025 16:18:41 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 7DA506018B; Thu, 20 Nov 2025 16:18:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3344DC4CEF1; Thu, 20 Nov 2025 16:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763655520; bh=KwZ0JhnSDCNZyZyVN2OkoVg0lxuvRbqfuZ3B6h7NGRg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MCG19c7vrB14C6fJ+JhzzKXYDKpEsqcAEaaJONS7bVM706UHdAmzQmi6Cb3od5awI WRw4jQH663YReAPOCN1shTzYGWuEan0maY0zVHg6X/AOE2k2rsI+HfYDQPXjzSeRiF Fk/rAuUySTn8H38h+yJEmVTMzrTXBnsd87zsW6g9B3TH1wnn6ArRc/6IMorry3cgcE huPOZdYkq4T25oR8OUMHtrj2mYVkT4mkiajE72ylz7TjVCyaj0NIGpT8qytz4rbiVp yh/jzx84pAzuxwooUxaP6B8h3FuX8fzsJfj8SGgtCE8VkS5brlkFCuk/TjKVlsewCt X0FVYGbc88fzw== 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 1vM7Mj-00000006wt3-47F0; Thu, 20 Nov 2025 16:18:38 +0000 Date: Thu, 20 Nov 2025 16:18:37 +0000 Message-ID: <864iqosmn6.wl-maz@kernel.org> From: Marc Zyngier To: Maximilian Dittgen Cc: , , , , , , , , , Subject: Re: [RFC PATCH 01/13] KVM: Introduce config option for per-vCPU vLPI enablement In-Reply-To: <20251120140305.63515-2-mdittgen@amazon.de> References: <20251120140305.63515-1-mdittgen@amazon.de> <20251120140305.63515-2-mdittgen@amazon.de> 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=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mdittgen@amazon.de, oliver.upton@linux.dev, pbonzini@redhat.com, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, lilitj@amazon.de, sauravsc@amazon.de, nh-open-source@amazon.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 Thu, 20 Nov 2025 14:02:50 +0000, Maximilian Dittgen wrote: >=20 > Add CONFIG_ARM_GIC_V3_PER_VCPU_VLPI to control whether vLPI direct > injection is to be enabled on a system-wide or a per-vCPU basis. >=20 > When enabled, vPEs can be allocated/deallocated to vCPUs on an ad-hoc, > per-vCPU basis in runtime. When disabled, keep current vgic_v4_init > behavior of automatic vCPU vPE allocation upon VM initialization. >=20 > We declare three ioctls numbers to manage per-vCPU vLPI enablement: > - KVM_ENABLE_VCPU_VLPI, which given a vCPU ID, allocates a vPE and > initializes the vCPU for receiving direct vLPI interrupts. > - KVM_DISABLE_VCPU_VLPI, which given a vCPU ID, disables the vCPU=E2=80= =99s > ability to receive direct vLPI interrupts and frees its underlying vPE > structure. > - KVM_QUERY_VCPU_VLPI, which given a vCPU ID, returns a boolean > describing whether the vCPU is configured to receive direct vLPI > interrupts. >=20 > This commit declares the kconfig, ioctl numbers, and documentation. > Implementation will come throughout this patch set. >=20 > Signed-off-by: Maximilian Dittgen > --- > Documentation/virt/kvm/api.rst | 56 ++++++++++++++++++++++++++++++++++ > arch/arm64/kvm/arm.c | 15 +++++++++ > arch/arm64/kvm/vgic/vgic-v4.c | 9 ++++++ > arch/arm64/kvm/vgic/vgic.h | 2 ++ > drivers/irqchip/Kconfig | 13 ++++++++ > include/uapi/linux/kvm.h | 6 ++++ > 6 files changed, 101 insertions(+) >=20 > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.= rst > index 27f726ff8fe0..dcfb326dff10 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -6517,6 +6517,62 @@ the capability to be present. > =20 > `flags` must currently be zero. > =20 > +4.XXX KVM_ENABLE_VCPU_VLPI > +-------------------------- > + > +:Capability: KVM_CAP_ARM_PER_VCPU_VLPI > +:Architectures: arm64 > +:Type: vm ioctl > +:Parameters: int vcpu_id (in) > +:Returns: 0 on success, negative value on error > + > +This ioctl enables GICv4 direct vLPI injection for the specified vCPU. > +Allocates vPE structures (doorbell IRQ, vPE table entry, virtual pending > +table, vPEID) and upgrades existing software-forwarded LPIs targeting > +this vCPU to hardware-forwarded vLPIs. > + > +If GICv4.1 is supported and vSGIs are disabled on the specified vCPU, > +this ioctl enables vCPU vSGI support. > + > +Requires CONFIG_ARM_GIC_V3_PER_VCPU_VLPI and GICv4 hardware support. > + > +Returns -EINVAL if vGICv4 is not initialized or if the passed vcpu_id > +does not map to a vCPU. > + > +4.XXX KVM_DISABLE_VCPU_VLPI > +--------------------------- > + > +:Capability: KVM_CAP_ARM_PER_VCPU_VLPI > +:Architectures: arm64 > +:Type: vm ioctl > +:Parameters: int vcpu_id (in) > +:Returns: 0 on success, negative value on error > + > +This ioctl disables GICv4 direct vLPI injection for the specified vCPU. > +Downgrades hardware-forwarded vLPIs to software-forwarded LPIs and frees > +vPE structures. Pending interrupts in the virtual pending table may be > +lost. I'm going to put my foot down on that immediately. There is no conceivable case where losing interrupts in acceptable. Ever. If that's what you want, please write your own hypervisor. I wish you luck! > + > +If vSGIs are enabled on the specified vCPU, this ioctl disables them. So what? Something that didn't have an active state now has one that the guest doesn't know about? There is exactly *one* bit that defines that, and it doesn't exist in some quantum superposition. This whole thing is completely insane, has not been thought out at all, is ignoring the basis of the architecture, and I'm really sorry that you wasted your time on that. M. --=20 Without deviation from the norm, progress is not possible.