[PATCH 2/2] KVM: x86: illustrative example for sending guest _stext with a hypercall

Wei Zhang
2022-04-12T20:06:07Z

A guest could send its _stext with the newly added hypercall. The
statistics collected afterwards will be correct in the kernel.

Signed-off-by: Wei Zhang <zhanwei@google.com>
---
arch/x86/kernel/setup.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index c95b9ac5a457..ee8c4fd4efe9 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -24,6 +24,7 @@
#include <linux/static_call.h>
#include <linux/swiotlb.h>

+#include <uapi/linux/kvm_para.h>
#include <uapi/linux/mount.h>

#include <xen/xen.h>
@@ -1241,6 +1242,11 @@ void __init setup_arch(char **cmdline_p)
#endif

unwind_init();
+
+ /*
+ * Send the _stext to the host kernel.
+ */
+ kvm_hypercall1(KVM_HC_GUEST_STEXT, (unsigned long)_stext);
}

#ifdef CONFIG_X86_32
--
2.35.1.1178.g4f1659d476-goog