diff options
-rw-r--r-- | arch/mn10300/mm/misalignment.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/arch/mn10300/mm/misalignment.c b/arch/mn10300/mm/misalignment.c index 32aa89dc3848..416c43baaa21 100644 --- a/arch/mn10300/mm/misalignment.c +++ b/arch/mn10300/mm/misalignment.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <asm/asm-offsets.h> | 37 | #include <asm/asm-offsets.h> |
38 | 38 | ||
39 | #if 0 | 39 | #if 0 |
40 | #define kdebug(FMT, ...) printk(KERN_DEBUG FMT, ##__VA_ARGS__) | 40 | #define kdebug(FMT, ...) printk(KERN_DEBUG "MISALIGN: "FMT"\n", ##__VA_ARGS__) |
41 | #else | 41 | #else |
42 | #define kdebug(FMT, ...) do {} while (0) | 42 | #define kdebug(FMT, ...) do {} while (0) |
43 | #endif | 43 | #endif |
@@ -50,14 +50,6 @@ static int misalignment_reg(unsigned long *registers, unsigned params, | |||
50 | unsigned opcode, unsigned disp, | 50 | unsigned opcode, unsigned disp, |
51 | unsigned long **_register); | 51 | unsigned long **_register); |
52 | 52 | ||
53 | static inline unsigned int_log2(unsigned x) | ||
54 | { | ||
55 | unsigned y; | ||
56 | asm("bsch %1,%0" : "=r"(y) : "r"(x), "0"(0)); | ||
57 | return y; | ||
58 | } | ||
59 | #define log2(x) int_log2(x) | ||
60 | |||
61 | static const unsigned Dreg_index[] = { | 53 | static const unsigned Dreg_index[] = { |
62 | REG_D0 >> 2, REG_D1 >> 2, REG_D2 >> 2, REG_D3 >> 2 | 54 | REG_D0 >> 2, REG_D1 >> 2, REG_D2 >> 2, REG_D3 >> 2 |
63 | }; | 55 | }; |
@@ -88,7 +80,7 @@ enum format_id { | |||
88 | FMT_D9, | 80 | FMT_D9, |
89 | }; | 81 | }; |
90 | 82 | ||
91 | struct { | 83 | static const struct { |
92 | u_int8_t opsz, dispsz; | 84 | u_int8_t opsz, dispsz; |
93 | } format_tbl[16] = { | 85 | } format_tbl[16] = { |
94 | [FMT_S0] = { 8, 0 }, | 86 | [FMT_S0] = { 8, 0 }, |
@@ -273,7 +265,7 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code) | |||
273 | void *address; | 265 | void *address; |
274 | unsigned tmp, npop; | 266 | unsigned tmp, npop; |
275 | 267 | ||
276 | kdebug("MISALIGN at %lx\n", regs->pc); | 268 | kdebug("==>misalignment({pc=%lx})", regs->pc); |
277 | 269 | ||
278 | if (in_interrupt()) | 270 | if (in_interrupt()) |
279 | die("Misalignment trap in interrupt context", regs, code); | 271 | die("Misalignment trap in interrupt context", regs, code); |
@@ -295,7 +287,7 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code) | |||
295 | noc = 8; | 287 | noc = 8; |
296 | 288 | ||
297 | for (pop = mn10300_opcodes; pop->name; pop++) { | 289 | for (pop = mn10300_opcodes; pop->name; pop++) { |
298 | npop = log2(pop->opcode | pop->opmask); | 290 | npop = ilog2(pop->opcode | pop->opmask); |
299 | if (npop <= 0 || npop > 31) | 291 | if (npop <= 0 || npop > 31) |
300 | continue; | 292 | continue; |
301 | npop = (npop + 8) & ~7; | 293 | npop = (npop + 8) & ~7; |
@@ -391,7 +383,7 @@ transfer_failed: | |||
391 | 383 | ||
392 | /* we matched the opcode */ | 384 | /* we matched the opcode */ |
393 | found_opcode: | 385 | found_opcode: |
394 | kdebug("MISALIGN: %lx: %x==%x { %x, %x }\n", | 386 | kdebug("%lx: %x==%x { %x, %x }", |
395 | regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]); | 387 | regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]); |
396 | 388 | ||
397 | tmp = format_tbl[pop->format].opsz; | 389 | tmp = format_tbl[pop->format].opsz; |
@@ -442,13 +434,13 @@ found_opcode: | |||
442 | goto bad_reg_mode; | 434 | goto bad_reg_mode; |
443 | 435 | ||
444 | if (strcmp(pop->name, "mov") == 0) { | 436 | if (strcmp(pop->name, "mov") == 0) { |
445 | kdebug("FIXUP: mov (%p),DARn\n", address); | 437 | kdebug("mov (%p),DARn", address); |
446 | if (copy_from_user(&data, (void *) address, 4) != 0) | 438 | if (copy_from_user(&data, (void *) address, 4) != 0) |
447 | goto transfer_failed; | 439 | goto transfer_failed; |
448 | if (pop->params[0] & 0x1000000) | 440 | if (pop->params[0] & 0x1000000) |
449 | *postinc += 4; | 441 | *postinc += 4; |
450 | } else if (strcmp(pop->name, "movhu") == 0) { | 442 | } else if (strcmp(pop->name, "movhu") == 0) { |
451 | kdebug("FIXUP: movhu (%p),DARn\n", address); | 443 | kdebug("movhu (%p),DARn", address); |
452 | data = 0; | 444 | data = 0; |
453 | if (copy_from_user(&data, (void *) address, 2) != 0) | 445 | if (copy_from_user(&data, (void *) address, 2) != 0) |
454 | goto transfer_failed; | 446 | goto transfer_failed; |
@@ -472,14 +464,13 @@ found_opcode: | |||
472 | data = *store; | 464 | data = *store; |
473 | 465 | ||
474 | if (strcmp(pop->name, "mov") == 0) { | 466 | if (strcmp(pop->name, "mov") == 0) { |
475 | kdebug("FIXUP: mov %lx,(%p)\n", data, address); | 467 | kdebug("mov %lx,(%p)", data, address); |
476 | if (copy_to_user((void *) address, &data, 4) != 0) | 468 | if (copy_to_user((void *) address, &data, 4) != 0) |
477 | goto transfer_failed; | 469 | goto transfer_failed; |
478 | if (pop->params[1] & 0x1000000) | 470 | if (pop->params[1] & 0x1000000) |
479 | *postinc += 4; | 471 | *postinc += 4; |
480 | } else if (strcmp(pop->name, "movhu") == 0) { | 472 | } else if (strcmp(pop->name, "movhu") == 0) { |
481 | kdebug("FIXUP: movhu %hx,(%p)\n", | 473 | kdebug("movhu %hx,(%p)", (uint16_t) data, address); |
482 | (uint16_t) data, address); | ||
483 | if (copy_to_user((void *) address, &data, 2) != 0) | 474 | if (copy_to_user((void *) address, &data, 2) != 0) |
484 | goto transfer_failed; | 475 | goto transfer_failed; |
485 | if (pop->params[1] & 0x1000000) | 476 | if (pop->params[1] & 0x1000000) |