All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Aashish Mittal <aashish.mittal4u@gmail.com>
Cc: kvm-ppc@vger.kernel.org,
	"kvm@vger.kernel.org list" <kvm@vger.kernel.org>
Subject: Re: Emulating LWZU Instruction for e500 powerpc
Date: Thu, 25 Aug 2011 09:44:50 -0500	[thread overview]
Message-ID: <1443A453-EDC5-432B-A443-16AC12C04A28@suse.de> (raw)
In-Reply-To: <CAAonZCFpf9Nv1deAafSagDPjRoLWa3haAuH4Puz1Dksmnd62ng@mail.gmail.com>


On 25.08.2011, at 04:30, Aashish Mittal wrote:

> 
> On Thu, Aug 25, 2011 at 4:04 AM, Alexander Graf <agraf@suse.de> wrote:
> 
> On 19.08.2011, at 06:45, Aashish Mittal wrote:
> 
> > Hi
> > I'm trying to emulate the lwzu instruction in e500 powerpc kvm for my project .
> > I've removed the read and write privileges from the tlb entries of guest's
> > certain pages . So when i'm trying to emulate lwzu instruction i'm getting a
> > kernel panic while mounting the guest filesystem while booting .
> >
> > attempt to access beyond end of device
> > ram0: rw=0, want=75703268, limit=262144
> >
> > To make sure that the emulation is  faulty what i'm trying to do now is at the
> > time of DATA STORAGE exit on a marked page by an lwzu instruction i'm patching
> > the next instruction with an instruction which will raise an INTERRUPT PROGRAM
> > EXCEPTION and will get trapped in kvm and then i'm reverting the old read and
> > write privileges of this page and resuming the guest so that this LWZU
> > instruction can run natively . I'm expecting the immediate next instruction to
> > raise the INTERRUPT PROGRAM EXCEPTION but all i'm getting are DATA STORAGE Exits
> > at other pages marked by me and DTLB and ITLB misses on other addresses .
> >
> > I've made sure to flush the icache after i patch using the instruction
> > flush_icache_range .
> >
> > Error Log :
> > Emulating a lwzu instruction on pc 0xc00161ac && eaddr 0xc05742f0
> > Original Instruction is 0x90e60004 at pc: 0xc00161b0
> > Modified Instruction is 0x7ce000a6 at pc: 0xc00161b0
> > Exit : Interrupt DATA STORAGE at pc 0xc000f210 on eaddr:0xc000f228 instruction:
> > 0x8085001c
> >
> > Why i'm not getting any INTERRUPT PROGRAM EXCEPTION immediately in the next
> > instruction ?
> 
> Hrm. Are you sure you're actually modifying the instruction? This looks like you're running Linux, so you could try and just put a "b ." instruction right after the instruction you're trying to patch up and examine memory from Qemu :)
> 
> 
> Alex
> 
> I checked the memory by reading the guest page at the modified instruction and it is the modified instruction . I think the reason i'm not getting the EXIT is because the icache is not getting flushed properly. 
> I'm trying to to flush the icache entries of the guest while i'm inside the host kvm . I'm trying to use flush_icache_range(pc , pc+ 4 ) where this pc  is the guest pc eaddr where i'm modifying the instruction . 
> 
> Do you have any idea how to flush the guest entries while i'm inside the host os given the guest eaddr of the address where i'm trying to patch the instruction . 

You need to do the icache flush on the effective address you were writing to, not the guest effective address :)


Alex


WARNING: multiple messages have this Message-ID (diff)
From: Alexander Graf <agraf@suse.de>
To: Aashish Mittal <aashish.mittal4u@gmail.com>
Cc: kvm-ppc@vger.kernel.org,
	"kvm@vger.kernel.org list" <kvm@vger.kernel.org>
