Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Add selftest event support to nVHE/pKVM hyp

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 <vdonnefort@google.com>
Link: https://patch.msgid.link/20260309162516.2623589-30-vdonnefort@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Vincent Donnefort and committed by
Marc Zyngier
5bbbed42 696dfec2

+42
+1
arch/arm64/include/asm/kvm_asm.h
··· 96 96 __KVM_HOST_SMCCC_FUNC___tracing_update_clock, 97 97 __KVM_HOST_SMCCC_FUNC___tracing_reset, 98 98 __KVM_HOST_SMCCC_FUNC___tracing_enable_event, 99 + __KVM_HOST_SMCCC_FUNC___tracing_write_event, 99 100 }; 100 101 101 102 #define DECLARE_KVM_VHE_SYM(sym) extern char sym[]
+11
arch/arm64/include/asm/kvm_hypevents.h
··· 46 46 ), 47 47 HE_PRINTK("reason=%s vcpu=%d", __hyp_enter_exit_reason_str(__entry->reason), __entry->vcpu) 48 48 ); 49 + 50 + HYP_EVENT(selftest, 51 + HE_PROTO(u64 id), 52 + HE_STRUCT( 53 + he_field(u64, id) 54 + ), 55 + HE_ASSIGN( 56 + __entry->id = id; 57 + ), 58 + RE_PRINTK("id=%llu", __entry->id) 59 + ); 49 60 #endif
+8
arch/arm64/kvm/hyp/nvhe/hyp-main.c
··· 643 643 cpu_reg(host_ctxt, 1) = __tracing_enable_event(id, enable); 644 644 } 645 645 646 + static void handle___tracing_write_event(struct kvm_cpu_context *host_ctxt) 647 + { 648 + DECLARE_REG(u64, id, host_ctxt, 1); 649 + 650 + trace_selftest(id); 651 + } 652 + 646 653 typedef void (*hcall_t)(struct kvm_cpu_context *); 647 654 648 655 #define HANDLE_FUNC(x) [__KVM_HOST_SMCCC_FUNC_##x] = (hcall_t)handle_##x ··· 698 691 HANDLE_FUNC(__tracing_update_clock), 699 692 HANDLE_FUNC(__tracing_reset), 700 693 HANDLE_FUNC(__tracing_enable_event), 694 + HANDLE_FUNC(__tracing_write_event), 701 695 }; 702 696 703 697 static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
+22
arch/arm64/kvm/hyp_trace.c
··· 348 348 } 349 349 DEFINE_SHOW_ATTRIBUTE(hyp_trace_clock); 350 350 351 + static ssize_t hyp_trace_write_event_write(struct file *f, const char __user *ubuf, 352 + size_t cnt, loff_t *pos) 353 + { 354 + unsigned long val; 355 + int ret; 356 + 357 + ret = kstrtoul_from_user(ubuf, cnt, 10, &val); 358 + if (ret) 359 + return ret; 360 + 361 + kvm_call_hyp_nvhe(__tracing_write_event, val); 362 + 363 + return cnt; 364 + } 365 + 366 + static const struct file_operations hyp_trace_write_event_fops = { 367 + .write = hyp_trace_write_event_write, 368 + }; 369 + 351 370 static int hyp_trace_init_tracefs(struct dentry *d, void *priv) 352 371 { 372 + if (!tracefs_create_file("write_event", 0200, d, NULL, &hyp_trace_write_event_fops)) 373 + return -ENOMEM; 374 + 353 375 return tracefs_create_file("trace_clock", 0440, d, NULL, &hyp_trace_clock_fops) ? 354 376 0 : -ENOMEM; 355 377 }