KVM: PPC: BOOK3S: Use the saved dar value and generic make_dsisr
Subsystems (3)
PATCH v5 1/1 KVM: PPC: BOOK3S: Use the saved dar value and generic make_dsisr
Although it's optional IBM POWER cpus always had DAR value set on alignment interrupt. So don't try to compute these values.
Signed-off-by Aneesh Kumar K.V <[email protected]>
---
* Changes from V4
* Update comments around using fault_dar
arch/powerpc/include/asm/disassemble.h | 34 +++++++++++++++++++++++++ arch/powerpc/kernel/align.c | 34 +------------------------ arch/powerpc/kvm/book3s_emulate.c | 46 ++++++---------------------------- 3 files changed, 43 insertions(+), 71 deletions(-)
arch/powerpc/include/asm/disassemble.h +34 -0
@@ -81,4 +81,38 @@ static inline unsigned int get_oc(u32 inst) {return (inst >>11 ) &0x7fff ; } + +#define IS_XFORM (inst) (get_op(inst) == 31) +#define IS_DSFORM (inst) (get_op(inst) >= 56) + +/* +* Create a DSISR value from the instruction +*/ +static inline unsigned make_dsisr (unsigned instr) +{ +unsigned dsisr; + + +/* bits 6:15 --> 22:31 */ + dsisr = (instr &0x03ff0000 ) >>16 ; + +if (IS_XFORM (instr)) { +/* bits 29:30 --> 15:16 */ + dsisr |= (instr &0x00000006 ) <<14 ; +/* bit 25 --> 17 */ + dsisr |= (instr &0x00000040 ) <<8 ; +/* bits 21:24 --> 18:21 */ + dsisr |= (instr &0x00000780 ) <<3 ; + }else { +/* bit 5 --> 17 */ + dsisr |= (instr &0x04000000 ) >>12 ; +/* bits 1: 4 --> 18:21 */ + dsisr |= (instr &0x78000000 ) >>17 ; +/* bits 30:31 --> 12:13 */ +if (IS_DSFORM (instr)) + dsisr |= (instr &0x00000003 ) <<18 ; + } + +return dsisr; +}#endif /* __ASM_PPC_DISASSEMBLE_H__ */
arch/powerpc/kernel/align.c +1 -33
@@ -25,14 +25,13 @@#include <asm/cputable.h> #include <asm/emulated_ops.h> #include <asm/switch_to.h> +#include <asm/disassemble.h> struct aligninfo {unsigned char len;unsigned char flags; }; -#define IS_XFORM (inst) (((inst) >> 26) == 31) -#define IS_DSFORM (inst) (((inst) >> 26) >= 56)#define INVALID { 0, 0 }
@@ -192,37 +191,6 @@ static struct aligninfo aligninfo[128] = { };/* -* Create a DSISR value from the instruction -*/ -static inline unsigned make_dsisr (unsigned instr) -{ -unsigned dsisr; - - -/* bits 6:15 --> 22:31 */ - dsisr = (instr &0x03ff0000 ) >>16 ; - -if (IS_XFORM (instr)) { -/* bits 29:30 --> 15:16 */ - dsisr |= (instr &0x00000006 ) <<14 ; -/* bit 25 --> 17 */ - dsisr |= (instr &0x00000040 ) <<8 ; -/* bits 21:24 --> 18:21 */ - dsisr |= (instr &0x00000780 ) <<3 ; - }else { -/* bit 5 --> 17 */ - dsisr |= (instr &0x04000000 ) >>12 ; -/* bits 1: 4 --> 18:21 */ - dsisr |= (instr &0x78000000 ) >>17 ; -/* bits 30:31 --> 12:13 */ -if (IS_DSFORM (instr)) - dsisr |= (instr &0x00000003 ) <<18 ; - } - -return dsisr; -} - -/* * The dcbz (data cache block zero) instruction * gives an alignment fault if used on non-cacheable * memory. We handle the fault mainly for the
arch/powerpc/kvm/book3s_emulate.c +8 -38
60 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 4 lines · Aneesh Kumar K.V
Although it's optional IBM POWER cpus always had DAR value set on alignment interrupt. So don't try to compute these values.
Signed-off-by Aneesh Kumar K.V <[email protected]>
The patch body is fine now. The commit message however is not. The patch does two things:
* Merge DSISR calculation with Linux's implementation
* Use the real DAR on book3s_64 alignment interrupts
In fact, you probably should make this 2 patches.
Alex