/*1* Copyright 2011 Tilera Corporation. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or4* modify it under the terms of the GNU General Public License5* as published by the Free Software Foundation, version 2.6*7* This program is distributed in the hope that it will be useful, but8* WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or10* NON INFRINGEMENT. See the GNU General Public License for11* more details.12*13* Atomically access user memory, but use MMU to avoid propagating14* kernel exceptions.15*/1617#include <linux/linkage.h>18#include <asm/errno.h>19#include <asm/futex.h>20#include <asm/page.h>21#include <asm/processor.h>2223/*24* Provide a set of atomic memory operations supporting <asm/futex.h>.25*26* r0: user address to manipulate27* r1: new value to write, or for cmpxchg, old value to compare against28* r2: (cmpxchg only) new value to write29*30* Return __get_user struct, r0 with value, r1 with error.31*/32#define FUTEX_OP(name, ...) \33STD_ENTRY(futex_##name) \34__VA_ARGS__; \35{ \36move r1, zero; \37jrp lr \38}; \39STD_ENDPROC(futex_##name); \40.pushsection __ex_table,"a"; \41.quad 1b, get_user_fault; \42.popsection4344.pushsection .fixup,"ax"45get_user_fault:46{ movei r1, -EFAULT; jrp lr }47ENDPROC(get_user_fault)48.popsection4950FUTEX_OP(cmpxchg, mtspr CMPEXCH_VALUE, r1; 1: cmpexch4 r0, r0, r2)51FUTEX_OP(set, 1: exch4 r0, r0, r1)52FUTEX_OP(add, 1: fetchadd4 r0, r0, r1)53FUTEX_OP(or, 1: fetchor4 r0, r0, r1)54FUTEX_OP(andn, nor r1, r1, zero; 1: fetchand4 r0, r0, r1)555657