alistair23-linux/arch/powerpc/xmon
Paul Mackerras 31cdd0c39c powerpc/xmon: Fix SPR read/write commands and add command to dump SPRs
xmon has commands for reading and writing SPRs, but they don't work
currently for several reasons. They attempt to synthesize a small
function containing an mfspr or mtspr instruction and call it. However,
the instructions are on the stack, which is usually not executable.
Also, for 64-bit we set up a procedure descriptor, which is fine for the
big-endian ABIv1, but not correct for ABIv2. Finally, the code uses the
infrastructure for catching memory errors, but that only catches data
storage interrupts and machine check interrupts, but a failed
mfspr/mtspr can generate a program interrupt or a hypervisor emulation
assist interrupt, or be a no-op.

Instead of trying to synthesize a function on the fly, this adds two new
functions, xmon_mfspr() and xmon_mtspr(), which take an SPR number as an
argument and read or write the SPR. Because there is no Power ISA
instruction which takes an SPR number in a register, we have to generate
one of each possible mfspr and mtspr instruction, for all 1024 possible
SPRs. Thus we get just over 8k bytes of code for each of xmon_mfspr()
and xmon_mtspr(). However, this 16kB of code pales in comparison to the
> 130kB of PPC opcode tables used by the xmon disassembler.

To catch interrupts caused by the mfspr/mtspr instructions, we add a new
'catch_spr_faults' flag. If an interrupt occurs while it is set, we come
back into xmon() via program_check_interrupt(), _exception() and die(),
see that catch_spr_faults is set and do a longjmp to bus_error_jmp, back
into read_spr() or write_spr().

This adds a couple of other nice features: first, a "Sa" command that
attempts to read and print out the value of all 1024 SPRs. If any mfspr
instruction acts as a no-op, then the SPR is not implemented and not
printed.

Secondly, the Sr and Sw commands detect when an SPR is not
implemented (i.e. mfspr is a no-op) and print a message to that effect
rather than printing a bogus value.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2016-05-11 21:54:07 +10:00
..
ansidecl.h powerpc: Merge xmon 2005-10-28 22:53:37 +10:00
dis-asm.h [POWERPC] Make xmon disassembly optional 2006-12-04 20:40:32 +11:00
Makefile powerpc/xmon: Fix SPR read/write commands and add command to dump SPRs 2016-05-11 21:54:07 +10:00
nonstdio.c powerpc/xmon: Paged output for paca display 2015-10-15 20:32:01 +11:00
nonstdio.h powerpc/xmon: Paged output for paca display 2015-10-15 20:32:01 +11:00
ppc-dis.c [POWERPC] Import updated version of ppc disassembly code for xmon 2006-12-04 20:40:36 +11:00
ppc-opc.c bug.h: add include of it to various implicit C users 2012-02-29 17:15:08 -05:00
ppc.h [POWERPC] Import updated version of ppc disassembly code for xmon 2006-12-04 20:40:36 +11:00
spr_access.S powerpc/xmon: Fix SPR read/write commands and add command to dump SPRs 2016-05-11 21:54:07 +10:00
spu-dis.c [PATCH] arch/powerpc trivial annotations 2007-02-09 09:14:06 -08:00
spu-insns.h [POWERPC] Import spu disassembly code into xmon 2006-12-04 20:40:29 +11:00
spu-opc.c bug.h: add include of it to various implicit C users 2012-02-29 17:15:08 -05:00
spu.h [POWERPC] Import spu disassembly code into xmon 2006-12-04 20:40:29 +11:00
xmon.c powerpc/xmon: Fix SPR read/write commands and add command to dump SPRs 2016-05-11 21:54:07 +10:00