qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implementing an access log


From: Lorenzo Susini
Subject: Implementing an access log
Date: Fri, 7 May 2021 18:01:02 +0200

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]