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 6A13AC4450A for ; Thu, 16 Jul 2026 09:37:38 +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=EPFwJ3WEuBcm2rx9cZEvteDwo2+iijOpn/63IcGELo4=; b=mV0fbLxyU6B0VTo3rJ5HNX2lpD c42ZcAc6jz4w5nfnR9/ybfPd/IPB39ILbaU79sjSKz3qa+OI1YPlQjdxDUxFcA+lJIBh0uwENf7qr +WNy0SP1mgGpfHHJ50QZgjSTGGS2kWRBpRTLmHn1Hv2ym0oucY+qPKGUjIwBX9vKlYpixn9U3BWLA 8AiGXz1eFjN+rOD2lFqgEV10/hGfJj1WLUVYkvbEW5apuk2v7whE9OgukN3lFrZ2VO3ISRxgIBiRY vdzSxDEEWopBm7wIWaUAGVGpRi0LJw0PDIyq1gNxnY6cDJItqkl8wAtsUZshfDin8MfvLhuSXnao/ hDC7gJzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wkIX6-0000000Gtsy-1YFd; Thu, 16 Jul 2026 09:37:32 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wkIX4-0000000Gtsg-3k03 for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2026 09:37:31 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 5605C60054; Thu, 16 Jul 2026 09:37:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 000121F000E9; Thu, 16 Jul 2026 09:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784194650; bh=EPFwJ3WEuBcm2rx9cZEvteDwo2+iijOpn/63IcGELo4=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=bLOfCpshJI9arPQk13D/3FzzjPN5KW7Lwe2sFGx9PbCCHlW5Nwh+GGSY1Y8/Vz+f/ /aWunZGjzog0ejKw+sqk4c7Da/L/uOGrjrJKvnzNItOUdk3U7WAB0zSw2AD1q0IBu6 s2Zr2R6l3yo9DPObKM5TmY18oKkz8dp3xEM/w3QK8V0Pw2I4ccPA4gtSHmnzXOzvoI 0hZlaif37EuuKP/s4boMscRXhDaFJYMVCordJwTO2dLdiUaCTXoC9YUCE3bM83zM3S 7MAlPtOKNqvPzT6t7jJf3NHdxPAmk0W8SMTiREEDaU/MzyiXlpVVDFSpn/u5v+dp2m OMeccACFs6rYA== 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 1wkIX1-00000005ccs-1RQq; Thu, 16 Jul 2026 09:37:27 +0000 Date: Thu, 16 Jul 2026 10:37:21 +0100 Message-ID: <86fr1jff72.wl-maz@kernel.org> From: Marc Zyngier To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Catalin Marinas , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo Pieralisi Subject: Re: [PATCH v15 09/37] KVM: arm64: CCA: Allow passing the machine type in KVM creation In-Reply-To: <9eb4e4c0-f1f6-4ab9-956a-0b233d1656c9@arm.com> References: <20260715142841.80544-1-steven.price@arm.com> <20260715142841.80544-10-steven.price@arm.com> <87zezs44cf.wl-maz@kernel.org> <9eb4e4c0-f1f6-4ab9-956a-0b233d1656c9@arm.com> 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: steven.price@arm.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, joey.gouly@arm.com, alexandru.elisei@arm.com, christoffer.dall@arm.com, tabba@google.com, linux-coco@lists.linux.dev, gankulkarni@os.amperecomputing.com, gshan@redhat.com, sdonthineni@nvidia.com, alpergun@google.com, aneesh.kumar@kernel.org, fj0570is@fujitsu.com, vannapurve@google.com, WeiLin.Chang@arm.com, lpieralisi@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-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, 16 Jul 2026 10:17:21 +0100, Steven Price wrote: > > On 15/07/2026 17:14, Marc Zyngier wrote: > > On Wed, 15 Jul 2026 15:28:11 +0100, > > Steven Price wrote: > >> > >> Previously machine type was used purely for specifying the physical > >> address size of the guest. Reserve the higher bits to specify an ARM > >> specific machine type and declare a new type 'KVM_VM_TYPE_ARM_REALM' > >> used to create a realm guest. > >> > >> Signed-off-by: Steven Price > >> --- > >> Changes since v13: > >> * Rework to use the two top bits for the machine type now that pKVM has > >> merged and used the top bit for KVM_VM_TYPE_ARM_PROTECTED. > >> * Update the documentation to include KVM_VM_TYPE_ARM_PROTECTED as > >> well. > >> Changes since v9: > >> * Explictly set realm.state to REALM_STATE_NONE rather than rely on the > >> zeroing of the structure. > >> Changes since v7: > >> * Add some documentation explaining the new machine type. > >> Changes since v6: > >> * Make the check for kvm_rme_is_available more visible and report an > >> error code of -EPERM (instead of -EINVAL) to make it explicit that > >> the kernel supports RME, but the platform doesn't. > >> --- > >> Documentation/virt/kvm/api.rst | 18 ++++++++++++++++-- > >> arch/arm64/kvm/arm.c | 11 +++++++++++ > >> include/uapi/linux/kvm.h | 7 ++++++- > >> 3 files changed, 33 insertions(+), 3 deletions(-) > >> > >> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > >> index b38e090ad95d..e39d146b34a3 100644 > >> --- a/Documentation/virt/kvm/api.rst > >> +++ b/Documentation/virt/kvm/api.rst > >> @@ -181,8 +181,22 @@ flag KVM_VM_MIPS_VZ. > >> ARM64: > >> ^^^^^^ > >> > >> -On arm64, the physical address size for a VM (IPA Size limit) is limited > >> -to 40bits by default. The limit can be configured if the host supports the > >> +On arm64, the machine type identifier is used to encode a type and the > >> +physical address size for the VM. The lower byte (bits[7-0]) encode the > >> +address size and the upper bits[30-31] encode a machine type. The machine > >> +types that might be available are: > >> + > >> + ========================= ============================================ > >> + KVM_VM_TYPE_ARM_NORMAL A standard VM > >> + KVM_VM_TYPE_ARM_REALM A "Realm" VM using the Arm Confidential > >> + Compute extensions, the VM's memory is > >> + protected from the host. > >> + KVM_VM_TYPE_ARM_PROTECTED A "protected" VM using pKVM to isolate the > >> + VM from the host. > >> + ========================= ============================================ > >> + > > > > Probably worth mentioning that REALM+PROTECTED is an illegal > > combination. > > The original intention was that these were enum values not separate bit > fields. Having to adapt to the pKVM changes when they were merged has > somewhat messed this up. I'll add a clarification, but hopefully we > haven't actually burnt the combination in case we have a 4th type in the > future. A good way to avoid ambiguity would be to list the actual values for the [31:30] field (0b00, 0b01, 0b10). Thanks, M. -- Without deviation from the norm, progress is not possible.