From nobody Mon Feb 9 16:33:20 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5B3A1DEFEC for ; Mon, 6 Jan 2025 14:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736173537; cv=none; b=bSNinElLTYotqi++vDYl1ZjtT0h5X+yeokoZA5I5iqZLSjmpOKpFngYdcFTNDxyLQ0cAo/8MtFM0CL16/yuY95R85OlmNyR0nqX6i1fE5/lTMAXyHoBX+sRp36o8WKC2g+Ih7gY+5Fs4ygLLPE8Prj6tnxnCiVrCGq0W+W080jU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736173537; c=relaxed/simple; bh=basFdqxsucbXYKlHn41Ysfk6IzsWrMLuIbJNEpIJJz4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TXZPDo6FfjPqIT9Gse7phKXP/nUyACYcznPzxK8/dpIrdq1enFGmM7DWJq4ejnims0o+STMuLetltQAvm2Lr+PEQwFSc0tekUQuQREiEIh6FlaiD5O+P/m/akOx6ZFZQ+hSM71MZ5x5T8rIwe/04oqfR1U3hpbyx5CSBA2rnklk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Tgh31NzB; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Tgh31NzB" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43618283d48so104418765e9.1 for ; Mon, 06 Jan 2025 06:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736173534; x=1736778334; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RxHaRwE8K9zHhfXkFI0ar+C1f1f9RJaVIjhqGS2PIW0=; b=Tgh31NzBEhl1B9tCfufQkXFrzTOwboi58J0xs/IGuGWhvs1OtE12ptz/tveXSje5AJ NpwMLWNItAI9ck1PBG+f5MFp7zEatYNAwF0How6BnytZwpMEyCcOlz4q4B8Ylt2A/3te fwOsuoabpBiJfHkcBJy0Ip+teJEgdWGG2G6vg1S8VOQip5/fTax3pOt8joUVopQ4Wy/A BRHHUXThC5c4u7t3ZizX7VJ6YSEez4Pebk37aMtXsxgk3Vvlm5LAWC+UlB0pMDTfjjX4 /hIj1NbbuzbC52qdYQhZXWMMeZt738iZxFAUbzMB64eaC2whUKeiuIhZyii2gy1VvlSt KOTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736173534; x=1736778334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RxHaRwE8K9zHhfXkFI0ar+C1f1f9RJaVIjhqGS2PIW0=; b=mGebElmzlUsz9nJQC9ba3BNXE2pf1JI2lfDqypWo7q7VVPK11/hIOktOVhDZM5MF+Z pwXQ+7qcWndeYG0j812AMgaJCkHknkUV5BNy6uTPUlxXVpOp1lUID8wiFHcxpEwgD4tz DD5iYtEzWKLLvnguqcu6lq5m4RW1Cz4x03Uto9jxrG9GKJEIIYrMQhcsMCaTlAcTPS6g Y+VtI5GPHPrQMiTj2ZWvUTNsuiDJNO1gcsydHI8sKt/9njJPPG9sQBcYSCsxUjymrHWQ AkxvZ3jB8JBcIaYuETEg9jki2UcaZoYzP6o07YvVyQoMGw/J8BtojMx4jHdOEXlC4Syz 5FMQ== X-Forwarded-Encrypted: i=1; AJvYcCVhaSvSMr/eYPIjw88VqNCjYGcxrrCQaJUIr23u3134Kafj4jy6luawydXAJIIr9OKZwYRm13/v7AvJB+k=@vger.kernel.org X-Gm-Message-State: AOJu0YzuvOtvAECY8BoUO3Pd6ropiyX+738aKR0Dc4fcY57+ukT6Mc39 lhmDWJcgwuHr0isbT5vCLMNx9HCZSLsVK3KX9IePoj66QDjGUi30SgLsvBPEKU4= X-Gm-Gg: ASbGncs0imOiFdWHdqAaAWHDGyxtJTeE2x2VYf4FzZ0poJtNhB8ztL+N3QcPuk5bNqY yPZa/Us1HdTkJUB/c0oY78EOTIyQM+w3y93DRgPZj4tNnTl+m6R4njzgncP0apWwNNYnUEwbxIa o27bzFw3E0eAFQLW7T/S005elmaJh+MRmiLqACcFUUep5jKacndfQyBX+a73TygMMsh4u3h8+ZA x13TT1nWk1u0i7/RpeV9ZMLbl8LN5C4BpLxj3ntnUNpPgGGGg01Zdiu X-Google-Smtp-Source: AGHT+IEgYl+0/TPin7WWSmn3OhX4sdnJNx6WPFGc3EzpxEqMLoC40XXnqOZPGdvtsWkfJKcw8cZ2Pw== X-Received: by 2002:a05:600c:46c7:b0:434:a4b3:5ebe with SMTP id 5b1f17b1804b1-43668b5e244mr445600755e9.24.1736173533153; Mon, 06 Jan 2025 06:25:33 -0800 (PST) Received: from pop-os.. ([145.224.66.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4365d116d8fsm577295045e9.17.2025.01.06.06.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 06:25:32 -0800 (PST) From: James Clark To: maz@kernel.org, kvmarm@lists.linux.dev, oliver.upton@linux.dev, suzuki.poulose@arm.com, coresight@lists.linaro.org Cc: James Clark , Joey Gouly , Zenghui Yu , Catalin Marinas , Will Deacon , Mike Leach , Alexander Shishkin , Mark Rutland , Shiqi Liu , Mark Brown , James Morse , Anshuman Khandual , "Rob Herring (Arm)" , Raghavendra Rao Ananta , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 6/7] KVM: arm64: Support trace filtering for guests Date: Mon, 6 Jan 2025 14:24:41 +0000 Message-Id: <20250106142446.628923-7-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250106142446.628923-1-james.clark@linaro.org> References: <20250106142446.628923-1-james.clark@linaro.org> 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" For nVHE, switch the filter value in and out if the Coresight driver asks for it. This will support filters for guests when sinks other than TRBE are used. For VHE, just write the filter directly to TRFCR_EL1 where trace can be used even with TRBE sinks. Signed-off-by: James Clark --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/debug.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm= _host.h index 8fdc7b6efc79..7cfa024de4e3 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1396,6 +1396,7 @@ void kvm_clr_pmu_events(u64 clr); bool kvm_set_pmuserenr(u64 val); void kvm_enable_trbe(void); void kvm_disable_trbe(void); +void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest); #else static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *att= r) {} static inline void kvm_clr_pmu_events(u64 clr) {} @@ -1405,6 +1406,7 @@ static inline bool kvm_set_pmuserenr(u64 val) } static inline void kvm_enable_trbe(void) {} static inline void kvm_disable_trbe(void) {} +static inline void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_gu= est) {} #endif =20 void kvm_vcpu_load_vhe(struct kvm_vcpu *vcpu); diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c index 92a24adadb0e..0e4c805e7e89 100644 --- a/arch/arm64/kvm/debug.c +++ b/arch/arm64/kvm/debug.c @@ -245,3 +245,21 @@ void kvm_disable_trbe(void) host_data_clear_flag(TRBE_ENABLED); } EXPORT_SYMBOL_GPL(kvm_disable_trbe); + +void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest) +{ + if (is_protected_kvm_enabled() || WARN_ON_ONCE(preemptible())) + return; + + if (has_vhe()) { + write_sysreg_s(trfcr_while_in_guest, SYS_TRFCR_EL12); + return; + } + + *host_data_ptr(trfcr_while_in_guest) =3D trfcr_while_in_guest; + if (read_sysreg_s(SYS_TRFCR_EL1) !=3D trfcr_while_in_guest) + host_data_set_flag(EL1_TRACING_CONFIGURED); + else + host_data_clear_flag(EL1_TRACING_CONFIGURED); +} +EXPORT_SYMBOL_GPL(kvm_tracing_set_el1_configuration); --=20 2.34.1