From nobody Mon Feb 9 16:17:04 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 4302633A9C1 for ; Mon, 26 Jan 2026 10:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769424296; cv=none; b=UvGVqrAZ5LTr4IcK5ukINmIkq1KUeQ5TFAxPX8VsvbO42QfskNByq+y3jMV8lXouNhOpLbGNnY/83I+gIMVsE73LqXZlG+QNZSxFxw9bdHWScCJGX7fLy5SR4TTtIXeZHZ71yIZLL3o10wUr5RHtQWIkj0U0UU2fIjpQrS/3098= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769424296; c=relaxed/simple; bh=jc/1tMtJgbj0D+3+RNgTcGKl6/fF2uDcmqUjShgP6kg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KdI+VN5UT0OaZ9UmjNcFHGQ/sbssINLcnF4YztIUuYc4Cj1zcmA3Ch3lZulTwi3xtIIg4tUS3WZr32WCxD8a92Er/I4wYh2wBWZdX/Nk5cRdjtagFnOdjt6c2y84NZwHCo38CnvUbMfKNX7myLt+V79aEPcjslWT/tVBFPWmnK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kCf6e4OO; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kCf6e4OO" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4779d8fd4ecso26802315e9.1 for ; Mon, 26 Jan 2026 02:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769424292; x=1770029092; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NT+CpEP6PzXqQH6e99olRbkgz8yl4Nh6CScVnzMBNjw=; b=kCf6e4OOEEDofSixq6Tabv6fXMjHy2uBD+n9aEAv/xaK6wtDdy9M38f+aqxvlWcS1p xMWC1GGiC/2R4hbquaKS/GYIaiTsuParZft2SsAugOZ4tTFUvVeK8uZQjZpVdrFeWFwU Lt8K9FV7bEg9v029GtK8GuN3Gx9TKKYzquuwW6GOAprg/5k3IhobqlIr4BVhaXPsrzep G52eQOn3xaToItE5XXjI6+JCGNW/sn/Iqnd6fprJ6gGs9SWaZagm3WRgJvo0nd5hLab2 kfRWsG828gGbdCrNyv/ENfhPMungpQXoc2ejdGjB5gIWRUEUB4plqQ2Eq0rD4bNlvZAZ R6fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769424292; x=1770029092; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NT+CpEP6PzXqQH6e99olRbkgz8yl4Nh6CScVnzMBNjw=; b=FcBpM2oT7HIvrfM3oNsNqxuRFdAKnECoCX/GlGF8tyZR0etPiCGzMHHvFxYZ3iRmJK tXjnYxYd+zJDxn0bdX0DVHnzlmL0boUaUu0CfkpYoOrkhRnO7p0X/g+hjI0fnf1pkFJ9 iJkPdP5cRmt768tgtkLUDlB9EcvzglQv4MJm+meiyuIklYG+zXk5upWVcmcgTMqyKEU4 d10uwU5sBY+S7ii/SmoZSqbytyhEtfZW/gJUFhsEXZqomEbSACaAHc2K805TBZvvqAhB xCd3mioaGHnuElBRtkNunB+LVOJb1HabBdYnwPSX1Yi8wDn87XLQcyTH5jHx7fROc6ep iocw== X-Forwarded-Encrypted: i=1; AJvYcCX568kFUkbKrbL3Fa9pSAmQ/sMqpJWdDlz7heFSLMRQZsYCOJicrn2lFbsMfcTvjciDtYgNbsHaq1lIAj8=@vger.kernel.org X-Gm-Message-State: AOJu0YyIdQQRlNSeIAEzRbuhPn6F1ebSZ/BGEJQB9QVu0XA0bbGy8cVz YoWYxP+xFsAcoL0CzurpCYazpTNB7gzrlZlNWNPdl1vWNcDelH+gQKFBdKUCQg7As0GLJEXLWYm Rev7JSe73Bjo4P1yedA1wBg== X-Received: from wmcv18.prod.google.com ([2002:a05:600c:4292:b0:47e:e776:2495]) (user=vdonnefort job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8b6a:b0:477:9e0c:f59 with SMTP id 5b1f17b1804b1-4805cd0e356mr65382385e9.2.1769424292276; Mon, 26 Jan 2026 02:44:52 -0800 (PST) Date: Mon, 26 Jan 2026 10:44:18 +0000 In-Reply-To: <20260126104419.1649811-1-vdonnefort@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260126104419.1649811-1-vdonnefort@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260126104419.1649811-30-vdonnefort@google.com> Subject: [PATCH v10 29/30] KVM: arm64: Add selftest event support to nVHE/pKVM hyp From: Vincent Donnefort To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, jstultz@google.com, qperret@google.com, will@kernel.org, aneesh.kumar@kernel.org, kernel-team@android.com, linux-kernel@vger.kernel.org, Vincent Donnefort Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a selftest event that can be triggered from a `write_event` tracefs file. This intends to be used by trace remote selftests. Signed-off-by: Vincent Donnefort diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_= asm.h index f8fa556ec3e1..c045c074614b 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -96,6 +96,7 @@ enum __kvm_host_smccc_func { __KVM_HOST_SMCCC_FUNC___tracing_update_clock, __KVM_HOST_SMCCC_FUNC___tracing_reset, __KVM_HOST_SMCCC_FUNC___tracing_enable_event, + __KVM_HOST_SMCCC_FUNC___tracing_write_event, }; =20 #define DECLARE_KVM_VHE_SYM(sym) extern char sym[] diff --git a/arch/arm64/include/asm/kvm_hypevents.h b/arch/arm64/include/as= m/kvm_hypevents.h index 221a1dacb2f0..743c49bd878f 100644 --- a/arch/arm64/include/asm/kvm_hypevents.h +++ b/arch/arm64/include/asm/kvm_hypevents.h @@ -46,4 +46,15 @@ HYP_EVENT(hyp_exit, ), HE_PRINTK("reason=3D%s vcpu=3D%d", __hyp_enter_exit_reason_str(__entry->r= eason), __entry->vcpu) ); + +HYP_EVENT(selftest, + HE_PROTO(u64 id), + HE_STRUCT( + he_field(u64, id) + ), + HE_ASSIGN( + __entry->id =3D id; + ), + RE_PRINTK("id=3D%llu", __entry->id) +); #endif diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/h= yp-main.c index e1d4a53260ff..5655c1690f4a 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -643,6 +643,13 @@ static void handle___tracing_enable_event(struct kvm_c= pu_context *host_ctxt) cpu_reg(host_ctxt, 1) =3D __tracing_enable_event(id, enable); } =20 +static void handle___tracing_write_event(struct kvm_cpu_context *host_ctxt) +{ + DECLARE_REG(u64, id, host_ctxt, 1); + + trace_selftest(id); +} + typedef void (*hcall_t)(struct kvm_cpu_context *); =20 #define HANDLE_FUNC(x) [__KVM_HOST_SMCCC_FUNC_##x] =3D (hcall_t)handle_##x @@ -691,6 +698,7 @@ static const hcall_t host_hcall[] =3D { HANDLE_FUNC(__tracing_update_clock), HANDLE_FUNC(__tracing_reset), HANDLE_FUNC(__tracing_enable_event), + HANDLE_FUNC(__tracing_write_event), }; =20 static void handle_host_hcall(struct kvm_cpu_context *host_ctxt) diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c index 1ad6a55ba95c..c1e28f6581ab 100644 --- a/arch/arm64/kvm/hyp_trace.c +++ b/arch/arm64/kvm/hyp_trace.c @@ -348,8 +348,30 @@ static int hyp_trace_clock_show(struct seq_file *m, vo= id *v) } DEFINE_SHOW_ATTRIBUTE(hyp_trace_clock); =20 +static ssize_t hyp_trace_write_event_write(struct file *f, const char __us= er *ubuf, + size_t cnt, loff_t *pos) +{ + unsigned long val; + int ret; + + ret =3D kstrtoul_from_user(ubuf, cnt, 10, &val); + if (ret) + return ret; + + kvm_call_hyp_nvhe(__tracing_write_event, val); + + return cnt; +} + +static const struct file_operations hyp_trace_write_event_fops =3D { + .write =3D hyp_trace_write_event_write, +}; + static int hyp_trace_init_tracefs(struct dentry *d, void *priv) { + if (!tracefs_create_file("write_event", 0200, d, NULL, &hyp_trace_write_e= vent_fops)) + return -ENOMEM; + return tracefs_create_file("trace_clock", 0440, d, NULL, &hyp_trace_clock= _fops) ? 0 : -ENOMEM; } --=20 2.52.0.457.g6b5491de43-goog