Subject: Re: Emulating LWZU Instruction for e500 powerpc
Date: Thu, 25 Aug 2011 14:44:50 +0000	[thread overview]
Message-ID: <1443A453-EDC5-432B-A443-16AC12C04A28@suse.de> (raw)
In-Reply-To: <CAAonZCFpf9Nv1deAafSagDPjRoLWa3haAuH4Puz1Dksmnd62ng@mail.gmail.com>


On 25.08.2011, at 04:30, Aashish Mittal wrote:

> 
> On Thu, Aug 25, 2011 at 4:04 AM, Alexander Graf <agraf@suse.de> wrote:
> 
> On 19.08.2011, at 06:45, Aashish Mittal wrote:
> 
> > Hi
> > I'm trying to emulate the lwzu instruction in e500 powerpc kvm for my project .
> > I've removed the read and write privileges from the tlb entries of guest's
> > certain pages . So when i'm trying to emulate lwzu instruction i'm getting a
> > kernel panic while mounting the guest filesystem while booting .
> >
> > attempt to access beyond end of device
> > ram0: rw=0, wantu703268, limit&2144
> >
> > To make sure that the emulation is  faulty what i'm trying to do now is at the
> > time of DATA STORAGE exit on a marked page by an lwzu instruction i'm patching
> > the next instruction with an instruction which will raise an INTERRUPT PROGRAM
> > EXCEPTION and will get trapped in kvm and then i'm reverting the old read and
> > write privileges of this page and resuming the guest so that this LWZU
> > instruction can run natively . I'm expecting the immediate next instruction to
> > raise the INTERRUPT PROGRAM EXCEPTION but all i'm getting are DATA STORAGE Exits
> > at other pages marked by me and DTLB and ITLB misses on other addresses .
> >
> > I've made sure to flush the icache after i patch using the instruction
> > flush_icache_range .
> >
> > Error Log :
> > Emulating a lwzu instruction on pc 0xc00161ac && eaddr 0xc05742f0
> > Original Instruction is 0x90e60004 at pc: 0xc00161b0
> > Modified Instruction is 0x7ce000a6 at pc: 0xc00161b0
> > Exit : Interrupt DATA STORAGE at pc 0xc000f210 on eaddr:0xc000f228 instruction:
> > 0x8085001c
> >
> > Why i'm not getting any INTERRUPT PROGRAM EXCEPTION immediately in the next
> > instruction ?
> 
> Hrm. Are you sure you're actually modifying the instruction? This looks like you're running Linux, so you could try and just put a "b ." instruction right after the instruction you're trying to patch up and examine memory from Qemu :)
> 
> 
> Alex
> 
> I checked the memory by reading the guest page at the modified instruction and it is the modified instruction . I think the reason i'm not getting the EXIT is because the icache is not getting flushed properly. 
> I'm trying to to flush the icache entries of the guest while i'm inside the host kvm . I'm trying to use flush_icache_range(pc , pc+ 4 ) where this pc  is the guest pc eaddr where i'm modifying the instruction . 
> 
> Do you have any idea how to flush the guest entries while i'm inside the host os given the guest eaddr of the address where i'm trying to patch the instruction . 

You need to do the icache flush on the effective address you were writing to, not the guest effective address :)


Alex


  parent reply	other threads:[~2011-08-25 14:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 11:45 Emulating LWZU Instruction for e500 powerpc Aashish Mittal
2011-08-24 22:34 ` Alexander Graf
2011-08-24 22:34   ` Alexander Graf
     [not found]   ` <CAAonZCFpf9Nv1deAafSagDPjRoLWa3haAuH4Puz1Dksmnd62ng@mail.gmail.com>
2011-08-25 14:44     ` Alexander Graf [this message]
2011-08-25 14:44       ` Alexander Graf
2011-08-25  9:31 ` Aashish Mittal
2011-08-25 16:44 ` Scott Wood

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=1443A453-EDC5-432B-A443-16AC12C04A28@suse.de \
    --to=agraf@suse.de \
    --cc=aashish.mittal4u@gmail.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.