Kernel KVM-PPC virtualization development
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: kvm-ppc@vger.kernel.org
Subject: Re: Emulating lwarx and stwcx instructions in PowerPc BOOKE e500
Date: Tue, 06 Mar 2012 20:45:30 +0000	[thread overview]
Message-ID: <4F56776A.6010106@freescale.com> (raw)
In-Reply-To: <loom.20120305T212407-58@post.gmane.org>

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


      parent reply	other threads:[~2012-03-06 20:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05 20:37 Emulating lwarx and stwcx instructions in PowerPc BOOKE e500 Aashish Mittal
2012-03-05 21:51 ` Scott Wood
2012-03-06 14:46 ` Sethi Varun-B16395
2012-03-06 20:42 ` Aashish Mittal
2012-03-06 20:45 ` Scott Wood [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F56776A.6010106@freescale.com \
    --to=scottwood@freescale.com \
    --cc=kvm-ppc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox