[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][PATCH] xen: make VMTRACE support optional


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Thu, 6 Nov 2025 15:50:24 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wkt0Ew14jTcRGur1+FZs8HbHI4jeMS064zlVi81tFMs=; b=IxKLrt3RM4jqRmmOo59Yd2A7OWJt5KzwG/QzldCGHVGB1Pcihy2ie4Zxd2lMxYxF8dmZhVqmjuU3ELDzQPymgYYMzfHrA7ngL5IFYMDFgfRKeZXyaT3H5TwNNpWZ+Ijc1ZHUYPV5JyrvZa7f3xqjCRL1MM5Zsje5tynIyqbxACOb3cF3FcGyeHWJmtbKJ7hJR02sZIfrS+Yo3DCU7J3PHSSGA7fWxDriQbHlIJlhVGc60r0QzsMQ7lqVFhkAzQ3MmxFQiKbux12IkAd5yAk7/VTY3bdWAt+aeRR5HIbqLhLdKUZti0GJQj7JQmLhhYbhhPP5R/Ha5QnBgQU3CJn0RQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AU8HdnHpIy+lO1UBErt4fN30nL7eyegpBUVxhBt39gpT7YyK+1iaSZ7AxqgYFePRPDgBDin1KjpOlNUFfMsstK1+AcZ0B8Q30ODJvq0cX+rv1hagg1p2KndOzIF0VzH8mgX00jbR5aIlQyr6Ds9JY2GUxCGbYKvek9T8J4zx6RVAua1w6KKL1idPadVcArRj1h60TRoB4tJFW1IgPGWEi5CZ7R08n6NFiTCxiOAlzRR7DPk8YMw9gzCepMnjomAsRAydes94sm3MUS56IbgOagCxqfxsypO/aQBxriA1NRUK7AwmLNd1ul0/P9oBrMzHDvxVU09/leDwkUJGNXogBA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Alexandru Isaila <aisaila@xxxxxxxxxxxxxxx>, Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 06 Nov 2025 13:50:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

On 06.11.25 14:00, Jan Beulich wrote:
On 31.10.2025 22:20, Grygorii Strashko wrote:
--- a/xen/Kconfig.debug
+++ b/xen/Kconfig.debug
@@ -155,4 +155,19 @@ config DEBUG_INFO
          "make install-xen" for installing xen.efi, stripping needs to be
          done outside the Xen build environment).
+config HAS_VMTRACE
+    bool
+
+config VMTRACE
+    bool "HW VM tracing support"
+    depends on HAS_VMTRACE
+    default y
+    help
+      Enables HW VM tracing support which allows to configure HW processor
+      features (vmtrace_op) to enable capturing information about software
+      execution using dedicated hardware facilities with minimal interference
+      to the software being traced. The trace date can be retrieved using 
buffer

Nit: s/date/data/

+      shared between Xen and domain
+      (see XENMEM_acquire_resource(XENMEM_resource_vmtrace_buf)).
+

I was actually meaning to ask that "VMX only" should somehow be mentioned here,
but then I noticed this is an arch-independent location.

Right, Arch code advertise VMTRACE support with HAS_VMTRACE.
In this particular case:
config INTEL_VMX
...
        select HAS_VMTRACE


I'm not quite sure we want it like this (just yet).

?


@@ -2940,11 +2948,13 @@ static struct hvm_function_table __initdata_cf_clobber 
vmx_function_table = {
      .altp2m_vcpu_emulate_ve = vmx_vcpu_emulate_ve,
      .altp2m_vcpu_emulate_vmfunc = vmx_vcpu_emulate_vmfunc,
  #endif
+#ifdef CONFIG_VMTRACE
      .vmtrace_control = vmtrace_control,
      .vmtrace_output_position = vmtrace_output_position,
      .vmtrace_set_option = vmtrace_set_option,
      .vmtrace_get_option = vmtrace_get_option,
      .vmtrace_reset = vmtrace_reset,
+#endif
.get_reg = vmx_get_reg,
      .set_reg = vmx_set_reg,

Blank line ahead of the new #ifdef?

@@ -738,6 +740,7 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu *v)
  bool altp2m_vcpu_emulate_ve(struct vcpu *v);
  #endif /* CONFIG_ALTP2M */
+#ifdef CONFIG_VMTRACE
  static inline int hvm_vmtrace_control(struct vcpu *v, bool enable, bool reset)
  {
      if ( hvm_funcs.vmtrace_control )
@@ -780,6 +783,12 @@ static inline int hvm_vmtrace_reset(struct vcpu *v)
return -EOPNOTSUPP;
  }
+#else
+static inline int hvm_vmtrace_reset(struct vcpu *v)
+{
+    return 0;
+}
+#endif

#ifdef inside the function body please, to reduce redundancy and to reduce the
risk of overlooking multiple places which need editing (when e.g. function
parameters change).

All hvm_vmtrace_x() functions are inline - do you mean like below for all of 
them?

 static inline int hvm_vmtrace_get_option(
     struct vcpu *v, uint64_t key, uint64_t *value)
 {
+#ifdef CONFIG_VMTRACE
     if ( hvm_funcs.vmtrace_get_option )
         return alternative_call(hvm_funcs.vmtrace_get_option, v, key, value);
+#endif
return -EOPNOTSUPP;
 }



--- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
@@ -155,7 +155,9 @@ struct vmx_vcpu {
      bool                 ept_spurious_misconfig;
/* Processor Trace configured and enabled for the vcpu. */
+#ifdef CONFIG_VMTRACE
      bool                 ipt_active;
+#endif

Imo such an #ifdef would better enclose the comment as well.

--- a/xen/arch/x86/vm_event.c
+++ b/xen/arch/x86/vm_event.c
@@ -253,7 +253,9 @@ void vm_event_fill_regs(vm_event_request_t *req)
      req->data.regs.x86.shadow_gs = ctxt.shadow_gs;
      req->data.regs.x86.dr6 = ctxt.dr6;
+#ifdef CONFIG_VMTRACE
      if ( hvm_vmtrace_output_position(curr, &req->data.regs.x86.vmtrace_pos) 
!= 1 )
+#endif
          req->data.regs.x86.vmtrace_pos = ~0;
  #endif
  }

Use IS_ENABLED() together with a function declaration (but no definition) in the
VMTRACE=n case?


--
Best regards,
-grygorii




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.