0

I want to modify the KVM Guest(linux) VM's kernel data structure from the Linux host. I want to modify the struct page* of KVM guest linux from the host. In host, I have access to GFN of the guest's struct page I want to modify.

Can I implement some kind of reverse-hypercall to send the info to guest kernel, so the guest can modify itself? or Can I modify it in the host by accessing the pointer to the structure (I feel this method would fail if the host doesn't know the guest VM's page structure)

Any reference to some existing methodology or kernel function will help.

shivank
  • 67
  • 1
  • 10
  • See https://stackoverflow.com/a/14541392/1216776 – stark Apr 18 '21 at 11:19
  • I think implementing gdb-like protocol for this would be too much, given that I have access to the host kernel and access to KVM page tables and GFNs (and thus respective PFN using `gfn_to_pfn()`). Also, I want only want to modify it, whenever the `kvm_mmu_page_fault()` is triggered in host. It seem to me that it can be easily done just that I'm not able to find the right direction. – shivank Apr 18 '21 at 16:57
  • If your host and guests' `struct kvm` use the same definition, you can modify it by passing the GFN via hypercall, and then use `kvm_write_guest()` or `kvm_vcpu_write_guest()` to modify it. Be careful with casting the data types. If you are just doing some experiments using the same kernel, that would be fine. – KagurazakaKotori Apr 25 '21 at 06:20

0 Answers0