<commit_before><commit_msg>Granary patches for 3.9.7 kernel<commit_after>diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
index 0f1ddee..3cce25e 100644
--- a/arch/x86/include/asm/page_64.h
+++ b/arch/x86/include/asm/page_64.h
@@ -9,9 +9,16 @@
 extern unsigned long max_pfn;
 extern unsigned long phys_base;
 
-static inline unsigned long __phys_addr_nodebug(unsigned long x)
+static inline unsigned long __phys_addr_nodebug(unsigned long x_)
 {
-	unsigned long y = x - __START_KERNEL_map;
+    /* GRANARY */
+    unsigned long x = x_;
+    unsigned long y;
+    if(!(x & (1ULL << 48)) && (x & (1ULL << 47))) {
+        x |= (0xFFFFULL << 48);
+    }
+
+	y = x - __START_KERNEL_map;
 
 	/* use the carry flag to determine if x was < __START_KERNEL_map */
 	x = y + ((x > y) ? phys_base : (__START_KERNEL_map - PAGE_OFFSET));
diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
index 8b491e6..9fbcd86 100644
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -1,7 +1,7 @@
 #ifndef _ASM_X86_PAGE_64_DEFS_H
 #define _ASM_X86_PAGE_64_DEFS_H
 
-#define THREAD_SIZE_ORDER	1
+#define THREAD_SIZE_ORDER	3
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_SIZE_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE - 1))
 
@@ -11,7 +11,7 @@
 #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
 #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
 
-#define IRQ_STACK_ORDER 2
+#define IRQ_STACK_ORDER 3
 #define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER)
 
 #define STACKFAULT_STACK 1
diff --git a/include/linux/sched.h b/include/linux/sched.h
index be4e742..1511a77 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1577,6 +1577,8 @@ struct task_struct {
 #ifdef CONFIG_UPROBES
 	struct uprobe_task *utask;
 #endif
+
+    void *granary;
 };
 
 /* Future-safe accessor for struct task_struct's cpus_allowed. */
diff --git a/kernel/wait.c b/kernel/wait.c
index 6698e0c..0547e34 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -206,9 +206,12 @@ __wait_on_bit(wait_queue_head_t *wq, struct wait_bit_queue *q,
 }
 EXPORT_SYMBOL(__wait_on_bit);
 
-int __sched out_of_line_wait_on_bit(void *word, int bit,
+int __sched out_of_line_wait_on_bit(void *word_, int bit,
 					int (*action)(void *), unsigned mode)
 {
+	/* GRANARY */
+	void *word = (void *) (((unsigned long) word_) | (0xFFFFULL << 48));
+	
 	wait_queue_head_t *wq = bit_waitqueue(word, bit);
 	DEFINE_WAIT_BIT(wait, word, bit);
 
@@ -237,9 +240,12 @@ __wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
 }
 EXPORT_SYMBOL(__wait_on_bit_lock);
 
-int __sched out_of_line_wait_on_bit_lock(void *word, int bit,
+int __sched out_of_line_wait_on_bit_lock(void *word_, int bit,
 					int (*action)(void *), unsigned mode)
 {
+	/* GRANARY */
+	void *word = (void *) (((unsigned long) word_) | (0xFFFFULL << 48));
+
 	wait_queue_head_t *wq = bit_waitqueue(word, bit);
 	DEFINE_WAIT_BIT(wait, word, bit);
 
@@ -247,8 +253,11 @@ int __sched out_of_line_wait_on_bit_lock(void *word, int bit,
 }
 EXPORT_SYMBOL(out_of_line_wait_on_bit_lock);
 
-void __wake_up_bit(wait_queue_head_t *wq, void *word, int bit)
+void __wake_up_bit(wait_queue_head_t *wq, void *word_, int bit)
 {
+	/* GRANARY */
+	void *word = (void *) (((unsigned long) word_) | (0xFFFFULL << 48));
+
 	struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
 	if (waitqueue_active(wq))
 		__wake_up(wq, TASK_NORMAL, 1, &key);
@@ -272,14 +281,20 @@ EXPORT_SYMBOL(__wake_up_bit);
  * may need to use a less regular barrier, such fs/inode.c's smp_mb(),
  * because spin_unlock() does not guarantee a memory barrier.
  */
-void wake_up_bit(void *word, int bit)
+void wake_up_bit(void *word_, int bit)
 {
+	/* GRANARY */
+	void *word = (void *) (((unsigned long) word_) | (0xFFFFULL << 48));
+
 	__wake_up_bit(bit_waitqueue(word, bit), word, bit);
 }
 EXPORT_SYMBOL(wake_up_bit);
 
-wait_queue_head_t *bit_waitqueue(void *word, int bit)
+wait_queue_head_t *bit_waitqueue(void *word_, int bit)
 {
+	/* GRANARY */
+	void *word = (void *) (((unsigned long) word_) | (0xFFFFULL << 48));
+
 	const int shift = BITS_PER_LONG == 32 ? 5 : 6;
 	const struct zone *zone = page_zone(virt_to_page(word));
 	unsigned long val = (unsigned long)word << shift | bit;

{'fraction_non_alphanumeric': 0.14719626168224298, 'fraction_numerical': 0.04649532710280374, 'mean_word_length': 4.40530303030303, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3081568', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1725, 'n_words': 374}