Emulating LWZU Instruction for e500 powerpc
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 ?
Signature · 2 lines
Thanks and regards Aashish Mittal
Quoted 28 lines · Aashish Mittal
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=262144To 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 pc0xc00161ac&& eaddr0xc05742f0Original Instruction is0x90e60004at pc:0xc00161b0
Modified Instruction is0x7ce000a6at pc:0xc00161b0
Exit : Interrupt DATA STORAGE at pc0xc000f210on eaddr:0xc000f228 instruction:0x8085001c
Quoted 2 lines
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
Quoted 6 lines · Alexander Graf <agraf <at> suse.de> writes:
Quoted 2 lines · Aashish Mittal
Hi
I'm trying to emulate the lwzu instruction in e500 powerpc kvm for my
project .
Quoted 8 lines
Quoted 8 lines
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&2144To make sure that the emulation is faulty what i'm trying to do now is at
the
Quoted 1 line
Quoted 1 line
time of DATA STORAGE exit on a marked page by an lwzu instruction i'm
patching
Quoted 1 line
Quoted 1 line
the next instruction with an instruction which will raise an INTERRUPT
PROGRAM
Quoted 1 line
Quoted 1 line
EXCEPTION and will get trapped in kvm and then i'm reverting the old read
and
Quoted 2 lines
Quoted 2 lines
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
Quoted 1 line
Quoted 1 line
raise the INTERRUPT PROGRAM EXCEPTION but all i'm getting are DATA STORAGE
Exits
Quoted 10 lines
Quoted 10 lines
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 pc0xc00161ac&& eaddr0xc05742f0Original Instruction is0x90e60004at pc:0xc00161b0Modified Instruction is0x7ce000a6at pc:0xc00161b0Exit : Interrupt DATA STORAGE at pc0xc000f210on eaddr:0xc000f228
instruction:
Quoted 6 lines
Quoted 4 lines
0x8085001cWhy 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
Quoted 1 line
could try and just put a "b ." instruction right after the instruction you're
trying to patch up and examine
Quoted 5 lines
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 .
Thanks for you help
Aashish Mittal
Quoted 39 lines · Aashish Mittal
On Thu, Aug 25, 2011 at 4:04 AM, Alexander Graf <[email protected]> wrote:
Quoted 28 lines · Aashish Mittal
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&2144To 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 pc0xc00161ac&& eaddr0xc05742f0Original Instruction is0x90e60004at pc:0xc00161b0
Modified Instruction is0x7ce000a6at pc:0xc00161b0
Exit : Interrupt DATA STORAGE at pc0xc000f210on eaddr:0xc000f228 instruction:0x8085001cQuoted 2 lines
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 :)
Quoted 6 lines
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
Quoted 9 lines · Aashish Mittal
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 useflush_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 .
What address are you using to actually do the modification? You can't flush with an address on which you can't do normal memory accesses from the current context. You need an effective address that is valid in the host.
-Scott