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. if (tmp > noc)
  402. BUG(); /* match was less complete than it ought to have been */
  403. if (tmp < noc) {
  404. tmp = noc - tmp;
  405. opcode >>= tmp;
  406. pc -= tmp >> 3;
  407. }
  408. /* grab the extra displacement (note it's LSB first) */
  409. disp = 0;
  410. dispsz = format_tbl[pop->format].dispsz;
  411. for (loop = 0; loop < dispsz; loop += 8) {
  412. pc++;
  413. if (__get_user(byte, pc) != 0)
  414. goto fetch_error;
  415. disp |= byte << loop;
  416. kdebug("{%p} disp[%02x]=%02x", pc, loop, byte);
  417. }
  418. kdebug("disp=%lx", disp);
  419. set_fs(KERNEL_XDS);
  420. if (fixup)
  421. set_fs(seg);
  422. tmp = (pop->params[0] ^ pop->params[1]) & 0x80000000;
  423. if (!tmp) {
  424. printk(KERN_CRIT
  425. "MISALIGN: %lx: insn not move to/from memory %x\n",
  426. regs->pc, opcode);
  427. goto failed;
  428. }
  429. /* determine the data transfer size of the move */
  430. if (pop->name[3] == 0 || /* "mov" */
  431. pop->name[4] == 'l') /* mov_lcc */
  432. inc = datasz = 4;
  433. else if (pop->name[3] == 'h') /* movhu */
  434. inc = datasz = 2;
  435. else
  436. goto unsupported_instruction;
  437. if (pop->params[0] & 0x80000000) {
  438. /* move memory to register */
  439. if (!misalignment_addr(registers, sp,
  440. pop->params[0], opcode, disp,
  441. &address, &postinc, &inc))
  442. goto bad_addr_mode;
  443. if (!misalignment_reg(registers, pop->params[1], opcode, disp,
  444. &store))
  445. goto bad_reg_mode;
  446. kdebug("mov%u (%p),DARn", datasz, address);
  447. if (copy_from_user(&data, (void *) address, datasz) != 0)
  448. goto transfer_failed;
  449. if (pop->params[0] & 0x1000000) {
  450. kdebug("inc=%lx", inc);
  451. *postinc += inc;
  452. }
  453. *store = data;
  454. kdebug("loaded %lx", data);
  455. } else {
  456. /* move register to memory */
  457. if (!misalignment_reg(registers, pop->params[0], opcode, disp,
  458. &store))
  459. goto bad_reg_mode;
  460. if (!misalignment_addr(registers, sp,
  461. pop->params[1], opcode, disp,
  462. &address, &postinc, &inc))
  463. goto bad_addr_mode;
  464. data = *store;
  465. kdebug("mov%u %lx,(%p)", datasz, data, address);
  466. if (copy_to_user((void *) address, &data, datasz) != 0)
  467. goto transfer_failed;
  468. if (pop->params[1] & 0x1000000)
  469. *postinc += inc;
  470. }
  471. tmp = format_tbl[pop->format].opsz + format_tbl[pop->format].dispsz;
  472. regs->pc += tmp >> 3;
  473. /* handle MOV_Lcc, which are currently the only FMT_D10 insns that
  474. * access memory */
  475. if (pop->format == FMT_D10)
  476. misalignment_MOV_Lcc(regs, opcode);
  477. set_fs(seg);
  478. }
  479. /*
  480. * determine the address that was being accessed
  481. */
  482. static int misalignment_addr(unsigned long *registers, unsigned long sp,
  483. unsigned params, unsigned opcode,
  484. unsigned long disp,
  485. void **_address, unsigned long **_postinc,
  486. unsigned long *_inc)
  487. {
  488. unsigned long *postinc = NULL, address = 0, tmp;
  489. if (!(params & 0x1000000)) {
  490. kdebug("noinc");
  491. *_inc = 0;
  492. _inc = NULL;
  493. }
  494. params &= 0x00ffffff;
  495. do {
  496. switch (params & 0xff) {
  497. case DM0:
  498. postinc = &registers[Dreg_index[opcode & 0x03]];
  499. address += *postinc;
  500. break;
  501. case DM1:
  502. postinc = &registers[Dreg_index[opcode >> 2 & 0x03]];
  503. address += *postinc;
  504. break;
  505. case DM2:
  506. postinc = &registers[Dreg_index[opcode >> 4 & 0x03]];
  507. address += *postinc;
  508. break;
  509. case AM0:
  510. postinc = &registers[Areg_index[opcode & 0x03]];
  511. address += *postinc;
  512. break;
  513. case AM1:
  514. postinc = &registers[Areg_index[opcode >> 2 & 0x03]];
  515. address += *postinc;
  516. break;
  517. case AM2:
  518. postinc = &registers[Areg_index[opcode >> 4 & 0x03]];
  519. address += *postinc;
  520. break;
  521. case RM0:
  522. postinc = &registers[Rreg_index[opcode & 0x0f]];
  523. address += *postinc;
  524. break;
  525. case RM1:
  526. postinc = &registers[Rreg_index[opcode >> 2 & 0x0f]];
  527. address += *postinc;
  528. break;
  529. case RM2:
  530. postinc = &registers[Rreg_index[opcode >> 4 & 0x0f]];
  531. address += *postinc;
  532. break;
  533. case RM4:
  534. postinc = &registers[Rreg_index[opcode >> 8 & 0x0f]];
  535. address += *postinc;
  536. break;
  537. case RM6:
  538. postinc = &registers[Rreg_index[opcode >> 12 & 0x0f]];
  539. address += *postinc;
  540. break;
  541. case RD0:
  542. postinc = &registers[Rreg_index[disp & 0x0f]];
  543. address += *postinc;
  544. break;
  545. case RD2:
  546. postinc = &registers[Rreg_index[disp >> 4 & 0x0f]];
  547. address += *postinc;
  548. break;
  549. case SP:
  550. address += sp;
  551. break;
  552. /* displacements are either to be added to the address
  553. * before use, or, in the case of post-inc addressing,
  554. * to be added into the base register after use */
  555. case SD8:
  556. case SIMM8:
  557. disp = (long) (int8_t) (disp & 0xff);
  558. goto displace_or_inc;
  559. case SD16:
  560. disp = (long) (int16_t) (disp & 0xffff);
  561. goto displace_or_inc;
  562. case SD24:
  563. tmp = disp << 8;
  564. asm("asr 8,%0" : "=r"(tmp) : "0"(tmp));
  565. disp = (long) tmp;
  566. goto displace_or_inc;
  567. case SIMM4_2:
  568. tmp = opcode >> 4 & 0x0f;
  569. tmp <<= 28;
  570. asm("asr 28,%0" : "=r"(tmp) : "0"(tmp));
  571. disp = (long) tmp;
  572. goto displace_or_inc;
  573. case IMM8:
  574. disp &= 0x000000ff;
  575. goto displace_or_inc;
  576. case IMM16:
  577. disp &= 0x0000ffff;
  578. goto displace_or_inc;
  579. case IMM24:
  580. disp &= 0x00ffffff;
  581. goto displace_or_inc;
  582. case IMM32:
  583. case IMM32_MEM:
  584. case IMM32_HIGH8:
  585. case IMM32_HIGH8_MEM:
  586. displace_or_inc:
  587. kdebug("%s %lx", _inc ? "incr" : "disp", disp);
  588. if (!_inc)
  589. address += disp;
  590. else
  591. *_inc = disp;
  592. break;
  593. default:
  594. BUG();
  595. return 0;
  596. }
  597. } while ((params >>= 8));
  598. *_address = (void *) address;
  599. *_postinc = postinc;
  600. return 1;
  601. }
  602. /*
  603. * determine the register that is acting as source/dest
  604. */
  605. static int misalignment_reg(unsigned long *registers, unsigned params,
  606. unsigned opcode, unsigned long disp,
  607. unsigned long **_register)
  608. {
  609. params &= 0x7fffffff;
  610. if (params & 0xffffff00)
  611. return 0;
  612. switch (params & 0xff) {
  613. case DM0:
  614. *_register = &registers[Dreg_index[opcode & 0x03]];
  615. break;
  616. case DM1:
  617. *_register = &registers[Dreg_index[opcode >> 2 & 0x03]];
  618. break;
  619. case DM2:
  620. *_register = &registers[Dreg_index[opcode >> 4 & 0x03]];
  621. break;
  622. case AM0:
  623. *_register = &registers[Areg_index[opcode & 0x03]];
  624. break;
  625. case AM1:
  626. *_register = &registers[Areg_index[opcode >> 2 & 0x03]];
  627. break;
  628. case AM2:
  629. *_register = &registers[Areg_index[opcode >> 4 & 0x03]];
  630. break;
  631. case RM0:
  632. *_register = &registers[Rreg_index[opcode & 0x0f]];
  633. break;
  634. case RM1:
  635. *_register = &registers[Rreg_index[opcode >> 2 & 0x0f]];
  636. break;
  637. case RM2:
  638. *_register = &registers[Rreg_index[opcode >> 4 & 0x0f]];
  639. break;
  640. case RM4:
  641. *_register = &registers[Rreg_index[opcode >> 8 & 0x0f]];
  642. break;
  643. case RM6:
  644. *_register = &registers[Rreg_index[opcode >> 12 & 0x0f]];
  645. break;
  646. case RD0:
  647. *_register = &registers[Rreg_index[disp & 0x0f]];
  648. break;
  649. case RD2:
  650. *_register = &registers[Rreg_index[disp >> 4 & 0x0f]];
  651. break;
  652. case SP:
  653. *_register = &registers[REG_SP >> 2];
  654. break;
  655. default:
  656. BUG();
  657. return 0;
  658. }
  659. return 1;
  660. }
  661. /*
  662. * handle the conditional loop part of the move-and-loop instructions
  663. */
  664. static void misalignment_MOV_Lcc(struct pt_regs *regs, uint32_t opcode)
  665. {
  666. unsigned long epsw = regs->epsw;
  667. unsigned long NxorV;
  668. kdebug("MOV_Lcc %x [flags=%lx]", opcode, epsw & 0xf);
  669. /* calculate N^V and shift onto the same bit position as Z */
  670. NxorV = ((epsw >> 3) ^ epsw >> 1) & 1;
  671. switch (opcode & 0xf) {
  672. case 0x0: /* MOV_LLT: N^V */
  673. if (NxorV)
  674. goto take_the_loop;
  675. return;
  676. case 0x1: /* MOV_LGT: ~(Z or (N^V))*/
  677. if (!((epsw & EPSW_FLAG_Z) | NxorV))
  678. goto take_the_loop;
  679. return;
  680. case 0x2: /* MOV_LGE: ~(N^V) */
  681. if (!NxorV)
  682. goto take_the_loop;
  683. return;
  684. case 0x3: /* MOV_LLE: Z or (N^V) */
  685. if ((epsw & EPSW_FLAG_Z) | NxorV)
  686. goto take_the_loop;
  687. return;
  688. case 0x4: /* MOV_LCS: C */
  689. if (epsw & EPSW_FLAG_C)
  690. goto take_the_loop;
  691. return;
  692. case 0x5: /* MOV_LHI: ~(C or Z) */
  693. if (!(epsw & (EPSW_FLAG_C | EPSW_FLAG_Z)))
  694. goto take_the_loop;
  695. return;
  696. case 0x6: /* MOV_LCC: ~C */
  697. if (!(epsw & EPSW_FLAG_C))
  698. goto take_the_loop;
  699. return;
  700. case 0x7: /* MOV_LLS: C or Z */
  701. if (epsw & (EPSW_FLAG_C | EPSW_FLAG_Z))
  702. goto take_the_loop;
  703. return;
  704. case 0x8: /* MOV_LEQ: Z */
  705. if (epsw & EPSW_FLAG_Z)
  706. goto take_the_loop;
  707. return;
  708. case 0x9: /* MOV_LNE: ~Z */
  709. if (!(epsw & EPSW_FLAG_Z))
  710. goto take_the_loop;
  711. return;
  712. case 0xa: /* MOV_LRA: always */
  713. goto take_the_loop;
  714. default:
  715. BUG();
  716. }
  717. take_the_loop:
  718. /* wind the PC back to just after the SETLB insn */
  719. kdebug("loop LAR=%lx", regs->lar);
  720. regs->pc = regs->lar - 4;
  721. }
  722. /*
  723. * misalignment handler tests
  724. */
  725. #ifdef CONFIG_TEST_MISALIGNMENT_HANDLER
  726. static u8 __initdata testbuf[512] __attribute__((aligned(16))) = {
  727. [257] = 0x11,
  728. [258] = 0x22,
  729. [259] = 0x33,
  730. [260] = 0x44,
  731. };
  732. #define ASSERTCMP(X, OP, Y) \
  733. do { \
  734. if (unlikely(!((X) OP (Y)))) { \
  735. printk(KERN_ERR "\n"); \
  736. printk(KERN_ERR "MISALIGN: Assertion failed at line %u\n", \
  737. __LINE__); \
  738. printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
  739. (unsigned long)(X), (unsigned long)(Y)); \
  740. BUG(); \
  741. } \
  742. } while(0)
  743. static int __init test_misalignment(void)
  744. {
  745. register void *r asm("e0");
  746. register u32 y asm("e1");
  747. void *p = testbuf, *q;
  748. u32 tmp, tmp2, x;
  749. printk(KERN_NOTICE "==>test_misalignment() [testbuf=%p]\n", p);
  750. p++;
  751. printk(KERN_NOTICE "___ MOV (Am),Dn ___\n");
  752. q = p + 256;
  753. asm volatile("mov (%0),%1" : "+a"(q), "=d"(x));
  754. ASSERTCMP(q, ==, p + 256);
  755. ASSERTCMP(x, ==, 0x44332211);
  756. printk(KERN_NOTICE "___ MOV (256,Am),Dn ___\n");
  757. q = p;
  758. asm volatile("mov (256,%0),%1" : "+a"(q), "=d"(x));
  759. ASSERTCMP(q, ==, p);
  760. ASSERTCMP(x, ==, 0x44332211);
  761. printk(KERN_NOTICE "___ MOV (Di,Am),Dn ___\n");
  762. tmp = 256;
  763. q = p;
  764. asm volatile("mov (%2,%0),%1" : "+a"(q), "=d"(x), "+d"(tmp));
  765. ASSERTCMP(q, ==, p);
  766. ASSERTCMP(x, ==, 0x44332211);
  767. ASSERTCMP(tmp, ==, 256);
  768. printk(KERN_NOTICE "___ MOV (256,Rm),Rn ___\n");
  769. r = p;
  770. asm volatile("mov (256,%0),%1" : "+r"(r), "=r"(y));
  771. ASSERTCMP(r, ==, p);
  772. ASSERTCMP(y, ==, 0x44332211);
  773. printk(KERN_NOTICE "___ MOV (Rm+),Rn ___\n");
  774. r = p + 256;
  775. asm volatile("mov (%0+),%1" : "+r"(r), "=r"(y));
  776. ASSERTCMP(r, ==, p + 256 + 4);
  777. ASSERTCMP(y, ==, 0x44332211);
  778. printk(KERN_NOTICE "___ MOV (Rm+,8),Rn ___\n");
  779. r = p + 256;
  780. asm volatile("mov (%0+,8),%1" : "+r"(r), "=r"(y));
  781. ASSERTCMP(r, ==, p + 256 + 8);
  782. ASSERTCMP(y, ==, 0x44332211);
  783. printk(KERN_NOTICE "___ MOV (7,SP),Rn ___\n");
  784. asm volatile(
  785. "add -16,sp \n"
  786. "mov +0x11,%0 \n"
  787. "movbu %0,(7,sp) \n"
  788. "mov +0x22,%0 \n"
  789. "movbu %0,(8,sp) \n"
  790. "mov +0x33,%0 \n"
  791. "movbu %0,(9,sp) \n"
  792. "mov +0x44,%0 \n"
  793. "movbu %0,(10,sp) \n"
  794. "mov (7,sp),%1 \n"
  795. "add +16,sp \n"
  796. : "+a"(q), "=d"(x));
  797. ASSERTCMP(x, ==, 0x44332211);
  798. printk(KERN_NOTICE "___ MOV (259,SP),Rn ___\n");
  799. asm volatile(
  800. "add -264,sp \n"
  801. "mov +0x11,%0 \n"
  802. "movbu %0,(259,sp) \n"
  803. "mov +0x22,%0 \n"
  804. "movbu %0,(260,sp) \n"
  805. "mov +0x33,%0 \n"
  806. "movbu %0,(261,sp) \n"
  807. "mov +0x55,%0 \n"
  808. "movbu %0,(262,sp) \n"
  809. "mov (259,sp),%1 \n"
  810. "add +264,sp \n"
  811. : "+d"(tmp), "=d"(x));
  812. ASSERTCMP(x, ==, 0x55332211);
  813. printk(KERN_NOTICE "___ MOV (260,SP),Rn ___\n");
  814. asm volatile(
  815. "add -264,sp \n"
  816. "mov +0x11,%0 \n"
  817. "movbu %0,(260,sp) \n"
  818. "mov +0x22,%0 \n"
  819. "movbu %0,(261,sp) \n"
  820. "mov +0x33,%0 \n"
  821. "movbu %0,(262,sp) \n"
  822. "mov +0x55,%0 \n"
  823. "movbu %0,(263,sp) \n"
  824. "mov (260,sp),%1 \n"
  825. "add +264,sp \n"
  826. : "+d"(tmp), "=d"(x));
  827. ASSERTCMP(x, ==, 0x55332211);
  828. printk(KERN_NOTICE "___ MOV_LNE ___\n");
  829. tmp = 1;
  830. tmp2 = 2;
  831. q = p + 256;
  832. asm volatile(
  833. "setlb \n"
  834. "mov %2,%3 \n"
  835. "mov %1,%2 \n"
  836. "cmp +0,%1 \n"
  837. "mov_lne (%0+,4),%1"
  838. : "+r"(q), "+d"(tmp), "+d"(tmp2), "=d"(x)
  839. :
  840. : "cc");
  841. ASSERTCMP(q, ==, p + 256 + 12);
  842. ASSERTCMP(x, ==, 0x44332211);
  843. printk(KERN_NOTICE "___ MOV in SETLB ___\n");
  844. tmp = 1;
  845. tmp2 = 2;
  846. q = p + 256;
  847. asm volatile(
  848. "setlb \n"
  849. "mov %1,%3 \n"
  850. "mov (%0+),%1 \n"
  851. "cmp +0,%1 \n"
  852. "lne "
  853. : "+a"(q), "+d"(tmp), "+d"(tmp2), "=d"(x)
  854. :
  855. : "cc");
  856. ASSERTCMP(q, ==, p + 256 + 8);
  857. ASSERTCMP(x, ==, 0x44332211);
  858. printk(KERN_NOTICE "<==test_misalignment()\n");
  859. return 0;
  860. }
  861. arch_initcall(test_misalignment);
  862. #endif /* CONFIG_TEST_MISALIGNMENT_HANDLER */