Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp369357lqp; Mon, 10 Jun 2024 06:45:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuuaE4uqX3xziqj4Qvv43bzREESo8qzugfhYUk4/SERYpD3FWxfChigRBd33EfP+sqi5z6pOhNsJIA7LNPsbSlTAWi4n9z+Ip1elqZTA== X-Google-Smtp-Source: AGHT+IFv3xs+9fYOmRXASVCw3ruE0DprrmvBpLZ95dK8Zvtr8r83aPmiFZNU48zqcOsngcuCVH6E X-Received: by 2002:a05:622a:24c:b0:43d:85ae:bf2 with SMTP id d75a77b69052e-44041b66ffbmr92032611cf.21.1718027135201; Mon, 10 Jun 2024 06:45:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718027135; cv=pass; d=google.com; s=arc-20160816; b=zQ1B6M/hdjlA44gosZ25MY3chLXmtvNdXjZ27vNXJu33DDJ5eGmknZjvdSG4J/veno EpqeV+UiJn4M6hPd4RdEEf4hFYc16iGScYJFZp4vMhsw2z3/09iibn75RZ/4omiuyjSd Skwkxy94hfLDYAWaCDyusc1sr628N6gd22z+nwYOK4oyufFXB/1V5u0m92T/XXUGvntT /9aYQJuh5UOyCTk/47bXQ8/p2XO0Nav93tm93mEYapD+u8i6TV6Ew/fTQTFONlmzegn8 xkPxU1KXaGxZSi7F0UcBgn0n6airhdfEah7a79Vsts6ula9QT2gXPHVI+Z1rK40g/8Rk uZIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=voC2e/nRoiJhUJKA24GwZIcVmZ4e3Pm4x+jHyeJ/PLY=; fh=mU6xl5FN63PgqIKyLHx/u5uRervM0V89cYoVjXl22Bs=; b=cp7FNgBVM9ftjbAhQQSzidKNpQKd4bNq2lBv9+TauK0Y8E7Q2kkKwcROWMKxhriut2 F0OyYUUYPcTRmdSelMZGIp0dLutedQbhG5d+Y3n2xLVIJjc7PrfnyoSHMJ2mLL6mwrVO VUsDK8K9h3Lym5nvtio/evnkMCcR4gB/OwfrB5XUE6KhZ13RPcv4ZSYxc2eCvir6w++y Bv9pzbjcEV0CXWKgN/IMrR5zW6QIu7gz0HIwdBzN2GMeF4qf8uPDbKsvP7PwRwsxGuYX cOI3xsbOc28GJqZ+UkAM2Gki4NfsM1VpGQkUjMwH0j3qeJH9WBzbnyvAZoWwid4HdEPY 9l1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-4412056fb0asi7168761cf.45.2024.06.10.06.45.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 06:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E5F381C21F7C for ; Mon, 10 Jun 2024 13:45:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5460143C58; Mon, 10 Jun 2024 13:42:56 +0000 (UTC) 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: 8bit 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; } +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) == 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 = 1; break; + case KVM_CAP_SET_GUEST_DEBUG: + r = !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, long ext) r = cpus_have_final_cap(ARM64_HAS_32BIT_EL1); break; case KVM_CAP_GUEST_DEBUG_HW_BPS: - r = get_num_brps(); + r = kvm_arm_get_num_brps(kvm); break; case KVM_CAP_GUEST_DEBUG_HW_WPS: - r = get_num_wrps(); + r = kvm_arm_get_num_wrps(kvm); break; case KVM_CAP_ARM_PMU_V3: r = kvm_arm_support_pmu_v3(); -- 2.34.1