qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Implementing an access log
@ 2021-05-07 16:01 Lorenzo Susini
  0 siblings, 0 replies; only message in thread
From: Lorenzo Susini @ 2021-05-07 16:01 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1884 bytes --]

Hi all,

I'm a student and am working on a personal project, I would like to receive
some feedback on implementing a memory access log
in QEMU (or in KVM, since I'm always enabling it). In particular, I want to
keep track of the guest physical pages which are accessed during a certain
interval of time. To implement it, I was thinking about these two options:

1. To keep track of each memory access, one could potentially unmap each
memory slot of the currently running VM. This way, every memory access
should
trap to KVM and then to userspace QEMU. Userspace will satisfy the request
by reading or writing memory using its virtual address space (actually
translating
the guest physical address to the corresponding host virtual address) and
it can record which page was accessed. This approach led me to a
KVM_EXIT_SHUTDOWN
and I did not know how to go further.

2. Another way to do it would be by introducing two new ioctls in KVM and
using the tdp mmu. The first one, let's call it KVM_CLEAR_ACCESS_LOG, takes
as input a memslot id. By iterating over
the paging structures leading to the translation of each gfn in the slot,
it reset the access bit. Then, the second, KVM_GET_ACCESS_LOG, will
generate a bitmap
containing one bit for each page of the memslot, pretty much like the
bitmap already implemented for the dirty log. I've tried to implement the
first ioctl, iterating the paging
structures using tdp_iter. When it comes to reset the access bit, my system
freezes. The output of dmesg is the following:

get_mmio_spte: detect reserved bits on spte, addr 0x....

I would like to receive any suggestions on the feasibility of these two
approaches, what do you think would be better and maybe some hints on how
to solve the problem.
Anyway, am I missing something similar that is already implemented? Other
ideas to implement this are welcome too.

Kind regards,
Lorenzo

[-- Attachment #2: Type: text/html, Size: 2189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-07 16:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 16:01 Implementing an access log Lorenzo Susini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).