qemu-devel
[Top][All Lists]
Advanced

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

KVM guest physical address and its corresponding host virtual address


From: Lorenzo Susini
Subject: KVM guest physical address and its corresponding host virtual address
Date: Sat, 13 Mar 2021 19:14:05 +0100

Hi all, 
I'm a student and I'm new to QEMU and virtualization. 

I would like to locate the Interrupt Descriptor Table of the guest from the host and so I want to obtain a host virtual address pointing to it. 
I don't know if I've found the right way to do that, but till now I'm doing like this from the kvm-all.c file: 
  1. I'm reading the IDTR register using KVM_GET_SREGS
  2. Given that this is a guest virtual address, I'm using the translation of the vcpu to translate it to a guest physical address. This is achieved by using KVM_TRANSLATE. 
  3. Now that I obtained a guest physical address, I think I can use it as an index to the physical memory allocated to the guest by the host, which of course resides in the host itself.
Now the question is how to implement point 3? The idea is simply to get the base address of the guest's memory and then add the physical address obtained at point 2. 
I was looking for that base address, and it turned out that there are many many memory slots in use.

Then, I found out this function: kvm_physical_memory_addr_from_host to do that. It seems to me it does what I'm thinking about but I'm not sure. Do you think I can use this?
I see it is also use to inject something (mce), so maybe it's good to use it.

Could you also explain to me the meaning of the ram field of the KVMSlot struct?

Best regards,
Lorenzo Susini

reply via email to

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