[PATCH] powerpc: Emulate most Book I instructions in emulate_step()

Kumar Gala galak at kernel.crashing.org
Wed Jun 2 22:45:27 EST 2010


On Jun 2, 2010, at 6:29 AM, Paul Mackerras wrote:

> This extends the emulate_step() function to handle a large proportion
> of the Book I instructions implemented on current 64-bit server
> processors.  The aim is to handle all the load and store instructions
> used in the kernel, plus all of the instructions that appear between
> l[wd]arx and st[wd]cx., so this handles the Altivec/VMX lvx and stvx
> and the VSX lxv2dx and stxv2dx instructions (implemented in POWER7).
> 
> The new code can emulate user mode instructions, and checks the
> effective address for a load or store if the saved state is for
> user mode.  It doesn't handle little-endian mode at present.
> 
> For floating-point, Altivec/VMX and VSX instructions, it checks
> that the saved MSR has the enable bit for the relevant facility
> set, and if so, assumes that the FP/VMX/VSX registers contain
> valid state, and does loads or stores directly to/from the
> FP/VMX/VSX registers, using assembly helpers in ldstfp.S.
> 
> Instructions supported now include:
> * Loads and stores, including some but not all VMX and VSX instructions,
>  and lmw/stmw
> * Atomic loads and stores (l[dw]arx, st[dw]cx.)
> * Integer arithmetic instructions (add, subtract, multiply, divide, etc.)
> * Compare instructions
> * Rotate and mask instructions
> * Shift instructions
> * Logical instructions (and, or, xor, etc.)
> * Condition register logical instructions
> * mtcrf, cntlz[wd], exts[bhw]
> * isync, sync, lwsync, ptesync, eieio
> * Cache operations (dcbf, dcbst, dcbt, dcbtst)
> 
> The overflow-checking arithmetic instructions are not included, but
> they appear not to be ever used in C code.  None of the floating
> point, VMX or VSX computational instructions are included.
> 
> This uses decimal values for the minor opcodes in the switch statements
> because that is what appears in the Power ISA specification, thus it is
> easier to check that they are correct if they are in decimal.
> 
> Signed-off-by: Paul Mackerras <paulus at samba.org>
> ---
> arch/powerpc/lib/Makefile |    4 +-
> arch/powerpc/lib/ldstfp.S |  207 ++++++
> arch/powerpc/lib/sstep.c  | 1513 +++++++++++++++++++++++++++++++++++++++++++--
> 3 files changed, 1677 insertions(+), 47 deletions(-)
> create mode 100644 arch/powerpc/lib/ldstfp.S

Why do we need to have emu support for all of these instructions?

- k


More information about the Linuxppc-dev mailing list