Re: [PATCH] kprobes for s390 architecture

From: Heiko Carstens
Date: Mon Jul 10 2006 - 05:34:22 EST


> +static int __kprobes swap_instruction(void *aref)
> +{
> + unsigned long addr, prev, tmp;
> + int shift;
> + struct ins_replace_args *args = aref;
> +
> + addr = (unsigned long) args->ptr;
> + shift = (2 ^ (addr & 2)) << 3;
> + addr ^= addr & 2;
> + asm volatile(
> + " l %0,0(%4)\n"
> + " nr %0,%5\n"
> + " lr %1,%0\n"

Whitespace :)

> + " or %0,%2\n"
> + " or %1,%3\n"
> + "0: cs %0,%1,0(%4)\n"
> + " jnl 1f\n"
> + " xr %1,%0\n"
> + " nr %1,%5\n"
> + " jnz 0b\n"
> + "1:"
> +#ifndef __s390x__
> + ".section .fixup,\"ax\"\n"
> + "2: lhi %0,%6\n"
> + " bras 1,3f\n"
> + " .long 1b\n"
> + "3: l 1,0(1)\n"
> + " br 1\n"
> + ".previous\n"
> + ".section __ex_table,\"a\"\n"
> + " .align 4\n"
> + " .long 0b,2b\n"
> + ".previous"
> +#else /* __s390x__ */
> + ".section .fixup,\"ax\"\n"
> + "2: lghi %0,%6\n"
> + " jg 1b\n"
> + ".previous\n"
> + ".section __ex_table,\"a\"\n"
> + " .align 8\n"
> + " .quad 0b,2b\n"
> + ".previous"
> +#endif /* __s390x__ */
> + : "=&d" (prev), "=&d" (tmp)
> + : "d" (args->old << shift), "d" (args->new << shift),
> + "a" (args->ptr), "d" (~(65535 << shift)), "K" (-EFAULT)
> + : "memory", "cc" );
> + return prev >> shift;

You need a label behind the cs instruction and put that into the __ex_table,
since the PSW will point to the instruction after cs if it fails.

Also, on failure this function seems to return -EFAULT >> shift, which
seems to be wrong.

> +EXPORT_SYMBOL(register_die_notifier);
> +EXPORT_SYMBOL(unregister_die_notifier);

_GPL?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/