Re: Emulating lwarx and stwcx instructions in PowerPc BOOKE e500

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

 



On 03/06/2012 02:30 PM, Aashish Mittal wrote:
> I'm thinking of emulating the lwarx and stwcx instruction as follows
> 
> 1) to emulate lwarx i will just do a load word instruction .
>  In order to emulate lwarx correctly, i will need to setup a global
> reservation structure, which has a reservation entry for each CPU.
> Upon making the lwarx, i will set the internal reserve bit, then setup a
> snoop address.  All writes to the memory block that the address is in
> will destroy the reservation in this structure.
> Since i'm not calling a direct lwarx instruction upon encountering a lwarx in
> guest this will not leave a reservation when i'm returning to guest.
> 
> 2) Upon encountering a stwcx instruction in guest i can match the
> reservation address
> as stored in my global reservation structure. If it matches then i can
> fire a dummy lwarx
> first in host and then fire the stwcx.

Why bother with the dummy lwarx and stwcx?  Just do an ordinary store.
You'll want to use a mutex in KVM to protect from multiple vcpus
accessing the region at once.

Also check whether you're on a CPU that's supposed to clear reservations
on interrupts.

> Will that work ?

It should, as long as you aren't sharing this memory with anything that
can access it directly (no emulation) that will be writing to the
reservation granule or using lwarx/stwcx itself.

But why do you need this?

-Scott

--
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