misalignment.c 29 KB

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