• Adrian Hunter's avatar
    perf tools: Add guest_code support · 096fc361
    Adrian Hunter authored
    A common case for KVM test programs is that the test program acts as the
    hypervisor, creating, running and destroying the virtual machine, and
    providing the guest object code from its own object code. In this case,
    the VM is not running an OS, but only the functions loaded into it by the
    hypervisor test program, and conveniently, loaded at the same virtual
    addresses.
    
    Normally to resolve addresses, MMAP events are needed to map addresses
    back to the object code and debug symbols for that object code.
    
    Currently, there is no way to get such mapping information from guests
    but, in the scenario described above, the guest has the same mappings
    as the hypervisor, so support for that scenario can be achieved.
    
    To support that, copy the host thread's maps to the guest thread's maps.
    Note, we do not discover the guest until we encounter a guest event,
    which works well because it is not until then that we know that the host
    thread's maps have been set up.
    
    Typically the main function for the guest object code is called
    "guest_code", hence the name chosen for this feature. Note, that is just a
    convention, the function could be named anything, and the tools do not
    care.
    
    This is primarily aimed at supporting Intel PT, or similar, where trace
    data can be recorded for a guest. Refer to the final patch in this series
    "perf intel-pt: Add guest_code support" for an example.
    Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: kvm@vger.kernel.org
    Link: https://lore.kernel.org/r/20220517131011.6117-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    096fc361
machine.h 9.76 KB