Bug 2175598

Summary: Fail to run systemtap examples
Product: Red Hat Enterprise Linux 9 Reporter: Han Han <hhan>
Component: libvirtAssignee: Virtualization Maintenance <virt-maint>
libvirt sub component: General QA Contact: Virtualization Bugs <virt-bugs>
Status: CLOSED WONTFIX Docs Contact:
Severity: low    
Priority: low CC: pkrempa, virt-maint
Version: 9.3   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-06 11:41:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Han Han 2023-03-06 02:47:38 UTC
Description of problem:
As subject

Version-Release number of selected component (if applicable):
kernel-5.14.0-283.el9.x86_64
libvirt-9.0.0-7.el9.x86_64
systemtap-4.8-2.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Install systemtap; run stap-prep to prepare for systemtap; install 'libvirt*' packages
2. Change to /usr/share/doc/libvirt-docs/examples/systemtap
3. Run the systemtap scripts.
# stap amd-sev-es-vmsa.stp
semantic error: unable to find member 'vmsa' for struct vcpu_svm (alternatives: vmcb, vcpu, asid, msrpm, sev_es, vmcb01, ir_list, svm_data, nested, dfr_reg, ldr_reg, tsc_aux, current_vmcb, next_rip, msr_decfg, spec_ctrl, tsc_ratio_msr, ir_list_lock, lbrv_enabled, nmi_iret_rip, nmi_l1_to_l2, vgif_enabled, nrips_enabled, soft_int_csbase, nmi_singlestep, virt_spec_ctrl, sysenter_eip_hi, sysenter_esp_hi, soft_int_old_rip, avic_backing_page, soft_int_injected, soft_int_next_rip, guest_state_loaded, tsc_scaling_enabled, pause_filter_enabled, shadow_msr_intercept, avic_physical_id_cache, pause_threshold_enabled, v_vmload_vmsave_enabled, x2avic_msrs_intercepted, nmi_singlestep_guest_rflags): operator '->' at amd-sev-es-vmsa.stp:47:17
        source:   dump_vmsa($svm->vmsa)
                                ^

semantic error: unresolved type : identifier '$svm' at :47:13
        source:   dump_vmsa($svm->vmsa)
                            ^

Pass 2: analysis failed.  [man error::pass2]

# stap lock-debug.stp 
semantic error: while resolving probe point: identifier 'lock' at lock-debug.stp:54:7
        source: probe lock.call
                      ^

semantic error: no match: identifier 'call' at :54:12
        source: probe lock.call
                           ^

Pass 2: analysis failed.  [man error::pass2]
Number of similar error messages suppressed: 2.
Rerun with -v to see them.

Actual results:
Fail to run lock-debug.stp and amd-sev-es-vmsa.stp

Expected results:
Run lock-debug.stp and amd-sev-es-vmsa.stp successfully

Additional info:

Comment 1 Peter Krempa 2023-03-06 09:54:12 UTC
Looking at the kernel source I've noticed that the 'vmsa' struct is inside the 'sev_es' member of 'struct vcpu_svm' which is in the context of the script accessed as $svm.

Could you please try updating the script to say:

 dump_vmsa($svm->sev_es->vmsa)

Comment 2 Peter Krempa 2023-03-06 09:59:02 UTC
The 'vmsa' struct was moved out in kernel commit:

commit b67a4cc35c9f726999fa29880713ce72d4e39e8d
Author: Peter Gonda <pgonda>
Date:   Thu Oct 21 10:42:59 2021 -0700

    KVM: SEV: Refactor out sev_es_state struct
    
    Move SEV-ES vCPU metadata into new sev_es_state struct from vcpu_svm.

I don't think it's feasible for libvirt to try to keep that file working as it's referencing specific line(!!!!!) of kernel source code. In this case also a different change broke it.

Comment 3 Han Han 2023-03-06 10:13:35 UTC
(In reply to Peter Krempa from comment #1)
> Looking at the kernel source I've noticed that the 'vmsa' struct is inside
> the 'sev_es' member of 'struct vcpu_svm' which is in the context of the
> script accessed as $svm.
> 
> Could you please try updating the script to say:
> 
>  dump_vmsa($svm->sev_es->vmsa)

It works after updating to this line:

➜  ~ stap /usr/share/doc/libvirt-docs/examples/systemtap/amd-sev-es-vmsa.stp
Running

Comment 4 Peter Krempa 2023-03-06 11:41:25 UTC
In upstream we came to the conclusion that bugs against this file are invalid as it's just an example which in most cases is expected to be editted. We'll be adding the following disclaimer to emphasisze that:

+# NOTE: This directly references specific structures and places in the
+#       kernel source code. It is expected that this example will need to be
+#       editted to match the kernel you intend to run it against.