misalignment.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  1. /* MN10300 Misalignment fixup handler
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/sched.h>
  13. #include <linux/kernel.h>
  14. #include <linux/string.h>
  15. #include <linux/errno.h>
  16. #include <linux/ptrace.h>
  17. #include <linux/timer.h>
  18. #include <linux/mm.h>
  19. #include <linux/smp.h>
  20. #include <linux/init.h>
  21. #include <linux/delay.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/pci.h>
  25. #include <asm/processor.h>
  26. #include <asm/system.h>
  27. #include <asm/uaccess.h>
  28. #include <asm/io.h>
  29. #include <asm/atomic.h>
  30. #include <asm/smp.h>
  31. #include <asm/pgalloc.h>
  32. #include <asm/cpu-regs.h>
  33. #include <asm/busctl-regs.h>
  34. #include <asm/fpu.h>
  35. #include <asm/gdb-stub.h>
  36. #include <asm/asm-offsets.h>
  37. #if 0
  38. #define kdebug(FMT, ...) printk(KERN_DEBUG "MISALIGN: "FMT"\n", ##__VA_ARGS__)
  39. #else
  40. #define kdebug(FMT, ...) do {} while (0)
  41. #endif
  42. static int misalignment_addr(unsigned long *registers, unsigned long sp,
  43. unsigned params, unsigned opcode,
  44. unsigned long disp,
  45. void **_address, unsigned long **_postinc,
  46. unsigned long *_inc);
  47. static int misalignment_reg(unsigned long *registers, unsigned params,
  48. unsigned opcode, unsigned long disp,
  49. unsigned long **_register);
  50. static void misalignment_MOV_Lcc(struct pt_regs *regs, uint32_t opcode);
  51. static const unsigned Dreg_index[] = {
  52. REG_D0 >> 2, REG_D1 >> 2, REG_D2 >> 2, REG_D3 >> 2
  53. };
  54. static const unsigned Areg_index[] = {
  55. REG_A0 >> 2, REG_A1 >> 2, REG_A2 >> 2, REG_A3 >> 2
  56. };
  57. static const unsigned Rreg_index[] = {
  58. REG_E0 >> 2, REG_E1 >> 2, REG_E2 >> 2, REG_E3 >> 2,
  59. REG_E4 >> 2, REG_E5 >> 2, REG_E6 >> 2, REG_E7 >> 2,
  60. REG_A0 >> 2, REG_A1 >> 2, REG_A2 >> 2, REG_A3 >> 2,
  61. REG_D0 >> 2, REG_D1 >> 2, REG_D2 >> 2, REG_D3 >> 2
  62. };
  63. enum format_id {
  64. FMT_S0,
  65. FMT_S1,
  66. FMT_S2,
  67. FMT_S4,
  68. FMT_D0,
  69. FMT_D1,
  70. FMT_D2,
  71. FMT_D4,
  72. FMT_D6,
  73. FMT_D7,
  74. FMT_D8,
  75. FMT_D9,
  76. FMT_D10,
  77. };
  78. static const struct {
  79. u_int8_t opsz, dispsz;
  80. } format_tbl[16] = {
  81. [FMT_S0] = { 8, 0 },
  82. [FMT_S1] = { 8, 8 },
  83. [FMT_S2] = { 8, 16 },
  84. [FMT_S4] = { 8, 32 },
  85. [FMT_D0] = { 16, 0 },
  86. [FMT_D1] = { 16, 8 },
  87. [FMT_D2] = { 16, 16 },
  88. [FMT_D4] = { 16, 32 },
  89. [FMT_D6] = { 24, 0 },
  90. [FMT_D7] = { 24, 8 },
  91. [FMT_D8] = { 24, 24 },
  92. [FMT_D9] = { 24, 32 },
  93. [FMT_D10] = { 32, 0 },
  94. };
  95. enum value_id {
  96. DM0, /* data reg in opcode in bits 0-1 */
  97. DM1, /* data reg in opcode in bits 2-3 */
  98. DM2, /* data reg in opcode in bits 4-5 */
  99. AM0, /* addr reg in opcode in bits 0-1 */
  100. AM1, /* addr reg in opcode in bits 2-3 */
  101. AM2, /* addr reg in opcode in bits 4-5 */
  102. RM0, /* reg in opcode in bits 0-3 */
  103. RM1, /* reg in opcode in bits 2-5 */
  104. RM2, /* reg in opcode in bits 4-7 */
  105. RM4, /* reg in opcode in bits 8-11 */
  106. RM6, /* reg in opcode in bits 12-15 */
  107. RD0, /* reg in displacement in bits 0-3 */
  108. RD2, /* reg in displacement in bits 4-7 */
  109. SP, /* stack pointer */
  110. SD8, /* 8-bit signed displacement */
  111. SD16, /* 16-bit signed displacement */
  112. SD24, /* 24-bit signed displacement */
  113. SIMM4_2, /* 4-bit signed displacement in opcode bits 4-7 */
  114. SIMM8, /* 8-bit signed immediate */
  115. IMM8, /* 8-bit unsigned immediate */
  116. IMM16, /* 16-bit unsigned immediate */
  117. IMM24, /* 24-bit unsigned immediate */
  118. IMM32, /* 32-bit unsigned immediate */
  119. IMM32_HIGH8, /* 32-bit unsigned immediate, LSB in opcode */
  120. IMM32_MEM, /* 32-bit unsigned displacement */
  121. IMM32_HIGH8_MEM, /* 32-bit unsigned displacement, LSB in opcode */
  122. DN0 = DM0,
  123. DN1 = DM1,
  124. DN2 = DM2,
  125. AN0 = AM0,
  126. AN1 = AM1,
  127. AN2 = AM2,
  128. RN0 = RM0,
  129. RN1 = RM1,
  130. RN2 = RM2,
  131. RN4 = RM4,
  132. RN6 = RM6,
  133. DI = DM1,
  134. RI = RM2,
  135. };
  136. struct mn10300_opcode {
  137. const char name[8];
  138. u_int32_t opcode;
  139. u_int32_t opmask;
  140. unsigned exclusion;
  141. enum format_id format;
  142. unsigned cpu_mask;
  143. #define AM33 330
  144. unsigned params[2];
  145. #define MEM(ADDR) (0x80000000 | (ADDR))
  146. #define MEM2(ADDR1, ADDR2) (0x80000000 | (ADDR1) << 8 | (ADDR2))
  147. #define MEMINC(ADDR) (0x81000000 | (ADDR))
  148. #define MEMINC2(ADDR, INC) (0x81000000 | (ADDR) << 8 | (INC))
  149. };
  150. /* LIBOPCODES EXCERPT
  151. Assemble Matsushita MN10300 instructions.
  152. Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
  153. This program is free software; you can redistribute it and/or modify
  154. it under the terms of the GNU General Public Licence as published by
  155. the Free Software Foundation; either version 2 of the Licence, or
  156. (at your option) any later version.
  157. This program is distributed in the hope that it will be useful,
  158. but WITHOUT ANY WARRANTY; without even the implied warranty of
  159. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  160. GNU General Public Licence for more details.
  161. You should have received a copy of the GNU General Public Licence
  162. along with this program; if not, write to the Free Software
  163. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  164. */
  165. static const struct mn10300_opcode mn10300_opcodes[] = {
  166. { "mov", 0x4200, 0xf300, 0, FMT_S1, 0, {DM1, MEM2(IMM8, SP)}},
  167. { "mov", 0x4300, 0xf300, 0, FMT_S1, 0, {AM1, MEM2(IMM8, SP)}},
  168. { "mov", 0x5800, 0xfc00, 0, FMT_S1, 0, {MEM2(IMM8, SP), DN0}},
  169. { "mov", 0x5c00, 0xfc00, 0, FMT_S1, 0, {MEM2(IMM8, SP), AN0}},
  170. { "mov", 0x60, 0xf0, 0, FMT_S0, 0, {DM1, MEM(AN0)}},
  171. { "mov", 0x70, 0xf0, 0, FMT_S0, 0, {MEM(AM0), DN1}},
  172. { "mov", 0xf000, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), AN1}},
  173. { "mov", 0xf010, 0xfff0, 0, FMT_D0, 0, {AM1, MEM(AN0)}},
  174. { "mov", 0xf300, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), DN2}},
  175. { "mov", 0xf340, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}},
  176. { "mov", 0xf380, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), AN2}},
  177. { "mov", 0xf3c0, 0xffc0, 0, FMT_D0, 0, {AM2, MEM2(DI, AN0)}},
  178. { "mov", 0xf80000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}},
  179. { "mov", 0xf81000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}},
  180. { "mov", 0xf82000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8,AM0), AN1}},
  181. { "mov", 0xf83000, 0xfff000, 0, FMT_D1, 0, {AM1, MEM2(SD8, AN0)}},
  182. { "mov", 0xf90a00, 0xffff00, 0, FMT_D6, AM33, {MEM(RM0), RN2}},
  183. { "mov", 0xf91a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEM(RN0)}},
  184. { "mov", 0xf96a00, 0xffff00, 0x12, FMT_D6, AM33, {MEMINC(RM0), RN2}},
  185. { "mov", 0xf97a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEMINC(RN0)}},
  186. { "mov", 0xfa000000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}},
  187. { "mov", 0xfa100000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}},
  188. { "mov", 0xfa200000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), AN1}},
  189. { "mov", 0xfa300000, 0xfff00000, 0, FMT_D2, 0, {AM1, MEM2(SD16, AN0)}},
  190. { "mov", 0xfa900000, 0xfff30000, 0, FMT_D2, 0, {AM1, MEM2(IMM16, SP)}},
  191. { "mov", 0xfa910000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}},
  192. { "mov", 0xfab00000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), AN0}},
  193. { "mov", 0xfab40000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}},
  194. { "mov", 0xfb0a0000, 0xffff0000, 0, FMT_D7, AM33, {MEM2(SD8, RM0), RN2}},
  195. { "mov", 0xfb1a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEM2(SD8, RN0)}},
  196. { "mov", 0xfb6a0000, 0xffff0000, 0x22, FMT_D7, AM33, {MEMINC2 (RM0, SIMM8), RN2}},
  197. { "mov", 0xfb7a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEMINC2 (RN0, SIMM8)}},
  198. { "mov", 0xfb8a0000, 0xffff0f00, 0, FMT_D7, AM33, {MEM2(IMM8, SP), RN2}},
  199. { "mov", 0xfb8e0000, 0xffff000f, 0, FMT_D7, AM33, {MEM2(RI, RM0), RD2}},
  200. { "mov", 0xfb9a0000, 0xffff0f00, 0, FMT_D7, AM33, {RM2, MEM2(IMM8, SP)}},
  201. { "mov", 0xfb9e0000, 0xffff000f, 0, FMT_D7, AM33, {RD2, MEM2(RI, RN0)}},
  202. { "mov", 0xfc000000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}},
  203. { "mov", 0xfc100000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}},
  204. { "mov", 0xfc200000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), AN1}},
  205. { "mov", 0xfc300000, 0xfff00000, 0, FMT_D4, 0, {AM1, MEM2(IMM32,AN0)}},
  206. { "mov", 0xfc800000, 0xfff30000, 0, FMT_D4, 0, {AM1, MEM(IMM32_MEM)}},
  207. { "mov", 0xfc810000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}},
  208. { "mov", 0xfc900000, 0xfff30000, 0, FMT_D4, 0, {AM1, MEM2(IMM32, SP)}},
  209. { "mov", 0xfc910000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}},
  210. { "mov", 0xfca00000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), AN0}},
  211. { "mov", 0xfca40000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}},
  212. { "mov", 0xfcb00000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), AN0}},
  213. { "mov", 0xfcb40000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}},
  214. { "mov", 0xfd0a0000, 0xffff0000, 0, FMT_D8, AM33, {MEM2(SD24, RM0), RN2}},
  215. { "mov", 0xfd1a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEM2(SD24, RN0)}},
  216. { "mov", 0xfd6a0000, 0xffff0000, 0x22, FMT_D8, AM33, {MEMINC2 (RM0, IMM24), RN2}},
  217. { "mov", 0xfd7a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEMINC2 (RN0, IMM24)}},
  218. { "mov", 0xfd8a0000, 0xffff0f00, 0, FMT_D8, AM33, {MEM2(IMM24, SP), RN2}},
  219. { "mov", 0xfd9a0000, 0xffff0f00, 0, FMT_D8, AM33, {RM2, MEM2(IMM24, SP)}},
  220. { "mov", 0xfe0a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}},
  221. { "mov", 0xfe0a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}},
  222. { "mov", 0xfe0e0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM(IMM32_HIGH8_MEM), RN2}},
  223. { "mov", 0xfe1a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}},
  224. { "mov", 0xfe1a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}},
  225. { "mov", 0xfe1e0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM(IMM32_HIGH8_MEM)}},
  226. { "mov", 0xfe6a0000, 0xffff0000, 0x22, FMT_D9, AM33, {MEMINC2 (RM0, IMM32_HIGH8), RN2}},
  227. { "mov", 0xfe7a0000, 0xffff0000, 0, FMT_D9, AM33, {RN2, MEMINC2 (RM0, IMM32_HIGH8)}},
  228. { "mov", 0xfe8a0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8, SP), RN2}},
  229. { "mov", 0xfe9a0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, SP)}},
  230. { "movhu", 0xf060, 0xfff0, 0, FMT_D0, 0, {MEM(AM0), DN1}},
  231. { "movhu", 0xf070, 0xfff0, 0, FMT_D0, 0, {DM1, MEM(AN0)}},
  232. { "movhu", 0xf480, 0xffc0, 0, FMT_D0, 0, {MEM2(DI, AM0), DN2}},
  233. { "movhu", 0xf4c0, 0xffc0, 0, FMT_D0, 0, {DM2, MEM2(DI, AN0)}},
  234. { "movhu", 0xf86000, 0xfff000, 0, FMT_D1, 0, {MEM2(SD8, AM0), DN1}},
  235. { "movhu", 0xf87000, 0xfff000, 0, FMT_D1, 0, {DM1, MEM2(SD8, AN0)}},
  236. { "movhu", 0xf89300, 0xfff300, 0, FMT_D1, 0, {DM1, MEM2(IMM8, SP)}},
  237. { "movhu", 0xf8bc00, 0xfffc00, 0, FMT_D1, 0, {MEM2(IMM8, SP), DN0}},
  238. { "movhu", 0xf94a00, 0xffff00, 0, FMT_D6, AM33, {MEM(RM0), RN2}},
  239. { "movhu", 0xf95a00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEM(RN0)}},
  240. { "movhu", 0xf9ea00, 0xffff00, 0x12, FMT_D6, AM33, {MEMINC(RM0), RN2}},
  241. { "movhu", 0xf9fa00, 0xffff00, 0, FMT_D6, AM33, {RM2, MEMINC(RN0)}},
  242. { "movhu", 0xfa600000, 0xfff00000, 0, FMT_D2, 0, {MEM2(SD16, AM0), DN1}},
  243. { "movhu", 0xfa700000, 0xfff00000, 0, FMT_D2, 0, {DM1, MEM2(SD16, AN0)}},
  244. { "movhu", 0xfa930000, 0xfff30000, 0, FMT_D2, 0, {DM1, MEM2(IMM16, SP)}},
  245. { "movhu", 0xfabc0000, 0xfffc0000, 0, FMT_D2, 0, {MEM2(IMM16, SP), DN0}},
  246. { "movhu", 0xfb4a0000, 0xffff0000, 0, FMT_D7, AM33, {MEM2(SD8, RM0), RN2}},
  247. { "movhu", 0xfb5a0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEM2(SD8, RN0)}},
  248. { "movhu", 0xfbca0000, 0xffff0f00, 0, FMT_D7, AM33, {MEM2(IMM8, SP), RN2}},
  249. { "movhu", 0xfbce0000, 0xffff000f, 0, FMT_D7, AM33, {MEM2(RI, RM0), RD2}},
  250. { "movhu", 0xfbda0000, 0xffff0f00, 0, FMT_D7, AM33, {RM2, MEM2(IMM8, SP)}},
  251. { "movhu", 0xfbde0000, 0xffff000f, 0, FMT_D7, AM33, {RD2, MEM2(RI, RN0)}},
  252. { "movhu", 0xfbea0000, 0xffff0000, 0x22, FMT_D7, AM33, {MEMINC2 (RM0, SIMM8), RN2}},
  253. { "movhu", 0xfbfa0000, 0xffff0000, 0, FMT_D7, AM33, {RM2, MEMINC2 (RN0, SIMM8)}},
  254. { "movhu", 0xfc600000, 0xfff00000, 0, FMT_D4, 0, {MEM2(IMM32,AM0), DN1}},
  255. { "movhu", 0xfc700000, 0xfff00000, 0, FMT_D4, 0, {DM1, MEM2(IMM32,AN0)}},
  256. { "movhu", 0xfc830000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM(IMM32_MEM)}},
  257. { "movhu", 0xfc930000, 0xfff30000, 0, FMT_D4, 0, {DM1, MEM2(IMM32, SP)}},
  258. { "movhu", 0xfcac0000, 0xfffc0000, 0, FMT_D4, 0, {MEM(IMM32_MEM), DN0}},
  259. { "movhu", 0xfcbc0000, 0xfffc0000, 0, FMT_D4, 0, {MEM2(IMM32, SP), DN0}},
  260. { "movhu", 0xfd4a0000, 0xffff0000, 0, FMT_D8, AM33, {MEM2(SD24, RM0), RN2}},
  261. { "movhu", 0xfd5a0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEM2(SD24, RN0)}},
  262. { "movhu", 0xfdca0000, 0xffff0f00, 0, FMT_D8, AM33, {MEM2(IMM24, SP), RN2}},
  263. { "movhu", 0xfdda0000, 0xffff0f00, 0, FMT_D8, AM33, {RM2, MEM2(IMM24, SP)}},
  264. { "movhu", 0xfdea0000, 0xffff0000, 0x22, FMT_D8, AM33, {MEMINC2 (RM0, IMM24), RN2}},
  265. { "movhu", 0xfdfa0000, 0xffff0000, 0, FMT_D8, AM33, {RM2, MEMINC2 (RN0, IMM24)}},
  266. { "movhu", 0xfe4a0000, 0xffff0000, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8,RM0), RN2}},
  267. { "movhu", 0xfe4e0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM(IMM32_HIGH8_MEM), RN2}},
  268. { "movhu", 0xfe5a0000, 0xffff0000, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, RN0)}},
  269. { "movhu", 0xfe5e0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM(IMM32_HIGH8_MEM)}},
  270. { "movhu", 0xfeca0000, 0xffff0f00, 0, FMT_D9, AM33, {MEM2(IMM32_HIGH8, SP), RN2}},
  271. { "movhu", 0xfeda0000, 0xffff0f00, 0, FMT_D9, AM33, {RM2, MEM2(IMM32_HIGH8, SP)}},
  272. { "movhu", 0xfeea0000, 0xffff0000, 0x22, FMT_D9, AM33, {MEMINC2 (RM0, IMM32_HIGH8), RN2}},
  273. { "movhu", 0xfefa0000, 0xffff0000, 0, FMT_D9, AM33, {RN2, MEMINC2 (RM0, IMM32_HIGH8)}},
  274. { "mov_llt", 0xf7e00000, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  275. { "mov_lgt", 0xf7e00001, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  276. { "mov_lge", 0xf7e00002, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  277. { "mov_lle", 0xf7e00003, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  278. { "mov_lcs", 0xf7e00004, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  279. { "mov_lhi", 0xf7e00005, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  280. { "mov_lcc", 0xf7e00006, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  281. { "mov_lls", 0xf7e00007, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  282. { "mov_leq", 0xf7e00008, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  283. { "mov_lne", 0xf7e00009, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  284. { "mov_lra", 0xf7e0000a, 0xffff000f, 0x22, FMT_D10, AM33, {MEMINC2 (RN4,SIMM4_2), RM6}},
  285. { "", 0, 0, 0, 0, 0, {0}},
  286. };
  287. /*
  288. * fix up misalignment problems where possible
  289. */
  290. asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code)
  291. {
  292. const struct exception_table_entry *fixup;
  293. const struct mn10300_opcode *pop;
  294. unsigned long *registers = (unsigned long *) regs;
  295. unsigned long data, *store, *postinc, disp, inc, sp;
  296. mm_segment_t seg;
  297. siginfo_t info;
  298. uint32_t opcode, noc, xo, xm;
  299. uint8_t *pc, byte, datasz;
  300. void *address;
  301. unsigned tmp, npop, dispsz, loop;
  302. /* we don't fix up userspace misalignment faults */
  303. if (user_mode(regs))
  304. goto bus_error;
  305. sp = (unsigned long) regs + sizeof(*regs);
  306. kdebug("==>misalignment({pc=%lx,sp=%lx})", regs->pc, sp);
  307. if (regs->epsw & EPSW_IE)
  308. asm volatile("or %0,epsw" : : "i"(EPSW_IE));
  309. seg = get_fs();
  310. set_fs(KERNEL_DS);
  311. fixup = search_exception_tables(regs->pc);
  312. /* first thing to do is to match the opcode */
  313. pc = (u_int8_t *) regs->pc;
  314. if (__get_user(byte, pc) != 0)
  315. goto fetch_error;
  316. opcode = byte;
  317. noc = 8;
  318. for (pop = mn10300_opcodes; pop->name[0]; pop++) {
  319. npop = ilog2(pop->opcode | pop->opmask);
  320. if (npop <= 0 || npop > 31)
  321. continue;
  322. npop = (npop + 8) & ~7;
  323. got_more_bits:
  324. if (npop == noc) {
  325. if ((opcode & pop->opmask) == pop->opcode)
  326. goto found_opcode;
  327. } else if (npop > noc) {
  328. xo = pop->opcode >> (npop - noc);
  329. xm = pop->opmask >> (npop - noc);
  330. if ((opcode & xm) != xo)
  331. continue;
  332. /* we've got a partial match (an exact match on the
  333. * first N bytes), so we need to get some more data */
  334. pc++;
  335. if (__get_user(byte, pc) != 0)
  336. goto fetch_error;
  337. opcode = opcode << 8 | byte;
  338. noc += 8;
  339. goto got_more_bits;
  340. } else {
  341. /* there's already been a partial match as long as the
  342. * complete match we're now considering, so this one
  343. * should't match */
  344. continue;
  345. }
  346. }
  347. /* didn't manage to find a fixup */
  348. printk(KERN_CRIT "MISALIGN: %lx: unsupported instruction %x\n",
  349. regs->pc, opcode);
  350. failed:
  351. set_fs(seg);
  352. if (die_if_no_fixup("misalignment error", regs, code))
  353. return;
  354. bus_error:
  355. info.si_signo = SIGBUS;
  356. info.si_errno = 0;
  357. info.si_code = BUS_ADRALN;
  358. info.si_addr = (void *) regs->pc;
  359. force_sig_info(SIGBUS, &info, current);
  360. return;
  361. /* error reading opcodes */
  362. fetch_error:
  363. printk(KERN_CRIT
  364. "MISALIGN: %p: fault whilst reading instruction data\n",
  365. pc);
  366. goto failed;
  367. bad_addr_mode:
  368. printk(KERN_CRIT
  369. "MISALIGN: %lx: unsupported addressing mode %x\n",
  370. regs->pc, opcode);
  371. goto failed;
  372. bad_reg_mode:
  373. printk(KERN_CRIT
  374. "MISALIGN: %lx: unsupported register mode %x\n",
  375. regs->pc, opcode);
  376. goto failed;
  377. unsupported_instruction:
  378. printk(KERN_CRIT
  379. "MISALIGN: %lx: unsupported instruction %x (%s)\n",
  380. regs->pc, opcode, pop->name);
  381. goto failed;
  382. transfer_failed:
  383. set_fs(seg);
  384. if (fixup) {
  385. regs->pc = fixup->fixup;
  386. return;
  387. }
  388. if (die_if_no_fixup("misalignment fixup", regs, code))
  389. return;
  390. info.si_signo = SIGSEGV;
  391. info.si_errno = 0;
  392. info.si_code = 0;
  393. info.si_addr = (void *) regs->pc;
  394. force_sig_info(SIGSEGV, &info, current);
  395. return;
  396. /* we matched the opcode */
  397. found_opcode:
  398. kdebug("%lx: %x==%x { %x, %x }",
  399. regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]);
  400. tmp = format_tbl[pop->format].opsz;
  401. BUG_ON(tmp > noc); /* match was less complete than it ought to have been */
  402. if (tmp < noc) {
  403. tmp = noc - tmp;
  404. opcode >>= tmp;
  405. pc -= tmp >> 3;
  406. }
  407. /* grab the extra displacement (note it's LSB first) */
  408. disp = 0;
  409. dispsz = format_tbl[pop->format].dispsz;
  410. for (loop = 0; loop < dispsz; loop += 8) {
  411. pc++;
  412. if (__get_user(byte, pc) != 0)
  413. goto fetch_error;
  414. disp |= byte << loop;
  415. kdebug("{%p} disp[%02x]=%02x", pc, loop, byte);
  416. }
  417. kdebug("disp=%lx", disp);
  418. set_fs(KERNEL_XDS);
  419. if (fixup)
  420. set_fs(seg);
  421. tmp = (pop->params[0] ^ pop->params[1]) & 0x80000000;
  422. if (!tmp) {
  423. printk(KERN_CRIT
  424. "MISALIGN: %lx: insn not move to/from memory %x\n",
  425. regs->pc, opcode);
  426. goto failed;
  427. }
  428. /* determine the data transfer size of the move */
  429. if (pop->name[3] == 0 || /* "mov" */
  430. pop->name[4] == 'l') /* mov_lcc */
  431. inc = datasz = 4;
  432. else if (pop->name[3] == 'h') /* movhu */
  433. inc = datasz = 2;
  434. else
  435. goto unsupported_instruction;
  436. if (pop->params[0] & 0x80000000) {
  437. /* move memory to register */
  438. if (!misalignment_addr(registers, sp,
  439. pop->params[0], opcode, disp,
  440. &address, &postinc, &inc))
  441. goto bad_addr_mode;
  442. if (!misalignment_reg(registers, pop->params[1], opcode, disp,
  443. &store))
  444. goto bad_reg_mode;
  445. kdebug("mov%u (%p),DARn", datasz, address);
  446. if (copy_from_user(&data, (void *) address, datasz) != 0)
  447. goto transfer_failed;
  448. if (pop->params[0] & 0x1000000) {
  449. kdebug("inc=%lx", inc);
  450. *postinc += inc;
  451. }
  452. *store = data;
  453. kdebug("loaded %lx", data);
  454. } else {
  455. /* move register to memory */
  456. if (!misalignment_reg(registers, pop->params[0], opcode, disp,
  457. &store))
  458. goto bad_reg_mode;
  459. if (!misalignment_addr(registers, sp,
  460. pop->params[1], opcode, disp,
  461. &address, &postinc, &inc))
  462. goto bad_addr_mode;
  463. data = *store;
  464. kdebug("mov%u %lx,(%p)", datasz, data, address);
  465. if (copy_to_user((void *) address, &data, datasz) != 0)
  466. goto transfer_failed;
  467. if (pop->params[1] & 0x1000000)
  468. *postinc += inc;
  469. }
  470. tmp = format_tbl[pop->format].opsz + format_tbl[pop->format].dispsz;
  471. regs->pc += tmp >> 3;
  472. /* handle MOV_Lcc, which are currently the only FMT_D10 insns that
  473. * access memory */
  474. if (pop->format == FMT_D10)
  475. misalignment_MOV_Lcc(regs, opcode);
  476. set_fs(seg);
  477. }
  478. /*
  479. * determine the address that was being accessed
  480. */
  481. static int misalignment_addr(unsigned long *registers, unsigned long sp,
  482. unsigned params, unsigned opcode,
  483. unsigned long disp,
  484. void **_address, unsigned long **_postinc,
  485. unsigned long *_inc)
  486. {
  487. unsigned long *postinc = NULL, address = 0, tmp;
  488. if (!(params & 0x1000000)) {
  489. kdebug("noinc");
  490. *_inc = 0;
  491. _inc = NULL;
  492. }
  493. params &= 0x00ffffff;
  494. do {
  495. switch (params & 0xff) {
  496. case DM0:
  497. postinc = &registers[Dreg_index[opcode & 0x03]];
  498. address += *postinc;
  499. break;
  500. case DM1:
  501. postinc = &registers[Dreg_index[opcode >> 2 & 0x03]];
  502. address += *postinc;
  503. break;
  504. case DM2:
  505. postinc = &registers[Dreg_index[opcode >> 4 & 0x03]];
  506. address += *postinc;
  507. break;
  508. case AM0:
  509. postinc = &registers[Areg_index[opcode & 0x03]];
  510. address += *postinc;
  511. break;
  512. case AM1:
  513. postinc = &registers[Areg_index[opcode >> 2 & 0x03]];
  514. address += *postinc;
  515. break;
  516. case AM2:
  517. postinc = &registers[Areg_index[opcode >> 4 & 0x03]];
  518. address += *postinc;
  519. break;
  520. case RM0:
  521. postinc = &registers[Rreg_index[opcode & 0x0f]];
  522. address += *postinc;
  523. break;
  524. case RM1:
  525. postinc = &registers[Rreg_index[opcode >> 2 & 0x0f]];
  526. address += *postinc;
  527. break;
  528. case RM2:
  529. postinc = &registers[Rreg_index[opcode >> 4 & 0x0f]];
  530. address += *postinc;
  531. break;
  532. case RM4:
  533. postinc = &registers[Rreg_index[opcode >> 8 & 0x0f]];
  534. address += *postinc;
  535. break;
  536. case RM6:
  537. postinc = &registers[Rreg_index[opcode >> 12 & 0x0f]];
  538. address += *postinc;
  539. break;
  540. case RD0:
  541. postinc = &registers[Rreg_index[disp & 0x0f]];
  542. address += *postinc;
  543. break;
  544. case RD2:
  545. postinc = &registers[Rreg_index[disp >> 4 & 0x0f]];
  546. address += *postinc;
  547. break;
  548. case SP:
  549. address += sp;
  550. break;
  551. /* displacements are either to be added to the address
  552. * before use, or, in the case of post-inc addressing,
  553. * to be added into the base register after use */
  554. case SD8:
  555. case SIMM8:
  556. disp = (long) (int8_t) (disp & 0xff);
  557. goto displace_or_inc;
  558. case SD16:
  559. disp = (long) (int16_t) (disp & 0xffff);
  560. goto displace_or_inc;
  561. case SD24:
  562. tmp = disp << 8;
  563. asm("asr 8,%0" : "=r"(tmp) : "0"(tmp) : "cc");
  564. disp = (long) tmp;
  565. goto displace_or_inc;
  566. case SIMM4_2:
  567. tmp = opcode >> 4 & 0x0f;
  568. tmp <<= 28;
  569. asm("asr 28,%0" : "=r"(tmp) : "0"(tmp) : "cc");
  570. disp = (long) tmp;
  571. goto displace_or_inc;
  572. case IMM8:
  573. disp &= 0x000000ff;
  574. goto displace_or_inc;
  575. case IMM16:
  576. disp &= 0x0000ffff;
  577. goto displace_or_inc;
  578. case IMM24:
  579. disp &= 0x00ffffff;
  580. goto displace_or_inc;
  581. case IMM32:
  582. case IMM32_MEM:
  583. case IMM32_HIGH8:
  584. case IMM32_HIGH8_MEM:
  585. displace_or_inc:
  586. kdebug("%s %lx", _inc ? "incr" : "disp", disp);
  587. if (!_inc)
  588. address += disp;
  589. else
  590. *_inc = disp;
  591. break;
  592. default:
  593. BUG();
  594. return 0;
  595. }
  596. } while ((params >>= 8));
  597. *_address = (void *) address;
  598. *_postinc = postinc;
  599. return 1;
  600. }
  601. /*
  602. * determine the register that is acting as source/dest
  603. */
  604. static int misalignment_reg(unsigned long *registers, unsigned params,
  605. unsigned opcode, unsigned long disp,
  606. unsigned long **_register)
  607. {
  608. params &= 0x7fffffff;
  609. if (params & 0xffffff00)
  610. return 0;
  611. switch (params & 0xff) {
  612. case DM0:
  613. *_register = &registers[Dreg_index[opcode & 0x03]];
  614. break;
  615. case DM1:
  616. *_register = &registers[Dreg_index[opcode >> 2 & 0x03]];
  617. break;
  618. case DM2:
  619. *_register = &registers[Dreg_index[opcode >> 4 & 0x03]];
  620. break;
  621. case AM0:
  622. *_register = &registers[Areg_index[opcode & 0x03]];
  623. break;
  624. case AM1:
  625. *_register = &registers[Areg_index[opcode >> 2 & 0x03]];
  626. break;
  627. case AM2:
  628. *_register = &registers[Areg_index[opcode >> 4 & 0x03]];
  629. break;
  630. case RM0:
  631. *_register = &registers[Rreg_index[opcode & 0x0f]];
  632. break;
  633. case RM1:
  634. *_register = &registers[Rreg_index[opcode >> 2 & 0x0f]];
  635. break;
  636. case RM2:
  637. *_register = &registers[Rreg_index[opcode >> 4 & 0x0f]];
  638. break;
  639. case RM4:
  640. *_register = &registers[Rreg_index[opcode >> 8 & 0x0f]];
  641. break;
  642. case RM6:
  643. *_register = &registers[Rreg_index[opcode >> 12 & 0x0f]];
  644. break;
  645. case RD0:
  646. *_register = &registers[Rreg_index[disp & 0x0f]];
  647. break;
  648. case RD2:
  649. *_register = &registers[Rreg_index[disp >> 4 & 0x0f]];
  650. break;
  651. case SP:
  652. *_register = &registers[REG_SP >> 2];
  653. break;
  654. default:
  655. BUG();
  656. return 0;
  657. }
  658. return 1;
  659. }
  660. /*
  661. * handle the conditional loop part of the move-and-loop instructions
  662. */
  663. static void misalignment_MOV_Lcc(struct pt_regs *regs, uint32_t opcode)
  664. {
  665. unsigned long epsw = regs->epsw;
  666. unsigned long NxorV;
  667. kdebug("MOV_Lcc %x [flags=%lx]", opcode, epsw & 0xf);
  668. /* calculate N^V and shift onto the same bit position as Z */
  669. NxorV = ((epsw >> 3) ^ epsw >> 1) & 1;
  670. switch (opcode & 0xf) {
  671. case 0x0: /* MOV_LLT: N^V */
  672. if (NxorV)
  673. goto take_the_loop;
  674. return;
  675. case 0x1: /* MOV_LGT: ~(Z or (N^V))*/
  676. if (!((epsw & EPSW_FLAG_Z) | NxorV))
  677. goto take_the_loop;
  678. return;
  679. case 0x2: /* MOV_LGE: ~(N^V) */
  680. if (!NxorV)
  681. goto take_the_loop;
  682. return;
  683. case 0x3: /* MOV_LLE: Z or (N^V) */
  684. if ((epsw & EPSW_FLAG_Z) | NxorV)
  685. goto take_the_loop;
  686. return;
  687. case 0x4: /* MOV_LCS: C */
  688. if (epsw & EPSW_FLAG_C)
  689. goto take_the_loop;
  690. return;
  691. case 0x5: /* MOV_LHI: ~(C or Z) */
  692. if (!(epsw & (EPSW_FLAG_C | EPSW_FLAG_Z)))
  693. goto take_the_loop;
  694. return;
  695. case 0x6: /* MOV_LCC: ~C */
  696. if (!(epsw & EPSW_FLAG_C))
  697. goto take_the_loop;
  698. return;
  699. case 0x7: /* MOV_LLS: C or Z */
  700. if (epsw & (EPSW_FLAG_C | EPSW_FLAG_Z))
  701. goto take_the_loop;
  702. return;
  703. case 0x8: /* MOV_LEQ: Z */
  704. if (epsw & EPSW_FLAG_Z)
  705. goto take_the_loop;
  706. return;
  707. case 0x9: /* MOV_LNE: ~Z */
  708. if (!(epsw & EPSW_FLAG_Z))
  709. goto take_the_loop;
  710. return;
  711. case 0xa: /* MOV_LRA: always */
  712. goto take_the_loop;
  713. default:
  714. BUG();
  715. }
  716. take_the_loop:
  717. /* wind the PC back to just after the SETLB insn */
  718. kdebug("loop LAR=%lx", regs->lar);
  719. regs->pc = regs->lar - 4;
  720. }
  721. /*
  722. * misalignment handler tests
  723. */
  724. #ifdef CONFIG_TEST_MISALIGNMENT_HANDLER
  725. static u8 __initdata testbuf[512] __attribute__((aligned(16))) = {
  726. [257] = 0x11,
  727. [258] = 0x22,
  728. [259] = 0x33,
  729. [260] = 0x44,
  730. };
  731. #define ASSERTCMP(X, OP, Y) \
  732. do { \
  733. if (unlikely(!((X) OP (Y)))) { \
  734. printk(KERN_ERR "\n"); \
  735. printk(KERN_ERR "MISALIGN: Assertion failed at line %u\n", \
  736. __LINE__); \
  737. printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
  738. (unsigned long)(X), (unsigned long)(Y)); \
  739. BUG(); \
  740. } \
  741. } while(0)
  742. static int __init test_misalignment(void)
  743. {
  744. register void *r asm("e0");
  745. register u32 y asm("e1");
  746. void *p = testbuf, *q;
  747. u32 tmp, tmp2, x;
  748. printk(KERN_NOTICE "==>test_misalignment() [testbuf=%p]\n", p);
  749. p++;
  750. printk(KERN_NOTICE "___ MOV (Am),Dn ___\n");
  751. q = p + 256;
  752. asm volatile("mov (%0),%1" : "+a"(q), "=d"(x));
  753. ASSERTCMP(q, ==, p + 256);
  754. ASSERTCMP(x, ==, 0x44332211);
  755. printk(KERN_NOTICE "___ MOV (256,Am),Dn ___\n");
  756. q = p;
  757. asm volatile("mov (256,%0),%1" : "+a"(q), "=d"(x));
  758. ASSERTCMP(q, ==, p);
  759. ASSERTCMP(x, ==, 0x44332211);
  760. printk(KERN_NOTICE "___ MOV (Di,Am),Dn ___\n");
  761. tmp = 256;
  762. q = p;
  763. asm volatile("mov (%2,%0),%1" : "+a"(q), "=d"(x), "+d"(tmp));
  764. ASSERTCMP(q, ==, p);
  765. ASSERTCMP(x, ==, 0x44332211);
  766. ASSERTCMP(tmp, ==, 256);
  767. printk(KERN_NOTICE "___ MOV (256,Rm),Rn ___\n");
  768. r = p;
  769. asm volatile("mov (256,%0),%1" : "+r"(r), "=r"(y));
  770. ASSERTCMP(r, ==, p);
  771. ASSERTCMP(y, ==, 0x44332211);
  772. printk(KERN_NOTICE "___ MOV (Rm+),Rn ___\n");
  773. r = p + 256;
  774. asm volatile("mov (%0+),%1" : "+r"(r), "=r"(y));
  775. ASSERTCMP(r, ==, p + 256 + 4);
  776. ASSERTCMP(y, ==, 0x44332211);
  777. printk(KERN_NOTICE "___ MOV (Rm+,8),Rn ___\n");
  778. r = p + 256;
  779. asm volatile("mov (%0+,8),%1" : "+r"(r), "=r"(y));
  780. ASSERTCMP(r, ==, p + 256 + 8);
  781. ASSERTCMP(y, ==, 0x44332211);
  782. printk(KERN_NOTICE "___ MOV (7,SP),Rn ___\n");
  783. asm volatile(
  784. "add -16,sp \n"
  785. "mov +0x11,%0 \n"
  786. "movbu %0,(7,sp) \n"
  787. "mov +0x22,%0 \n"
  788. "movbu %0,(8,sp) \n"
  789. "mov +0x33,%0 \n"
  790. "movbu %0,(9,sp) \n"
  791. "mov +0x44,%0 \n"
  792. "movbu %0,(10,sp) \n"
  793. "mov (7,sp),%1 \n"
  794. "add +16,sp \n"
  795. : "+a"(q), "=d"(x));
  796. ASSERTCMP(x, ==, 0x44332211);
  797. printk(KERN_NOTICE "___ MOV (259,SP),Rn ___\n");
  798. asm volatile(
  799. "add -264,sp \n"
  800. "mov +0x11,%0 \n"
  801. "movbu %0,(259,sp) \n"
  802. "mov +0x22,%0 \n"
  803. "movbu %0,(260,sp) \n"
  804. "mov +0x33,%0 \n"
  805. "movbu %0,(261,sp) \n"
  806. "mov +0x55,%0 \n"
  807. "movbu %0,(262,sp) \n"
  808. "mov (259,sp),%1 \n"
  809. "add +264,sp \n"
  810. : "+d"(tmp), "=d"(x));
  811. ASSERTCMP(x, ==, 0x55332211);
  812. printk(KERN_NOTICE "___ MOV (260,SP),Rn ___\n");
  813. asm volatile(
  814. "add -264,sp \n"
  815. "mov +0x11,%0 \n"
  816. "movbu %0,(260,sp) \n"
  817. "mov +0x22,%0 \n"
  818. "movbu %0,(261,sp) \n"
  819. "mov +0x33,%0 \n"
  820. "movbu %0,(262,sp) \n"
  821. "mov +0x55,%0 \n"
  822. "movbu %0,(263,sp) \n"
  823. "mov (260,sp),%1 \n"
  824. "add +264,sp \n"
  825. : "+d"(tmp), "=d"(x));
  826. ASSERTCMP(x, ==, 0x55332211);
  827. printk(KERN_NOTICE "___ MOV_LNE ___\n");
  828. tmp = 1;
  829. tmp2 = 2;
  830. q = p + 256;
  831. asm volatile(
  832. "setlb \n"
  833. "mov %2,%3 \n"
  834. "mov %1,%2 \n"
  835. "cmp +0,%1 \n"
  836. "mov_lne (%0+,4),%1"
  837. : "+r"(q), "+d"(tmp), "+d"(tmp2), "=d"(x)
  838. :
  839. : "cc");
  840. ASSERTCMP(q, ==, p + 256 + 12);
  841. ASSERTCMP(x, ==, 0x44332211);
  842. printk(KERN_NOTICE "___ MOV in SETLB ___\n");
  843. tmp = 1;
  844. tmp2 = 2;
  845. q = p + 256;
  846. asm volatile(
  847. "setlb \n"
  848. "mov %1,%3 \n"
  849. "mov (%0+),%1 \n"
  850. "cmp +0,%1 \n"
  851. "lne "
  852. : "+a"(q), "+d"(tmp), "+d"(tmp2), "=d"(x)
  853. :
  854. : "cc");
  855. ASSERTCMP(q, ==, p + 256 + 8);
  856. ASSERTCMP(x, ==, 0x44332211);
  857. printk(KERN_NOTICE "<==test_misalignment()\n");
  858. return 0;
  859. }
  860. arch_initcall(test_misalignment);
  861. #endif /* CONFIG_TEST_MISALIGNMENT_HANDLER */