misalignment.c 29 KB

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