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 B6C3F10ED67C for ; Fri, 27 Mar 2026 14:02:37 +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: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kn4eTQTRzLwG0LAqn8ir8kpNKnolwu7hPcdScE71Odo=; b=KkBoXYusMWHa5O41zchElnND2D JyurLLPgQ3uFqDWwMR1Q8HRFVIyeLD/SmZSu/Mk1xR4ddVN9sxqsNBI9+ibEQYiB8v5ulT6NdtUsF eSbCCSQQ0FmLGsbCVyZvGcbTOMu0y6uDcTDt2PTkpZZMjZDpQSbDnDW1H20D8KDVrJmBM/bnkZzl9 0ElrK/73ZEOA/KrOAIgUpKNQX0XLrafT6lpgQl/D5QQotlRIvNAbIojhToYqGGoxqWhy5MZhs1/5j 0qtzcvDTJrd43+hyl5yivdzStkzMxPjeHeJj9oYyGEx+ethJwIjrOlU7lXRG/6+XcjiFUwVee/FXl H0ZummfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w67lb-00000007Wa4-3qXC; Fri, 27 Mar 2026 14:02:27 +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 1w67lH-00000007WLV-2O3W for linux-arm-kernel@lists.infradead.org; Fri, 27 Mar 2026 14:02:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 027B760133; Fri, 27 Mar 2026 14:02:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3704C19423; Fri, 27 Mar 2026 14:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774620126; bh=SDMGafRUVGGCgrJPxBIvZuvVZsCaeXEC2Q2rHPwapCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lb3b3cl/R9xTQP4n1HtBB9/qX8rGUhsOZ38btyRqV+5HFIiLVgerrSp2LL2UsFguT vvXeMx46dVt0gLj77sKK4V2hFvwG5HyTCKP2T5GL2Z5WeI9lWe6OsrVvVIL1c9ARlg nBv3rOSqP6T09pV+RWZoHdZFS4FCp08Z18NIWZnvcejNwY5ZLjkDrFI16B7w89Dkgh 89A5419BA4zTZNORybyLZfNk8WqJVOnkAYWTn0CNL0NOdJGZfAhQFI/keIyxc7i3J8 KpzlPXNC/2PWhkcwkX+5n3AcPm3VkWX7r8qUcwVuZt8kQXO4QyfbMFJd/f6k7w9/uk GJodAnjVd5dYg== From: Will Deacon To: kvmarm@lists.linux.dev Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Quentin Perret , Fuad Tabba , Vincent Donnefort , Mostafa Saleh , Alexandru Elisei Subject: [PATCH v4 23/38] KVM: arm64: Change 'pkvm_handle_t' to u16 Date: Fri, 27 Mar 2026 14:00:22 +0000 Message-ID: <20260327140039.21228-24-will@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260327140039.21228-1-will@kernel.org> References: <20260327140039.21228-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 'pkvm_handle_t' doesn't need to be a 32-bit type and subsequent patches will rely on it being no more than 16 bits so that it can be encoded into a pte annotation. Change 'pkvm_handle_t' to a u16 and add a compile-type check that the maximum handle fits into the reduced type. Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Tested-by: Mostafa Saleh Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/kvm/hyp/nvhe/pkvm.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 31b9454bb74d..0c5e7ce5f187 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -247,7 +247,7 @@ struct kvm_smccc_features { unsigned long vendor_hyp_bmap_2; /* Function numbers 64-127 */ }; -typedef unsigned int pkvm_handle_t; +typedef u16 pkvm_handle_t; struct kvm_protected_vm { pkvm_handle_t handle; diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index a2d45f4b0cf6..a7253a884163 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -222,6 +222,7 @@ static struct pkvm_hyp_vm **vm_table; void pkvm_hyp_vm_table_init(void *tbl) { + BUILD_BUG_ON((u64)HANDLE_OFFSET + KVM_MAX_PVMS > (pkvm_handle_t)-1); WARN_ON(vm_table); vm_table = tbl; } -- 2.53.0.1018.g2bb0e51243-goog