···73/*74 * __access_ok: Check if address with size is OK or not.75 *76- * We do three checks:77- * (1) is it user space?78- * (2) addr + size --> carry?79- * (3) addr + size >= 0x80000000 (PAGE_OFFSET)80 *81- * (1) (2) (3) | RESULT82- * 0 0 0 | ok83- * 0 0 1 | ok84- * 0 1 0 | bad85- * 0 1 1 | bad86- * 1 0 0 | ok87- * 1 0 1 | bad88- * 1 1 0 | bad89- * 1 1 1 | bad90 */91static inline int __access_ok(unsigned long addr, unsigned long size)92{93- unsigned long flag, tmp;9495- __asm__("stc r7_bank, %0\n\t"96- "mov.l @(8,%0), %0\n\t"97- "clrt\n\t"98- "addc %2, %1\n\t"99- "and %1, %0\n\t"100- "rotcl %0\n\t"101- "rotcl %0\n\t"102- "and #3, %0"103- : "=&z" (flag), "=r" (tmp)104- : "r" (addr), "1" (size)105- : "t");106-107 return flag == 0;0108}109#endif /* CONFIG_MMU */110
···73/*74 * __access_ok: Check if address with size is OK or not.75 *76+ * Uhhuh, this needs 33-bit arithmetic. We have a carry..00077 *78+ * sum := addr + size; carry? --> flag = true;79+ * if (sum >= addr_limit) flag = true;000000080 */81static inline int __access_ok(unsigned long addr, unsigned long size)82{83+ unsigned long flag, sum;8485+ __asm__("clrt\n\t"86+ "addc %3, %1\n\t"87+ "movt %0\n\t"88+ "cmp/hi %4, %1\n\t"89+ "rotcl %0"90+ :"=&r" (flag), "=r" (sum)91+ :"1" (addr), "r" (size),92+ "r" (current_thread_info()->addr_limit.seg)93+ :"t");00094 return flag == 0;95+96}97#endif /* CONFIG_MMU */98