Re: Load data from shared page (magic page) using 'kvmppc_ld'

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

 



On 20.12.2011, at 19:03, Dushyant Bansal wrote:

> On Tuesday 20 December 2011 09:37 PM, Alexander Graf wrote:
>> On 20.12.2011, at 16:43, Dushyant Bansal wrote:
>> 
>>> Hi,
>>> 
>>> The Book3S KVM implementation contains one helper function  'kvmppc_ld' to load data from guest virtual addresses.
>>> 
>>> Usually, this works fine for me. But this doesn't work when I try to read data from the shared page (magic page).
>>> 
>>> /* Writing data on shared page */
>>> u32 * p = (u32 *) (vcpu->arch.shared + 192); /* p becomes the host address corresponding to guest address of '0xfffff0c0' */
>>> p[0] = 20;
>>> 
>>> /* Reading data on shared page */
>>> u32 inst = 0;
>>> ulong pc = 0xfffff0c0; /* Or, any other address on the shared page */
>>> r = kvmppc_ld(vcpu,&pc, sizeof(u32),&inst, false);
>>> 
>>> 'inst' still contains '0'. Also, value returned by this call is '0' which means 'kvmppc_ld' has not failed.
>>> 
>>> Am I missing something here? If you have any pointers, please let me know.
>> Uh. Looks like the kvmppc_ld code path doesn't take the magic page into consideration. Could you please verify if you can read the value from guest code? Also, why do you want to load it using kvmppc_ld on the host?
> 
> Yes, I can read it from the guest.
> 
> Actually, I am storing a few instructions on the shared page which get executed from inside guest VM. Most of the times, this works fine.
> But quite a few times, I have noticed that if there is an exit on any of those instructions residing on the shared page then, it doesn't show the expected instruction in the exit trace.
> 
> kvm_book3s_exit: exit=0x400 | pc=0xfffff0c0 | inst=0x7fe000a6
> 
> Here, inst should be some other instruction. I haven't checked it thoroughly but it looks to me that  'inst' here is the instruction corresponding to an earlier VM exit.

Yes, that's expected. The exit code here is 0x400, pointing to an ISI exception. For ISIs, we need to map the guest's address space and are very sure we won't have to emulate the instruction, so we can just not load last_inst (which wouldn't work in the fast path anyway, because it's not mapped).

> So, I was trying to read the actual instruction for this pc after a VM exit using kvmppc_ld.

kvmppc_ld doesn't support the magic page as it is today. While I agree that it's unpretty, we only use it for very few use cases, most prominently loading last_inst if the fast path failed. Since we don't store instructions in the magic page, that hasn't emerged yet.

So you can either implement magic_page handling in kvmppc_ld (or its underlying functions) or just accept the fact that last_inst isn't correct in this case and move on :).


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux