Created
December 31, 2010 13:20
-
-
Save anonymous/761000 to your computer and use it in GitHub Desktop.
C++でLinuxカーネルモジュール、カーネルへのパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ru linux-source-2.6.32-orig/arch/x86/include/asm/apic.h linux-source-2.6.32/arch/x86/include/asm/apic.h | |
--- linux-source-2.6.32-orig/arch/x86/include/asm/apic.h 2010-12-31 17:25:07.780930317 +0900 | |
+++ linux-source-2.6.32/arch/x86/include/asm/apic.h 2010-12-31 17:44:09.820779788 +0900 | |
@@ -585,7 +585,9 @@ | |
static inline physid_mask_t default_apicid_to_cpu_present(int phys_apicid) | |
{ | |
- return physid_mask_of_physid(phys_apicid); | |
+ physid_mask_t __physid_mask = {0}; | |
+ physid_set(phys_apicid, __physid_mask); | |
+ return __physid_mask; | |
} | |
#endif /* CONFIG_X86_LOCAL_APIC */ | |
diff -ru linux-source-2.6.32-orig/arch/x86/include/asm/paravirt.h linux-source-2.6.32/arch/x86/include/asm/paravirt.h | |
--- linux-source-2.6.32-orig/arch/x86/include/asm/paravirt.h 2010-12-31 17:25:08.304964121 +0900 | |
+++ linux-source-2.6.32/arch/x86/include/asm/paravirt.h 2010-12-31 17:30:24.785067507 +0900 | |
@@ -469,7 +469,12 @@ | |
pv_mmu_ops.make_pte, | |
val); | |
- return (pte_t) { .pte = ret }; | |
+ //return (pte_t) { .pte = ret }; | |
+ { | |
+ pte_t r = {0}; | |
+ r.pte = ret; | |
+ return r; | |
+ } | |
} | |
static inline pteval_t pte_val(pte_t pte) | |
@@ -523,7 +528,12 @@ | |
ret = PVOP_CALL3(pteval_t, pv_mmu_ops.ptep_modify_prot_start, | |
mm, addr, ptep); | |
- return (pte_t) { .pte = ret }; | |
+ //return (pte_t) { .pte = ret }; | |
+ { | |
+ pte_t r = {0}; | |
+ r.pte = ret; | |
+ return r; | |
+ } | |
} | |
static inline void ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr, | |
diff -ru linux-source-2.6.32-orig/arch/x86/include/asm/pgtable_types.h linux-source-2.6.32/arch/x86/include/asm/pgtable_types.h | |
--- linux-source-2.6.32-orig/arch/x86/include/asm/pgtable_types.h 2010-12-31 17:25:07.932183032 +0900 | |
+++ linux-source-2.6.32/arch/x86/include/asm/pgtable_types.h 2010-12-31 17:29:36.876702655 +0900 | |
@@ -257,7 +257,10 @@ | |
static inline pte_t native_make_pte(pteval_t val) | |
{ | |
- return (pte_t) { .pte = val }; | |
+ //return (pte_t) { .pte = val }; | |
+ pte_t r = {0}; | |
+ r.pte = val; | |
+ return r; | |
} | |
static inline pteval_t native_pte_val(pte_t pte) | |
diff -ru linux-source-2.6.32-orig/arch/x86/include/asm/vdso.h linux-source-2.6.32/arch/x86/include/asm/vdso.h | |
--- linux-source-2.6.32-orig/arch/x86/include/asm/vdso.h 2010-12-31 17:25:07.674446886 +0900 | |
+++ linux-source-2.6.32/arch/x86/include/asm/vdso.h 2010-12-31 17:46:13.128868328 +0900 | |
@@ -33,8 +33,8 @@ | |
* These symbols are defined with the addresses in the vsyscall page. | |
* See vsyscall-sigreturn.S. | |
*/ | |
-extern void __user __kernel_sigreturn; | |
-extern void __user __kernel_rt_sigreturn; | |
+extern int __user __kernel_sigreturn; | |
+extern int __user __kernel_rt_sigreturn; | |
/* | |
* These symbols are defined by vdso32.S to mark the bounds | |
diff -ru linux-source-2.6.32-orig/include/linux/hrtimer.h linux-source-2.6.32/include/linux/hrtimer.h | |
--- linux-source-2.6.32-orig/include/linux/hrtimer.h 2010-12-31 17:16:09.248998962 +0900 | |
+++ linux-source-2.6.32/include/linux/hrtimer.h 2010-12-31 17:40:03.772657336 +0900 | |
@@ -15,6 +15,14 @@ | |
#ifndef _LINUX_HRTIMER_H | |
#define _LINUX_HRTIMER_H | |
+#ifndef HRTIMER_RESTART_DEFINED | |
+#define HRTIMER_RESTART_DEFINED | |
+enum hrtimer_restart { | |
+ HRTIMER_NORESTART, /* Timer is not restarted */ | |
+ HRTIMER_RESTART, /* Timer must be restarted */ | |
+}; | |
+#endif | |
+ | |
#include <linux/rbtree.h> | |
#include <linux/ktime.h> | |
#include <linux/init.h> | |
@@ -41,10 +49,6 @@ | |
/* | |
* Return values for the callback function | |
*/ | |
-enum hrtimer_restart { | |
- HRTIMER_NORESTART, /* Timer is not restarted */ | |
- HRTIMER_RESTART, /* Timer must be restarted */ | |
-}; | |
/* | |
* Values to track state of the timer | |
diff -ru linux-source-2.6.32-orig/include/linux/kernel.h linux-source-2.6.32/include/linux/kernel.h | |
--- linux-source-2.6.32-orig/include/linux/kernel.h 2010-12-31 17:16:19.640677382 +0900 | |
+++ linux-source-2.6.32/include/linux/kernel.h 2010-12-31 17:28:22.449055817 +0900 | |
@@ -283,9 +283,12 @@ | |
extern int printk_needs_cpu(int cpu); | |
extern void printk_tick(void); | |
- | |
+/* | |
extern void asmlinkage __attribute__((format(printf, 1, 2))) | |
early_printk(const char *fmt, ...); | |
+*/ | |
+extern void __attribute__((format(printf, 1, 2))) | |
+ early_printk(const char *fmt, ...); | |
unsigned long int_sqrt(unsigned long); | |
diff -ru linux-source-2.6.32-orig/include/linux/ktime.h linux-source-2.6.32/include/linux/ktime.h | |
--- linux-source-2.6.32-orig/include/linux/ktime.h 2010-12-31 17:16:17.720851072 +0900 | |
+++ linux-source-2.6.32/include/linux/ktime.h 2010-12-31 17:34:11.185348078 +0900 | |
@@ -84,30 +84,35 @@ | |
if (unlikely(secs >= KTIME_SEC_MAX)) | |
return (ktime_t){ .tv64 = KTIME_MAX }; | |
#endif | |
- return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs }; | |
+ //return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs }; | |
+ { | |
+ ktime_t r = {0}; | |
+ r.tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs; | |
+ return r; | |
+ } | |
} | |
/* Subtract two ktime_t variables. rem = lhs -rhs: */ | |
-#define ktime_sub(lhs, rhs) \ | |
- ({ (ktime_t){ .tv64 = (lhs).tv64 - (rhs).tv64 }; }) | |
+#define ktime_sub(lhs, rhs) \ | |
+ ({ ktime_t r = {0}; r.tv64 = (lhs).tv64 - (rhs).tv64; r; }) | |
/* Add two ktime_t variables. res = lhs + rhs: */ | |
-#define ktime_add(lhs, rhs) \ | |
- ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; }) | |
+#define ktime_add(lhs, rhs) \ | |
+ ({ ktime_t r = {0}; r.tv64 = (lhs).tv64 + (rhs).tv64; r }) | |
/* | |
* Add a ktime_t variable and a scalar nanosecond value. | |
* res = kt + nsval: | |
*/ | |
-#define ktime_add_ns(kt, nsval) \ | |
- ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) | |
+#define ktime_add_ns(kt, nsval) \ | |
+ ({ ktime_t r = {0}; r.tv64 = (kt).tv64 + (nsval) ; r; }) | |
/* | |
* Subtract a scalar nanosecod from a ktime_t variable | |
* res = kt - nsval: | |
*/ | |
#define ktime_sub_ns(kt, nsval) \ | |
- ({ (ktime_t){ .tv64 = (kt).tv64 - (nsval) }; }) | |
+ ({ ktime_t r = {0}; r.tv64 = (kt).tv64 - (nsval); r; }) | |
/* convert a timespec to ktime_t format: */ | |
static inline ktime_t timespec_to_ktime(struct timespec ts) | |
@@ -329,7 +342,7 @@ | |
static inline ktime_t ns_to_ktime(u64 ns) | |
{ | |
- static const ktime_t ktime_zero = { .tv64 = 0 }; | |
+ static const ktime_t ktime_zero = {0}; | |
return ktime_add_ns(ktime_zero, ns); | |
} | |
diff -ru linux-source-2.6.32-orig/include/linux/semaphore.h linux-source-2.6.32/include/linux/semaphore.h | |
--- linux-source-2.6.32-orig/include/linux/semaphore.h 2010-12-31 17:16:18.601068313 +0900 | |
+++ linux-source-2.6.32/include/linux/semaphore.h 2010-12-31 19:14:44.974000157 +0900 | |
@@ -32,7 +32,25 @@ | |
static inline void sema_init(struct semaphore *sem, int val) | |
{ | |
static struct lock_class_key __key; | |
- *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val); | |
+ struct semaphore temp = {0}; | |
+ | |
+#ifdef CONFIG_DEBUG_SPINLOCK | |
+# error | |
+#endif | |
+ | |
+#ifdef CONFIG_DEBUG_LOCK_ALLOC | |
+# error | |
+#endif | |
+ | |
+ { | |
+ spinlock_t s = {0}; | |
+ s.raw_lock = __RAW_SPIN_LOCK_UNLOCKED; | |
+ temp.lock = s; | |
+ } | |
+ //temp.lock = __SPIN_LOCK_UNLOCKED((*sem).lock); | |
+ temp.count = val; | |
+ temp.wait_list = LIST_HEAD_INIT((*sem).wait_list); | |
+ *sem = temp; | |
lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); | |
} | |
diff -ru linux-source-2.6.32-orig/include/linux/timer.h linux-source-2.6.32/include/linux/timer.h | |
--- linux-source-2.6.32-orig/include/linux/timer.h 2010-12-31 17:16:15.732639992 +0900 | |
+++ linux-source-2.6.32/include/linux/timer.h 2010-12-31 17:39:59.508635587 +0900 | |
@@ -1,6 +1,14 @@ | |
#ifndef _LINUX_TIMER_H | |
#define _LINUX_TIMER_H | |
+#ifndef HRTIMER_RESTART_DEFINED | |
+#define HRTIMER_RESTART_DEFINED | |
+enum hrtimer_restart { | |
+ HRTIMER_NORESTART, /* Timer is not restarted */ | |
+ HRTIMER_RESTART, /* Timer must be restarted */ | |
+}; | |
+#endif | |
+ | |
#include <linux/list.h> | |
#include <linux/ktime.h> | |
#include <linux/stddef.h> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment