From patchwork Thu Feb 20 13:49:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13983999 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03E1D1FCF72; Thu, 20 Feb 2025 13:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740059356; cv=none; b=eY7Jv+QLxZafVOrvADxs578UF020+nW5qWM4Ov2Pu+Jez8Hrj3rxGz8iqhUW12BtvDBvV2lBXlM2gE1x4EPvAbuVcJYv+6wNniCYxNV6ss3nueJR5XlVlJuWm0rb93fQfRgPtzTx7HIMB1+rAjzOMdM5B4/ShOWvULlYh0TrRKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740059356; c=relaxed/simple; bh=y7O1hHzcPZT/DmHmjE6yXWnVnGZsmfoF2G8xDlrEQ4E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WTlUgr5MXDEwqzXQ91Npli/m7i4kzHO19igSHEqc3L/RCU3wQPUvJsiFzQ2L1IIFJmesfJbtoZsoyiI1BvfkAkVK3qxjf8BUsfk3GL2B0aZGjq/uwcr46l0vvBL8ApXSbha+fshK6IehqCWeWwc2rZ7PDHg/XlAxlMBfldg1teM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kdjD2Y1D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kdjD2Y1D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC42AC4CEE3; Thu, 20 Feb 2025 13:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740059355; bh=y7O1hHzcPZT/DmHmjE6yXWnVnGZsmfoF2G8xDlrEQ4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kdjD2Y1DijYW+oiBI5oGeg35yFJTGjGwYyMyBkOfPQVBFNTdmt/Nw7VhY5vnihvBB A8aboI/hT+/luIJcdmN3AKH+yTWjUd6C870KXVnAWHotJCRfiMAJETaj9pktr09biU NLaS9jBY7DUCmyqHIrk/wjamsvGZKYaCxbJqix+yfgH7ygujycQ1WheusgWkTHTCKx INZmXDSoV5o6ILXdBPDjMpmyMAd8Y7io4lezlhOHmox+7pGVmW+gKs24x9Mj/P2jZc 8NYHfGJlbfNfARwWuFAGN9qKa6iv1lAxawuyluu0CJ7klhDR6TdC0yQqP7jQkkz7UY X9bB0DFkArSRg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tl6vS-006DXp-52; Thu, 20 Feb 2025 13:49:14 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Eric Auger , gankulkarni@os.amperecomputing.com Subject: [PATCH v2 13/14] KVM: arm64: Allow userspace to request KVM_ARM_VCPU_EL2* Date: Thu, 20 Feb 2025 13:49:06 +0000 Message-Id: <20250220134907.554085-14-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250220134907.554085-1-maz@kernel.org> References: <20250220134907.554085-1-maz@kernel.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, eric.auger@redhat.com, gankulkarni@os.amperecomputing.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Since we're (almost) feature complete, let's allow userspace to request KVM_ARM_VCPU_EL2* by bumping KVM_VCPU_MAX_FEATURES up. We also now advertise the features to userspace with new capabilities. It's going to be great... Reviewed-by: Oliver Upton Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/kvm/arm.c | 6 ++++++ include/uapi/linux/kvm.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 3a7ec98ef1238..e6b9a601258fd 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -39,7 +39,7 @@ #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS -#define KVM_VCPU_MAX_FEATURES 7 +#define KVM_VCPU_MAX_FEATURES 9 #define KVM_VCPU_VALID_FEATURES (BIT(KVM_VCPU_MAX_FEATURES) - 1) #define KVM_REQ_SLEEP \ diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 5ea09f13c7bc0..1bc79f9e5b23a 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -359,6 +359,12 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) case KVM_CAP_ARM_EL1_32BIT: r = cpus_have_final_cap(ARM64_HAS_32BIT_EL1); break; + case KVM_CAP_ARM_EL2: + r = cpus_have_final_cap(ARM64_HAS_NESTED_VIRT); + break; + case KVM_CAP_ARM_EL2_E2H0: + r = cpus_have_final_cap(ARM64_HAS_HCR_NV1); + break; case KVM_CAP_GUEST_DEBUG_HW_BPS: r = get_num_brps(); break; diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 45e6d8fca9b99..9a6674f51b8be 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -929,6 +929,8 @@ struct kvm_enable_cap { #define KVM_CAP_PRE_FAULT_MEMORY 236 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_ARM_EL2 239 +#define KVM_CAP_ARM_EL2_E2H0 240 struct kvm_irq_routing_irqchip { __u32 irqchip;