[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220412195846.3692374-1-zhanwei@google.com>
Date: Tue, 12 Apr 2022 19:58:44 +0000
From: Wei Zhang <zhanwei@...gle.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Wei Zhang <zhanwei@...gle.com>,
Suleiman Souhlal <suleiman@...gle.com>,
Sangwhan Moon <sxm@...gle.com>, Ingo Molnar <mingo@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 0/2] KVM: x86: Fix incorrect VM-exit profiling
The profile=kvm boot option has been useful because it provides a
convenient approach to profile VM exits. However, it's problematic because
the profiling buffer is indexed by (pc - _stext), and a guest's pc minus a
host's _stext doesn't make sense in most cases.
When running another linux kernel in the guest, we could work around the
problem by disabling KASLR in both the host and the guest so they have the
same _stext. However, this is inconvenient and not always possible.
We're looking for a solution to this problem. A straightforward idea is to
pass the guest's _stext to the host so the profiling buffer can be indexed
correctly. This approach is quite brute, as you can see in the prototype
patches.
We had some initial discussions and here is a short summary:
1. The VM-exit profiling is already hacky. It's collecting stats about all
KVM guests bunched together into a single global buffer without any
separation.
2. Even if we pass _stext from the guest, there are still a lot of
limitations: There can be only one running guest, and the size of its
text region shouldn't exceed the size of the profiling buffer,
which is (_etext - _stext) in the host.
3. There are other methods for profiling VM exits, but it would be really
convenient if readprofile just works out of box for KVM profiling.
It would be awesome to hear more thoughts on this. Should we try to fix the
existing VM-exit profiling functionility? Or should we avoid adding more
hacks there? If it should be fixed, what's the preferred way? Thanks in
advance for any suggestions.
Wei Zhang (2):
KVM: x86: allow guest to send its _stext for kvm profiling
KVM: x86: illustrative example for sending guest _stext with a
hypercall
arch/x86/kernel/setup.c | 6 ++++++
arch/x86/kvm/x86.c | 15 +++++++++++++++
include/linux/kvm_host.h | 4 ++++
include/uapi/linux/kvm_para.h | 1 +
virt/kvm/Kconfig | 5 +++++
5 files changed, 31 insertions(+)
base-commit: 42dcbe7d8bac997eef4c379e61d9121a15ed4e36
--
2.35.1.1178.g4f1659d476-goog
Powered by blists - more mailing lists