patches/0002-Disable-range-checks-we-re-running-in-userspace.patch
changeset 2 d1f6d8b6f81c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/0002-Disable-range-checks-we-re-running-in-userspace.patch	Thu Apr 09 12:07:21 2009 +0200
@@ -0,0 +1,159 @@
+From 4700df7fad5064696c6bb5809fe01067966543ad Mon Sep 17 00:00:00 2001
+From: Florian Westphal <fw@strlen.de>
+Date: Sun, 22 Mar 2009 15:12:05 +0100
+Subject: [PATCH] Disable range checks; we're running in userspace
+
+The get_user macro calls
+__get_user_{1,2,4}
+depending on sizeof(*ptr).
+Unfortunately, these functions are assembler routines that have
+protoype void fun(void), yet they they will modifiy arguments and
+return a value, so they cannot be implemented easily in the cradle code.
+
+The most simple method to work around it is to remove that macro
+if CONFIG_NSC is defined.
+
+--- a/linux-2.6.28/arch/x86/include/asm/uaccess.h	2008-10-26 11:41:31.000000000 +0100
++++ b/linux-2.6.28/arch/x86/include/asm/uaccess.h	2008-10-24 12:43:01.000000000 +0200
+@@ -77,11 +77,8 @@
+  * checks that the pointer is in the user space range - after calling
+  * this function, memory access functions may still return -EFAULT.
+  */
++#ifdef CONFIG_NSC
++#define access_ok(type, addr, size) (1)
++#else
+ #define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
++#endif
+-
+ /*
+  * The exception table consists of pairs of addresses: the first is the
+  * address of an instruction that is allowed to fault, and the second is
+@@ -155,9 +152,6 @@
+ 		__get_user_x(8, __ret_gu, __val_gu, ptr)
+ #endif
+
++#ifdef CONFIG_NSC
++#define get_user(x,ptr) ({ (x) = *ptr; 0; })
++#else
+ #define get_user(x, ptr)						\
+ ({									\
+ 	int __ret_gu;							\
+@@ -183,7 +177,6 @@
+ 	(x) = (__typeof__(*(ptr)))__val_gu;				\
+ 	__ret_gu;							\
+ })
++#endif
+
+ #define __put_user_x(size, x, ptr, __ret_pu)			\
+ 	asm volatile("call __put_user_" #size : "=a" (__ret_pu)	\
+@@ -243,10 +236,6 @@
+  *
+  * Returns zero on success, or -EFAULT on error.
+  */
++
++#ifdef CONFIG_NSC
++#define put_user(x,ptr) ({ *(ptr) = x; 0;})
++#else
+ #define put_user(x, ptr)					\
+ ({								\
+ 	int __ret_pu;						\
+@@ -272,7 +261,6 @@
+ 	}							\
+ 	__ret_pu;						\
+ })
++#endif
+
+ #define __put_user_size(x, ptr, size, retval, errret)			\
+ do {									\
+---
+ arch/x86/include/asm/uaccess.h                    |   12 ++++++++++
+ patches/random-driver-no-entropy-accounting.patch |   25 ---------------------
+ 2 files changed, 12 insertions(+), 25 deletions(-)
+ delete mode 100644 patches/random-driver-no-entropy-accounting.patch
+
+diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
+index 4340055..b443339 100644
+--- a/arch/x86/include/asm/uaccess.h
++++ b/arch/x86/include/asm/uaccess.h
+@@ -77,7 +77,11 @@
+  * checks that the pointer is in the user space range - after calling
+  * this function, memory access functions may still return -EFAULT.
+  */
++#ifdef CONFIG_NSC
++#define access_ok(type, addr, size) (1)
++#else
+ #define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
++#endif
+ 
+ /*
+  * The exception table consists of pairs of addresses: the first is the
+@@ -152,6 +156,9 @@ extern int __get_user_bad(void);
+ 		__get_user_x(8, __ret_gu, __val_gu, ptr)
+ #endif
+ 
++#ifdef CONFIG_NSC
++#define get_user(x,ptr) ({ (x) = *ptr; 0; })
++#else
+ #define get_user(x, ptr)						\
+ ({									\
+ 	int __ret_gu;							\
+@@ -178,6 +185,7 @@ extern int __get_user_bad(void);
+ 	(x) = (__typeof__(*(ptr)))__val_gu;				\
+ 	__ret_gu;							\
+ })
++#endif /* NSC */
+ 
+ #define __put_user_x(size, x, ptr, __ret_pu)			\
+ 	asm volatile("call __put_user_" #size : "=a" (__ret_pu)	\
+@@ -237,6 +245,9 @@ extern void __put_user_8(void);
+  *
+  * Returns zero on success, or -EFAULT on error.
+  */
++#ifdef CONFIG_NSC
++#define put_user(x,ptr) ({ *(ptr) = x; 0;})
++#else
+ #define put_user(x, ptr)					\
+ ({								\
+ 	int __ret_pu;						\
+@@ -263,6 +274,7 @@ extern void __put_user_8(void);
+ 	}							\
+ 	__ret_pu;						\
+ })
++#endif /* NSC */
+ 
+ #define __put_user_size(x, ptr, size, retval, errret)			\
+ do {									\
+diff --git a/patches/random-driver-no-entropy-accounting.patch b/patches/random-driver-no-entropy-accounting.patch
+deleted file mode 100644
+index 7e9a4ca..0000000
+--- a/patches/random-driver-no-entropy-accounting.patch
++++ /dev/null
+@@ -1,25 +0,0 @@
+-This disables entropy accounting in the PRNG.
+-
+-The real fix is to either completely replace random.c,
+-providing our own implementation using ns-3 rng infrastructure,
+-or feed the prng periodically.
+-
+---- a/drivers/char/random.c	2008-05-02 13:17:31.000000000 +0200
+-+++ b/drivers/char/random.c	2008-07-14 03:23:26.000000000 +0200
+-@@ -749,15 +749,7 @@
+- 	unsigned long flags;
+- 
+- 	BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
+-+#ifdef CONFIG_NSC
+-+	/*
+-+	 * prevent infinite loop: if a code path calls get_random_bytes
+-+	 * and we've run out of entropy, this calls wake_up_interruptible(),
+-+	 * which calls the code path again, which calls get_random_bytes,
+-+	 * which calls wake_up which...
+-+	 */
+-+	return nbytes;
+-+#endif
+-+
+- 	/* Hold lock while accounting */
+- 	spin_lock_irqsave(&r->lock, flags);
+- 
+-- 
+1.6.0.6
+