libvirt/examples/systemtap/amd-sev-es-vmsa.stp
Peter Krempa 83a78633a7 examples: systemtap: Update to linux-6.3 (rc1)
The 'vmsa' struct was moved out of 'struct vcpu_svm' into the 'sev_es'
sub-struct in linux commit:

  commit b67a4cc35c9f726999fa29880713ce72d4e39e8d
  Author: Peter Gonda <pgonda@google.com>
  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.

Also update the line reference to have more margin.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-03-06 13:35:44 +01:00

53 lines
1.8 KiB
Plaintext

#!/usr/bin/stap
#
# Copyright (C) 2022 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
#
# A script that captures the VMSA blob for the boot vCPU and
# first additional vCPU, when a KVM guest is booted with SEV-ES
#
# 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.
#
# The captured VMSA will be printed to the console in hex format,
# and can be converted to the required binary format by feeding
# it through
#
# perl -e 'while (<>) { print pack("C64", map { hex($_) } ( $_ =~ m/../g )); }' > vmsa.bin
#
probe begin {
printf("Running\n")
}
function dump_vmsa(addr:long) {
printf("VMSA\n")
for (i = 0; i < 4096 ; i+= 64) {
printf("%.64M\n", addr + i);
}
}
# This line number will need to be updated for the specific kernel
# version that is being probed. The line that needs to be targetted
# is the one beween the call to clflush_cache_range(...) and the
# call to sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE...).
#
# Line 635 is correct for Linux v6.3
probe module("kvm_amd").statement("__sev_launch_update_vmsa@arch/x86/kvm/svm/sev.c:635") {
dump_vmsa($svm->sev_es->vmsa)
}