Commit d2889a3efc3851e62de69cb9d88fb784c28e0ed8

Authored by blueswir1
1 parent 24be5ae3

Alignment check mechanism (not fully enabled yet) (Aurelien Jarno)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2655 c046a42c-6fe2-441c-8c8c-71466251a162
target-sparc/cpu.h
... ... @@ -35,6 +35,7 @@
35 35 #define TT_NFPU_INSN 0x04
36 36 #define TT_WIN_OVF 0x05
37 37 #define TT_WIN_UNF 0x06
  38 +#define TT_UNALIGNED 0x07
38 39 #define TT_FP_EXCP 0x08
39 40 #define TT_DFAULT 0x09
40 41 #define TT_TOVF 0x0a
... ... @@ -55,6 +56,7 @@
55 56 #define TT_DFAULT 0x30
56 57 #define TT_DMISS 0x31
57 58 #define TT_DPROT 0x32
  59 +#define TT_UNALIGNED 0x34
58 60 #define TT_PRIV_ACT 0x37
59 61 #define TT_EXTINT 0x40
60 62 #define TT_SPILL 0x80
... ...
target-sparc/op.c
... ... @@ -1486,7 +1486,10 @@ void OPPROTO op_movl_npc_im(void)
1486 1486  
1487 1487 void OPPROTO op_movl_npc_T0(void)
1488 1488 {
1489   - env->npc = T0;
  1489 + if (T0 & 0x3)
  1490 + raise_exception(TT_UNALIGNED);
  1491 + else
  1492 + env->npc = T0;
1490 1493 }
1491 1494  
1492 1495 void OPPROTO op_mov_pc_npc(void)
... ...
target-sparc/op_helper.c
... ... @@ -923,7 +923,11 @@ void do_interrupt(int intno)
923 923  
924 924 #if !defined(CONFIG_USER_ONLY)
925 925  
  926 +static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
  927 + void *retaddr);
  928 +
926 929 #define MMUSUFFIX _mmu
  930 +#define ALIGNED_ONLY
927 931 #define GETPC() (__builtin_return_address(0))
928 932  
929 933 #define SHIFT 0
... ... @@ -938,6 +942,14 @@ void do_interrupt(int intno)
938 942 #define SHIFT 3
939 943 #include "softmmu_template.h"
940 944  
  945 +static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
  946 + void *retaddr)
  947 +{
  948 + /* Uncomment the following line to enable mem_address_not_aligned traps */
  949 + /* Not enabled yet because of bugs in OpenBIOS */
  950 + //raise_exception(TT_UNALIGNED);
  951 + //printf("Unaligned access to 0x%x from 0x%x\n", addr, env->pc);
  952 +}
941 953  
942 954 /* try to fill the TLB and return an exception if error. If retaddr is
943 955 NULL, it means that the function was called in C code (i.e. not
... ...
target-sparc/translate.c
... ... @@ -25,7 +25,6 @@
25 25 Rest of V9 instructions, VIS instructions
26 26 NPC/PC static optimisations (use JUMP_TB when possible)
27 27 Optimize synthetic instructions
28   - Optional alignment check
29 28 128-bit float
30 29 */
31 30  
... ...