From nobody Thu Feb 12 19:04:32 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21A80143757; Mon, 10 Jun 2024 13:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718026976; cv=none; b=dk8+NuNAHFeeo7A401aNlkzOW+LLd+7nFXG5t+Vv37ZMceMVVyOGj2eSxayojekX61/4KIIFRoxm2iWfD5tqgb6VDWabW0zkc5NhmAX9x1WemoSKQCcTgyIOvmhspIaNAy1HY/24NGo26o/9kpn9H3sFRgFIkdvQUuAPsUTBRsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718026976; c=relaxed/simple; bh=bUtos3wotb6J2jLgnXLV6GApw7NcI4hb5kbg5+76I/c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q6/CcjjUVxMlpbbyio6yH+GSIDHXw6s1umqHxpZ1R0qrv5rAYxFM/vnHwZvVDU4tNo65TqhmoiTO2olzax1SIrygrqjkq11tj746qGJOAlNzqde1wIk+GmqTOL+h7bDJzFqvAnoKGZPZ/nF40NUppGSV10FBDMCUX2t7OmR0yOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 230BB169C; Mon, 10 Jun 2024 06:43:19 -0700 (PDT) Received: from e122027.cambridge.arm.com (e122027.cambridge.arm.com [10.1.35.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4348B3F58B; Mon, 10 Jun 2024 06:42:51 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , 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 , Steven Price Subject: [PATCH v3 10/43] kvm: arm64: Expose debug HW register numbers for Realm Date: Mon, 10 Jun 2024 14:41:29 +0100 Message-Id: <20240610134202.54893-11-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610134202.54893-1-steven.price@arm.com> References: <20240610134202.54893-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Suzuki K Poulose Expose VM specific Debug HW register numbers. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price --- arch/arm64/kvm/arm.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index d3cdc775d001..c37b563d1d66 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -68,6 +68,22 @@ bool is_kvm_arm_initialised(void) return kvm_arm_initialised; } =20 +static u32 kvm_arm_get_num_brps(struct kvm *kvm) +{ + if (!kvm || !kvm_is_realm(kvm)) + return get_num_brps(); + /* Realm guest is not debuggable. */ + return 0; +} + +static u32 kvm_arm_get_num_wrps(struct kvm *kvm) +{ + if (!kvm || !kvm_is_realm(kvm)) + return get_num_wrps(); + /* Realm guest is not debuggable. */ + return 0; +} + int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) { return kvm_vcpu_exiting_guest_mode(vcpu) =3D=3D IN_GUEST_MODE; @@ -336,7 +352,6 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long = ext) case KVM_CAP_ARM_IRQ_LINE_LAYOUT_2: case KVM_CAP_ARM_NISV_TO_USER: case KVM_CAP_ARM_INJECT_EXT_DABT: - case KVM_CAP_SET_GUEST_DEBUG: case KVM_CAP_VCPU_ATTRIBUTES: case KVM_CAP_PTP_KVM: case KVM_CAP_ARM_SYSTEM_SUSPEND: @@ -344,6 +359,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long = ext) case KVM_CAP_COUNTER_OFFSET: r =3D 1; break; + case KVM_CAP_SET_GUEST_DEBUG: + r =3D !kvm_is_realm(kvm); + break; case KVM_CAP_SET_GUEST_DEBUG2: return KVM_GUESTDBG_VALID_MASK; case KVM_CAP_ARM_SET_DEVICE_ADDR: @@ -389,10 +407,10 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, lon= g ext) r =3D cpus_have_final_cap(ARM64_HAS_32BIT_EL1); break; case KVM_CAP_GUEST_DEBUG_HW_BPS: - r =3D get_num_brps(); + r =3D kvm_arm_get_num_brps(kvm); break; case KVM_CAP_GUEST_DEBUG_HW_WPS: - r =3D get_num_wrps(); + r =3D kvm_arm_get_num_wrps(kvm); break; case KVM_CAP_ARM_PMU_V3: r =3D kvm_arm_support_pmu_v3(); --=20 2.34.1