mirror of
https://github.com/torvalds/linux.git
synced 2024-11-07 04:32:03 +00:00
18aecc2b64
This support was partially present in the existing code (look for "__tilegx__" ifdefs) but with this change you can build a working kernel using the TILE-Gx toolchain and ARCH=tilegx. Most of these files are new, generally adding a foo_64.c file where previously there was just a foo_32.c file. The ARCH=tilegx directive redirects to arch/tile, not arch/tilegx, using the existing SRCARCH mechanism in the top-level Makefile. Changes to existing files: - <asm/bitops.h> and <asm/bitops_32.h> changed to factor the include of <asm-generic/bitops/non-atomic.h> in the common header. - <asm/compat.h> and arch/tile/kernel/compat.c changed to remove the "const" markers I had put on compat_sys_execve() when trying to match some recent similar changes to the non-compat execve. It turns out the compat version wasn't "upgraded" to use const. - <asm/opcode-tile_64.h> and <asm/opcode_constants_64.h> were previously included accidentally, with the 32-bit contents. Now they have the proper 64-bit contents. Finally, I had to hack the existing hacky drivers/input/input-compat.h to add yet another "#ifdef" for INPUT_COMPAT_TEST (same as x86_64). Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> [drivers/input]
87 lines
2.5 KiB
C
87 lines
2.5 KiB
C
/*
|
|
* Copyright 2011 Tilera Corporation. All Rights Reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation, version 2.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
|
* NON INFRINGEMENT. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* Do memcpy(), but trap and return "n" when a load or store faults.
|
|
*
|
|
* Note: this idiom only works when memcpy() compiles to a leaf function.
|
|
* If "sp" is updated during memcpy, the "jrp lr" will be incorrect.
|
|
*
|
|
* Also note that we are capturing "n" from the containing scope here.
|
|
*/
|
|
|
|
#define _ST(p, inst, v) \
|
|
({ \
|
|
asm("1: " #inst " %0, %1;" \
|
|
".pushsection .coldtext.memcpy,\"ax\";" \
|
|
"2: { move r0, %2; jrp lr };" \
|
|
".section __ex_table,\"a\";" \
|
|
".quad 1b, 2b;" \
|
|
".popsection" \
|
|
: "=m" (*(p)) : "r" (v), "r" (n)); \
|
|
})
|
|
|
|
#define _LD(p, inst) \
|
|
({ \
|
|
unsigned long __v; \
|
|
asm("1: " #inst " %0, %1;" \
|
|
".pushsection .coldtext.memcpy,\"ax\";" \
|
|
"2: { move r0, %2; jrp lr };" \
|
|
".section __ex_table,\"a\";" \
|
|
".quad 1b, 2b;" \
|
|
".popsection" \
|
|
: "=r" (__v) : "m" (*(p)), "r" (n)); \
|
|
__v; \
|
|
})
|
|
|
|
#define USERCOPY_FUNC __copy_to_user_inatomic
|
|
#define ST1(p, v) _ST((p), st1, (v))
|
|
#define ST2(p, v) _ST((p), st2, (v))
|
|
#define ST4(p, v) _ST((p), st4, (v))
|
|
#define ST8(p, v) _ST((p), st, (v))
|
|
#define LD1 LD
|
|
#define LD2 LD
|
|
#define LD4 LD
|
|
#define LD8 LD
|
|
#include "memcpy_64.c"
|
|
|
|
#define USERCOPY_FUNC __copy_from_user_inatomic
|
|
#define ST1 ST
|
|
#define ST2 ST
|
|
#define ST4 ST
|
|
#define ST8 ST
|
|
#define LD1(p) _LD((p), ld1u)
|
|
#define LD2(p) _LD((p), ld2u)
|
|
#define LD4(p) _LD((p), ld4u)
|
|
#define LD8(p) _LD((p), ld)
|
|
#include "memcpy_64.c"
|
|
|
|
#define USERCOPY_FUNC __copy_in_user_inatomic
|
|
#define ST1(p, v) _ST((p), st1, (v))
|
|
#define ST2(p, v) _ST((p), st2, (v))
|
|
#define ST4(p, v) _ST((p), st4, (v))
|
|
#define ST8(p, v) _ST((p), st, (v))
|
|
#define LD1(p) _LD((p), ld1u)
|
|
#define LD2(p) _LD((p), ld2u)
|
|
#define LD4(p) _LD((p), ld4u)
|
|
#define LD8(p) _LD((p), ld)
|
|
#include "memcpy_64.c"
|
|
|
|
unsigned long __copy_from_user_zeroing(void *to, const void __user *from,
|
|
unsigned long n)
|
|
{
|
|
unsigned long rc = __copy_from_user_inatomic(to, from, n);
|
|
if (unlikely(rc))
|
|
memset(to + n - rc, 0, rc);
|
|
return rc;
|
|
}
|