• Arnaldo Carvalho de Melo's avatar
    tools arch x86: Sync the msr-index.h copy with the kernel sources · 7f7f86a7
    Arnaldo Carvalho de Melo authored
    To pick up the changes in:
    
      2b129932 ("x86/speculation: Add RSB VM Exit protections")
      4af184ee ("tools/power turbostat: dump secondary Turbo-Ratio-Limit")
      4ad3278d ("x86/speculation: Disable RRSBA behavior")
      d7caac99 ("x86/cpu/amd: Add Spectral Chicken")
      6ad0ad2b ("x86/bugs: Report Intel retbleed vulnerability")
      c59a1f10 ("KVM: x86/pmu: Add IA32_PEBS_ENABLE MSR emulation for extended PEBS")
      465932db ("x86/cpu: Add new VMX feature, Tertiary VM-Execution control")
      027bbb88 ("KVM: x86/speculation: Disable Fill buffer clear within guests")
      51802186 ("x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug")
    
    Addressing these tools/perf build warnings:
    
        diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
    
    That makes the beautification scripts to pick some new entries:
    
      $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before
      $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h
      $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after
      $ diff -u before after
      --- before	2022-08-17 09:05:13.938246475 -0300
      +++ after	2022-08-17 09:05:22.221455851 -0300
      @@ -161,6 +161,7 @@
       	[0x0000048f] = "IA32_VMX_TRUE_EXIT_CTLS",
       	[0x00000490] = "IA32_VMX_TRUE_ENTRY_CTLS",
       	[0x00000491] = "IA32_VMX_VMFUNC",
      +	[0x00000492] = "IA32_VMX_PROCBASED_CTLS3",
       	[0x000004c1] = "IA32_PMC0",
       	[0x000004d0] = "IA32_MCG_EXT_CTL",
       	[0x00000560] = "IA32_RTIT_OUTPUT_BASE",
      @@ -212,6 +213,7 @@
       	[0x0000064D] = "PLATFORM_ENERGY_STATUS",
       	[0x0000064e] = "PPERF",
       	[0x0000064f] = "PERF_LIMIT_REASONS",
      +	[0x00000650] = "SECONDARY_TURBO_RATIO_LIMIT",
       	[0x00000658] = "PKG_WEIGHTED_CORE_C0_RES",
       	[0x00000659] = "PKG_ANY_CORE_C0_RES",
       	[0x0000065A] = "PKG_ANY_GFXE_C0_RES",
      $
    
    Now one can trace systemwide asking to see backtraces to where those
    MSRs are being read/written, see this example with a previous update:
    
      # perf trace -e msr:*_msr/max-stack=32/ --filter="msr>=IA32_U_CET && msr<=IA32_INT_SSP_TAB"
      ^C#
    
    If we use -v (verbose mode) we can see what it does behind the scenes:
    
      # perf trace -v -e msr:*_msr/max-stack=32/ --filter="msr>=IA32_U_CET && msr<=IA32_INT_SSP_TAB"
      Using CPUID AuthenticAMD-25-21-0
      0x6a0
      0x6a8
      New filter for msr:read_msr: (msr>=0x6a0 && msr<=0x6a8) && (common_pid != 597499 && common_pid != 3313)
      0x6a0
      0x6a8
      New filter for msr:write_msr: (msr>=0x6a0 && msr<=0x6a8) && (common_pid != 597499 && common_pid != 3313)
      mmap size 528384B
      ^C#
    
    Example with a frequent msr:
    
      # perf trace -v -e msr:*_msr/max-stack=32/ --filter="msr==IA32_SPEC_CTRL" --max-events 2
      Using CPUID AuthenticAMD-25-21-0
      0x48
      New filter for msr:read_msr: (msr==0x48) && (common_pid != 2612129 && common_pid != 3841)
      0x48
      New filter for msr:write_msr: (msr==0x48) && (common_pid != 2612129 && common_pid != 3841)
      mmap size 528384B
      Looking at the vmlinux_path (8 entries long)
      symsrc__init: build id mismatch for vmlinux.
      Using /proc/kcore for kernel data
      Using /proc/kallsyms for symbols
         0.000 Timer/2525383 msr:write_msr(msr: IA32_SPEC_CTRL, val: 6)
                                           do_trace_write_msr ([kernel.kallsyms])
                                           do_trace_write_msr ([kernel.kallsyms])
                                           __switch_to_xtra ([kernel.kallsyms])
                                           __switch_to ([kernel.kallsyms])
                                           __schedule ([kernel.kallsyms])
                                           schedule ([kernel.kallsyms])
                                           futex_wait_queue_me ([kernel.kallsyms])
                                           futex_wait ([kernel.kallsyms])
                                           do_futex ([kernel.kallsyms])
                                           __x64_sys_futex ([kernel.kallsyms])
                                           do_syscall_64 ([kernel.kallsyms])
                                           entry_SYSCALL_64_after_hwframe ([kernel.kallsyms])
                                           __futex_abstimed_wait_common64 (/usr/lib64/libpthread-2.33.so)
         0.030 :0/0 msr:write_msr(msr: IA32_SPEC_CTRL, val: 2)
                                           do_trace_write_msr ([kernel.kallsyms])
                                           do_trace_write_msr ([kernel.kallsyms])
                                           __switch_to_xtra ([kernel.kallsyms])
                                           __switch_to ([kernel.kallsyms])
                                           __schedule ([kernel.kallsyms])
                                           schedule_idle ([kernel.kallsyms])
                                           do_idle ([kernel.kallsyms])
                                           cpu_startup_entry ([kernel.kallsyms])
                                           secondary_startup_64_no_verify ([kernel.kallsyms])
      #
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Daniel Sneddon <daniel.sneddon@linux.intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Len Brown <len.brown@intel.com>
    Cc: Like Xu <like.xu@linux.intel.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Robert Hoo <robert.hu@linux.intel.com>
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Link: https://lore.kernel.org/lkml/YvzbT24m2o5U%2F7+q@kernel.org/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    7f7f86a7
msr-index.h 39.9 KB