All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Arvind R <arvino55@gmail.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: Nouveau on dom0
Date: Wed, 3 Mar 2010 13:13:03 -0500	[thread overview]
Message-ID: <20100303181303.GA21078@phenom.dumpdata.com> (raw)
In-Reply-To: <d799c4761003030911l51013f07mc1bf4aa15df519c4@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3051 bytes --]

> >> page-table directory so that when the GPU accesses the addresses, it
> >> gets the real bus address. I wonder if it fails at that thought -
> >> meaning that the addresses that are written to the page table are
> >> actually the guest page numbers (gpfn) instead of the machine page numbers (mfn).
> >
> > No, I don't think thats how it works. The user-space write triggers an
> > aio-write -
> 
> which triggers do_page_fault, handle_mm_fault, do_linear_fault, __do_fault
> and finally ttm_bo_vm_fault.
> ttm_bo_fault returns VM_FAULT_NOPAGE

VM_FAULT_NOPAGE = means retry the fault, In other words, I've fixed the
PTE to point to the right PFN.
> 
>  - but xen-boot keeps on re-triggering the same fault.

Which probably means that something is not OK with the PTE. What is the
vma->vm_page_prot value before the vm_insert_mixed? (and maybe even
after)

Try also reading the true value of the PTE and seeing what it shows
before and after the vm_insert_mixed.

I've attached a simple patch I wrote some time ago to get the real MFNs
and its page protection. I think you can adapt it (print_data function to be exact)
to peet at the PTE and its protection values.

There is an extra flag that the PTE can have when running under Xen: _PAGE_IOMAP.
This signifies that the PFN is actually the MFN. In this case thought
it sholdn't be enabled b/c the memory is actually gathered from
alloc_page. But if it is, it might be the culprit.


> when vm_fault calls ttm_tt_get_page, the page is already there, and
> the handler does another vm_insert_page (i changed vm_insert_mixed
> vm_insert_page/pfn based on io_mem, now the only patch, and it works on
> bare machine) on and on and on.
> 
> What can possibly cause the fault-handler to repeat endlessly?

The VM_FAULT_NOPAGE shortcircuits most of the fault-handler and makes it
return back. The application is resumed and retries the operation that
caused the fault - in this case an attempt to write to an address that
was not present. Obviously the second attempt at writing to the address
should have worked without problems.

> If a wrong page is backed at the user-address, it should create bad_access or
> some other subsequent events - but the system is running fine minus all local
> consoles! If the insertion is to a wrong place, this can happen; but
> the top-level
> trap is the only provider of the address - and the fault addres and
> vma address match,
> and the same code works fine on bare-boot.

So you see this fault handler being called endlessly while the machine
is still running and other pieces of code work just fine, right?

> 
> ttm_tt_get_page calls alloc in a loop - so it may allocate multiple pages from
> start/end depending on Highmem memory or not - implying asynchronous allocation
> and mapping.

I thought it had some logic to figure out that it already handled this
page and would return an already allocate page?

> 
> All I want now is *ptr = (uint32_t)data to work as of now!

You are doing a great job at this head-spinning detective work. Much
appreciated!

[-- Attachment #2: debug-print-pte.patch --]
[-- Type: text/plain, Size: 23820 bytes --]

diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index 634c40a..bbd0c36 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -133,8 +133,8 @@ int set_memory_wc(unsigned long addr, int numpages);
 int set_memory_wb(unsigned long addr, int numpages);
 int set_memory_x(unsigned long addr, int numpages);
 int set_memory_nx(unsigned long addr, int numpages);
-int set_memory_ro(unsigned long addr, int numpages);
-int set_memory_rw(unsigned long addr, int numpages);
+int set_memory_ro(unsigned long addr, int numpages, int debug);
+int set_memory_rw(unsigned long addr, int numpages, int debug);
 int set_memory_np(unsigned long addr, int numpages);
 int set_memory_4k(unsigned long addr, int numpages);
 
@@ -168,23 +168,23 @@ int set_pages_uc(struct page *page, int numpages);
 int set_pages_wb(struct page *page, int numpages);
 int set_pages_x(struct page *page, int numpages);
 int set_pages_nx(struct page *page, int numpages);
-int set_pages_ro(struct page *page, int numpages);
-int set_pages_rw(struct page *page, int numpages);
+int set_pages_ro(struct page *page, int numpages, int debug);
+int set_pages_rw(struct page *page, int numpages, int debug);
 
 
 void clflush_cache_range(void *addr, unsigned int size);
 
-#ifdef CONFIG_DEBUG_RODATA
+//#ifdef CONFIG_DEBUG_RODATA
 void mark_rodata_ro(void);
 extern const int rodata_test_data;
 extern int kernel_set_to_readonly;
 void set_kernel_text_rw(void);
-void set_kernel_text_ro(void);
+void set_kernel_text_ro(void);/*
 #else
 static inline void set_kernel_text_rw(void) { }
 static inline void set_kernel_text_ro(void) { }
 #endif
-
+*/
 #ifdef CONFIG_DEBUG_RODATA_TEST
 int rodata_test(void);
 #else
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index ecb544e..ae78303 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -344,7 +344,7 @@ void cpu_idle_wait(void);
 
 extern unsigned long arch_align_stack(unsigned long sp);
 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
-
+extern void print_data(char *what, unsigned long addr);
 void default_idle(void);
 
 void stop_this_cpu(void *dummy);
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index de7353c..11ee66f 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -472,11 +472,13 @@ void __init alternative_instructions(void)
 #endif
  	apply_paravirt(__parainstructions, __parainstructions_end);
 
-	if (smp_alt_once)
+	if (smp_alt_once) {
+		print_data("__smp_locks", (unsigned long)__smp_locks+1);
+		print_data("__smp_locks_end",(unsigned long)__smp_locks_end-1);
 		free_init_pages("SMP alternatives",
 				(unsigned long)__smp_locks,
 				(unsigned long)__smp_locks_end);
-
+	}
 	restart_nmi();
 }
 
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index d406c52..d03204f 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -13,7 +13,7 @@
 #include <asm/tlbflush.h>
 #include <asm/tlb.h>
 #include <asm/proto.h>
-
+#include <asm/xen/page.h>
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
 unsigned long __initdata e820_table_start;
@@ -336,9 +336,81 @@ int devmem_is_allowed(unsigned long pagenr)
 	return 0;
 }
 
+void print_data(char *what, unsigned long addr)
+{
+	static const char * const level_name[] =
+	  { "NONE", "4K", "2M", "1G", "NUM" };
+	unsigned long pfn = virt_to_pfn(addr);
+	pte_t *pte;
+	pteval_t val;
+	unsigned int level;
+	unsigned offset;
+	unsigned long phys;
+	pgprotval_t prot;
+	char buf[40];
+	char *str;
+
+
+
+	// Gets the MFN.
+	pte  = lookup_address(addr, &level);
+	offset = addr & ~PAGE_MASK;
+
+	phys = (pte_mfn(*pte) << PAGE_SHIFT) + offset;		
+	val = pte_val_ma(*pte);
+	prot = pgprot_val(pte_pgprot(*pte));
+
+	str = buf;
+	if (!prot)
+		str += sprintf(str, "Not present.");
+	else  {
+		if (prot & _PAGE_USER)
+			str += sprintf(str, "USR ");
+		else
+			str += sprintf(str, "    ");
+		if (prot & _PAGE_RW)
+			str += sprintf(str, "RW ");
+		else
+			str += sprintf(str, "ro ");
+		if (prot & _PAGE_PWT)
+			str += sprintf(str, "PWT ");
+		else
+			str += sprintf(str, "    ");
+		if (prot & _PAGE_PCD)
+			str += sprintf(str, "PCD ");
+		else
+			str += sprintf(str, "    ");
+
+		/* Bit 9 has a different meaning on level 3 vs 4 */
+		if (level <= 3) {
+			if (prot & _PAGE_PSE)
+				str += sprintf(str, "PSE ");
+			else
+				str += sprintf(str, "    ");
+		} else {
+			if (prot & _PAGE_PAT)
+				str += sprintf(str, "pat ");
+			else
+				str += sprintf(str, "    ");
+		}
+		if (prot & _PAGE_GLOBAL)
+			str += sprintf(str, "GLB ");
+		else
+			str += sprintf(str, "    ");
+		if (prot & _PAGE_NX)
+			str += sprintf(str, "NX ");
+		else
+			str += sprintf(str, "x  ");
+	}
+	printk(KERN_INFO "[%16s]PFN: 0x%lx PTE: 0x%lx: [%s] [%s]\n",
+			what, (unsigned long)pfn, (unsigned long)(pte->pte),
+			buf, level_name[level]);
+}
+
 void free_init_pages(char *what, unsigned long begin, unsigned long end)
 {
 	unsigned long addr = begin;
+	int debug = 0;
 
 	if (addr >= end)
 		return;
@@ -358,13 +430,16 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
 	 * we are going to free part of that, we need to make that
 	 * writeable first.
 	 */
-	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
+	//printk(KERN_INFO "Mark RW: memory %08lx..%08lx\n", begin, PAGE_ALIGN(end));
+
+	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT, 1);
 
-	printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
+	print_data("RW", begin);
 
 	for (; addr < end; addr += PAGE_SIZE) {
 		ClearPageReserved(virt_to_page(addr));
 		init_page_count(virt_to_page(addr));
+		/* crashes here with _RO page */
 		memset((void *)(addr & ~(PAGE_SIZE-1)),
 			POISON_FREE_INITMEM, PAGE_SIZE);
 		free_page(addr);
@@ -375,7 +450,9 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
 
 void free_initmem(void)
 {
-	free_init_pages("unused kernel memory",
+	print_data("__init_begin", (unsigned long)(&__init_begin)+1);
+	print_data("__init_end", (unsigned long)(&__init_end)-1);
+	free_init_pages("unused kernel memory (init_)",
 			(unsigned long)(&__init_begin),
 			(unsigned long)(&__init_end));
 }
@@ -383,6 +460,8 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
+	print_data("initrd_start", start+1);
+	print_data("initrd_end", end-1);
 	free_init_pages("initrd memory", start, end);
 }
 #endif
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 9a0c258..97df56b 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -1006,10 +1006,10 @@ void set_kernel_text_rw(void)
 	if (!kernel_set_to_readonly)
 		return;
 
-	pr_debug("Set kernel text: %lx - %lx for read write\n",
+	printk(KERN_INFO "Set kernel text: %lx - %lx for read write\n",
 		 start, start+size);
 
-	set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT);
+	set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT, 1);
 }
 
 void set_kernel_text_ro(void)
@@ -1020,10 +1020,10 @@ void set_kernel_text_ro(void)
 	if (!kernel_set_to_readonly)
 		return;
 
-	pr_debug("Set kernel text: %lx - %lx for read only\n",
+	printk(KERN_INFO "Set kernel text: %lx - %lx for read only\n",
 		 start, start+size);
 
-	set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
+	set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT, 1);
 }
 
 void mark_rodata_ro(void)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 69ddfbd..81ca3d6 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -710,7 +710,7 @@ void __init mem_init(void)
 		initsize >> 10);
 }
 
-#ifdef CONFIG_DEBUG_RODATA
+//#ifdef CONFIG_DEBUG_RODATA
 const int rodata_test_data = 0xC3;
 EXPORT_SYMBOL_GPL(rodata_test_data);
 
@@ -724,7 +724,7 @@ void set_kernel_text_rw(void)
 	if (!kernel_set_to_readonly)
 		return;
 
-	pr_debug("Set kernel text: %lx - %lx for read write\n",
+	printk(KERN_INFO "Set kernel text: %lx - %lx for read write\n",
 		 start, end);
 
 	/*
@@ -732,7 +732,7 @@ void set_kernel_text_rw(void)
 	 * mapping will always be RO. Refer to the comment in
 	 * static_protections() in pageattr.c
 	 */
-	set_memory_rw(start, (end - start) >> PAGE_SHIFT);
+	set_memory_rw(start, (end - start) >> PAGE_SHIFT, 1);
 }
 
 void set_kernel_text_ro(void)
@@ -743,13 +743,19 @@ void set_kernel_text_ro(void)
 	if (!kernel_set_to_readonly)
 		return;
 
-	pr_debug("Set kernel text: %lx - %lx for read only\n",
+	printk(KERN_INFO "Set kernel text: %lx - %lx for read only\n",
 		 start, end);
 
 	/*
 	 * Set the kernel identity mapping for text RO.
 	 */
-	set_memory_ro(start, (end - start) >> PAGE_SHIFT);
+	set_memory_ro(start, (end - start) >> PAGE_SHIFT, 1);
+}
+
+static inline int
+within(unsigned long addr, unsigned long start, unsigned long end)
+{
+	return addr >= start && addr < end;
 }
 
 void mark_rodata_ro(void)
@@ -764,15 +770,47 @@ void mark_rodata_ro(void)
 
 	printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
 	       (end - start) >> 10);
-	set_memory_ro(start, (end - start) >> PAGE_SHIFT);
 
-	kernel_set_to_readonly = 1;
+	printk(KERN_INFO "start: 0x%lx, end: 0x%lx (size: 0x%ld)\n" \
+			"rodata_start: 0x%lx, rodata_end: 0x%lx (size: 0x%ld)\n" \
+			"text_end: 0x%lx, data_start: 0x%lx (size: 0x%lx)\n",
+			start, end, (end-start) >> PAGE_SHIFT,
+			rodata_start, rodata_end, (rodata_end-rodata_start)>>PAGE_SHIFT,
+			text_end, data_start, (data_start-rodata_end)>>PAGE_SHIFT);
+	print_data("_text", start);
+	print_data("_end-1", end-1);
+	print_data("text_end+1", text_end+1);
+	print_data("text_end-1", text_end-1);
+	print_data("data_start", data_start);
+	print_data("rodata_end-1" ,rodata_end-1);
+	print_data("__stop_ex_t_1", (unsigned long) page_address(virt_to_page(text_end))+1);
+	print_data("rodata_start", (unsigned long) page_address(virt_to_page(rodata_start)));
+
+	set_memory_ro(start, (end - start) >> PAGE_SHIFT, 1);
+	print_data("RO_text", start);
+	print_data("RO_end01", end-1);
+	print_data("ROtext_end+1", text_end+1);
+	print_data("ROdata_start", data_start);
+	print_data("ROrodata_end-1" ,rodata_end-1);
+	print_data("RO__stop___ex_", (unsigned long) page_address(virt_to_page(text_end))+1);
+	print_data("ROrodata_start-1", (unsigned long) page_address(virt_to_page(rodata_start))-1);
+	print_data("ROrodata_start+1", (unsigned long) page_address(virt_to_page(rodata_start))+1);
 
+	kernel_set_to_readonly = 1;
 	/*
 	 * The rodata section (but not the kernel text!) should also be
 	 * not-executable.
 	 */
+	printk(KERN_INFO "NX: 0x%lx, #%ld\n", rodata_start, (end-rodata_start)>>PAGE_SHIFT);
 	set_memory_nx(rodata_start, (end - rodata_start) >> PAGE_SHIFT);
+	print_data("NX_text", start);
+	print_data("NX_end-1", end-1);
+	print_data("NXtext_end+1", text_end+1);
+	print_data("NXdata_start", data_start);
+	print_data("NXrodata_end-1" ,rodata_end-1);
+	print_data("NX__stop___ex+1", (unsigned long) page_address(virt_to_page(text_end))+1);
+	print_data("NXrodata_start-1", (unsigned long) page_address(virt_to_page(rodata_start))-1);
+	print_data("NXrodata_start+1", (unsigned long) page_address(virt_to_page(rodata_start))+1);
 
 	rodata_test();
 
@@ -784,16 +822,16 @@ void mark_rodata_ro(void)
 	set_memory_ro(start, (end-start) >> PAGE_SHIFT);
 #endif
 
-	free_init_pages("unused kernel memory",
+	free_init_pages("#1unused kernel memory",
 			(unsigned long) page_address(virt_to_page(text_end)),
-			(unsigned long)
-				 page_address(virt_to_page(rodata_start)));
-	free_init_pages("unused kernel memory",
+			(unsigned long) page_address(virt_to_page(rodata_start)));
+
+	free_init_pages("#2unused kernel memory",
 			(unsigned long) page_address(virt_to_page(rodata_end)),
 			(unsigned long) page_address(virt_to_page(data_start)));
 }
 
-#endif
+//#endif
 
 int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
 				   int flags)
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 1d4eb93..ab4d965 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -23,7 +23,7 @@
 #include <asm/pgalloc.h>
 #include <asm/proto.h>
 #include <asm/pat.h>
-
+#include <asm/xen/page.h>
 /*
  * The current flushing context - we pass it instead of 5 arguments:
  */
@@ -291,8 +291,33 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
 	 */
 	if (kernel_set_to_readonly &&
 	    within(address, (unsigned long)_text,
-		   (unsigned long)__end_rodata_hpage_align))
-		pgprot_val(forbidden) |= _PAGE_RW;
+		   (unsigned long)__end_rodata_hpage_align)) {
+
+		/* When kernel_set_to_readonly, two sections that are OK to be
+  		 * PAGE_RW are the ones that are going to be recycled by
+  		 * mark_rodata_ro */
+		if (!within(address, (unsigned long)&__stop___ex_table,
+				(unsigned long)&__start_rodata) &&
+		    !within(address, (unsigned long)&__end_rodata,
+				(unsigned long)&_sdata))
+			pgprot_val(forbidden) |= _PAGE_RW;
+/*
+		if (pgprot_val(prot) & _PAGE_RW) {
+			printk(KERN_INFO "PAGE_RW: 0x%lx 0x%lx,(text:0x%lx, 0x%lx, 0x%lx)\n "\
+				 "(end: 0x%lx, 0x%lx, 0x%lx)\n" \
+				"PGPROT: 0x%lx->0x%lx\n",
+				address, pfn,
+				(unsigned long)_text,
+				virt_to_pfn(_text),
+				(unsigned long) page_address(virt_to_page(_text)),
+				(unsigned long)__end_rodata_hpage_align,
+				virt_to_pfn(__end_rodata_hpage_align),
+				(unsigned long) page_address(virt_to_page(__end_rodata_hpage_align)),
+				(unsigned long)pgprot_val(prot),
+				(unsigned long)pgprot_val(__pgprot(pgprot_val(prot) & ~pgprot_val(forbidden)))); 
+		}
+	*/
+	}
 #endif
 
 	prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
@@ -602,7 +627,7 @@ static int __cpa_process_fault(struct cpa_data *cpa, unsigned long vaddr,
 	}
 }
 
-static int __change_page_attr(struct cpa_data *cpa, int primary)
+static int __change_page_attr(struct cpa_data *cpa, int primary, int debug)
 {
 	unsigned long address;
 	int do_split, err;
@@ -647,7 +672,12 @@ repeat:
 		/*
 		 * Do we really change anything ?
 		 */
-		if (pte_val(old_pte) != pte_val(new_pte)) {
+		if (pte_val(old_pte) != pte_val(new_pte)) { /*
+			if (debug) {
+				printk(KERN_INFO " 0x%lx -> 0x%lx\n",
+				(unsigned long)pgprot_val(pte_pgprot(old_pte)),
+				(unsigned long)pgprot_val(pte_pgprot(new_pte)));
+			} */
 			set_pte_atomic(kpte, new_pte);
 			cpa->flags |= CPA_FLUSHTLB;
 		}
@@ -698,7 +728,7 @@ repeat:
 	return err;
 }
 
-static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias);
+static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias, int debug);
 
 static int cpa_process_alias(struct cpa_data *cpa)
 {
@@ -735,7 +765,7 @@ static int cpa_process_alias(struct cpa_data *cpa)
 		alias_cpa.vaddr = &laddr;
 		alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY);
 
-		ret = __change_page_attr_set_clr(&alias_cpa, 0);
+		ret = __change_page_attr_set_clr(&alias_cpa, 0, 0);
 		if (ret)
 			return ret;
 	}
@@ -758,14 +788,14 @@ static int cpa_process_alias(struct cpa_data *cpa)
 		 * The high mapping range is imprecise, so ignore the
 		 * return value.
 		 */
-		__change_page_attr_set_clr(&alias_cpa, 0);
+		__change_page_attr_set_clr(&alias_cpa, 0, 0);
 	}
 #endif
 
 	return 0;
 }
 
-static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
+static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias, int debug)
 {
 	int ret, numpages = cpa->numpages;
 
@@ -781,7 +811,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
 
 		if (!debug_pagealloc)
 			spin_lock(&cpa_lock);
-		ret = __change_page_attr(cpa, checkalias);
+		ret = __change_page_attr(cpa, checkalias, debug);
 		if (!debug_pagealloc)
 			spin_unlock(&cpa_lock);
 		if (ret)
@@ -818,7 +848,7 @@ static inline int cache_attr(pgprot_t attr)
 static int change_page_attr_set_clr(unsigned long *addr, int numpages,
 				    pgprot_t mask_set, pgprot_t mask_clr,
 				    int force_split, int in_flag,
-				    struct page **pages)
+				    struct page **pages, int debug)
 {
 	struct cpa_data cpa;
 	int ret, cache, checkalias;
@@ -830,9 +860,16 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
 	 */
 	mask_set = canon_pgprot(mask_set);
 	mask_clr = canon_pgprot(mask_clr);
-	if (!pgprot_val(mask_set) && !pgprot_val(mask_clr) && !force_split)
+	if (!pgprot_val(mask_set) && !pgprot_val(mask_clr) && !force_split) {
+		/*
+		if (debug) {
+			printk(KERN_INFO "0x%lx [!0x%lx && !0x%lx]\n",
+				(unsigned long)addr,
+				(unsigned long)pgprot_val(mask_set),
+				(unsigned long)pgprot_val(mask_clr));
+		} */
 		return 0;
-
+	}
 	/* Ensure we are PAGE_SIZE aligned */
 	if (in_flag & CPA_ARRAY) {
 		int i;
@@ -880,8 +917,15 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
 
 	/* No alias checking for _NX bit modifications */
 	checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX;
-
-	ret = __change_page_attr_set_clr(&cpa, checkalias);
+	/*
+	if (debug)
+		printk(KERN_INFO "0x%lx Mask_set: 0x%lx, Mask_clr: 0x%lx, %s\n",
+			(unsigned long)addr,
+			(unsigned long)pgprot_val(mask_set),
+			(unsigned long)pgprot_val(mask_clr),
+			(checkalias) ? "! PAGE_NX" : "NX");	
+	*/
+	ret = __change_page_attr_set_clr(&cpa, checkalias, debug);
 
 	/*
 	 * Check whether we really changed something:
@@ -915,31 +959,31 @@ out:
 }
 
 static inline int change_page_attr_set(unsigned long *addr, int numpages,
-				       pgprot_t mask, int array)
+				       pgprot_t mask, int array, int debug)
 {
 	return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0,
-		(array ? CPA_ARRAY : 0), NULL);
+		(array ? CPA_ARRAY : 0), NULL, debug);
 }
 
 static inline int change_page_attr_clear(unsigned long *addr, int numpages,
-					 pgprot_t mask, int array)
+					 pgprot_t mask, int array, int debug)
 {
 	return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0,
-		(array ? CPA_ARRAY : 0), NULL);
+		(array ? CPA_ARRAY : 0), NULL, 0);
 }
 
 static inline int cpa_set_pages_array(struct page **pages, int numpages,
 				       pgprot_t mask)
 {
 	return change_page_attr_set_clr(NULL, numpages, mask, __pgprot(0), 0,
-		CPA_PAGES_ARRAY, pages);
+		CPA_PAGES_ARRAY, pages, 0);
 }
 
 static inline int cpa_clear_pages_array(struct page **pages, int numpages,
 					 pgprot_t mask)
 {
 	return change_page_attr_set_clr(NULL, numpages, __pgprot(0), mask, 0,
-		CPA_PAGES_ARRAY, pages);
+		CPA_PAGES_ARRAY, pages, 0);
 }
 
 int _set_memory_uc(unsigned long addr, int numpages)
@@ -948,7 +992,7 @@ int _set_memory_uc(unsigned long addr, int numpages)
 	 * for now UC MINUS. see comments in ioremap_nocache()
 	 */
 	return change_page_attr_set(&addr, numpages,
-				    __pgprot(_PAGE_CACHE_UC_MINUS), 0);
+				    __pgprot(_PAGE_CACHE_UC_MINUS), 0, 0);
 }
 
 int set_memory_uc(unsigned long addr, int numpages)
@@ -992,7 +1036,7 @@ int set_memory_array_uc(unsigned long *addr, int addrinarray)
 	}
 
 	ret = change_page_attr_set(addr, addrinarray,
-				    __pgprot(_PAGE_CACHE_UC_MINUS), 1);
+				    __pgprot(_PAGE_CACHE_UC_MINUS), 1, 0);
 	if (ret)
 		goto out_free;
 
@@ -1012,12 +1056,12 @@ int _set_memory_wc(unsigned long addr, int numpages)
 	unsigned long addr_copy = addr;
 
 	ret = change_page_attr_set(&addr, numpages,
-				    __pgprot(_PAGE_CACHE_UC_MINUS), 0);
+				    __pgprot(_PAGE_CACHE_UC_MINUS), 0, 0);
 	if (!ret) {
 		ret = change_page_attr_set_clr(&addr_copy, numpages,
 					       __pgprot(_PAGE_CACHE_WC),
 					       __pgprot(_PAGE_CACHE_MASK),
-					       0, 0, NULL);
+					       0, 0, NULL, 0);
 	}
 	return ret;
 }
@@ -1050,7 +1094,7 @@ EXPORT_SYMBOL(set_memory_wc);
 int _set_memory_wb(unsigned long addr, int numpages)
 {
 	return change_page_attr_clear(&addr, numpages,
-				      __pgprot(_PAGE_CACHE_MASK), 0);
+				      __pgprot(_PAGE_CACHE_MASK), 0, 0);
 }
 
 int set_memory_wb(unsigned long addr, int numpages)
@@ -1072,7 +1116,7 @@ int set_memory_array_wb(unsigned long *addr, int addrinarray)
 	int ret;
 
 	ret = change_page_attr_clear(addr, addrinarray,
-				      __pgprot(_PAGE_CACHE_MASK), 1);
+				      __pgprot(_PAGE_CACHE_MASK), 1, 0);
 	if (ret)
 		return ret;
 
@@ -1088,7 +1132,7 @@ int set_memory_x(unsigned long addr, int numpages)
 	if (!(__supported_pte_mask & _PAGE_NX))
 		return 0;
 
-	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0);
+	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0, 0);
 }
 EXPORT_SYMBOL(set_memory_x);
 
@@ -1097,31 +1141,33 @@ int set_memory_nx(unsigned long addr, int numpages)
 	if (!(__supported_pte_mask & _PAGE_NX))
 		return 0;
 
-	return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0);
+	return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0, 0);
 }
 EXPORT_SYMBOL(set_memory_nx);
 
-int set_memory_ro(unsigned long addr, int numpages)
+int set_memory_ro(unsigned long addr, int numpages, int debug)
 {
-	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_RW), 0);
+	//if (debug) printk(KERN_INFO "RO: 0x%lx (%d)\n", addr, numpages);
+	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_RW), 0, debug);
 }
 EXPORT_SYMBOL_GPL(set_memory_ro);
 
-int set_memory_rw(unsigned long addr, int numpages)
+int set_memory_rw(unsigned long addr, int numpages, int debug)
 {
-	return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_RW), 0);
+	//if (debug) printk(KERN_INFO "RW: 0x%lx (%d)\n", addr, numpages);
+	return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_RW), 0, debug);
 }
 EXPORT_SYMBOL_GPL(set_memory_rw);
 
 int set_memory_np(unsigned long addr, int numpages)
 {
-	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0);
+	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0, 0);
 }
 
 int set_memory_4k(unsigned long addr, int numpages)
 {
 	return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
-					__pgprot(0), 1, 0, NULL);
+					__pgprot(0), 1, 0, NULL, 0);
 }
 
 int set_pages_uc(struct page *page, int numpages)
@@ -1213,18 +1259,18 @@ int set_pages_nx(struct page *page, int numpages)
 }
 EXPORT_SYMBOL(set_pages_nx);
 
-int set_pages_ro(struct page *page, int numpages)
+int set_pages_ro(struct page *page, int numpages, int debug)
 {
 	unsigned long addr = (unsigned long)page_address(page);
 
-	return set_memory_ro(addr, numpages);
+	return set_memory_ro(addr, numpages, debug);
 }
 
-int set_pages_rw(struct page *page, int numpages)
+int set_pages_rw(struct page *page, int numpages, int debug)
 {
 	unsigned long addr = (unsigned long)page_address(page);
 
-	return set_memory_rw(addr, numpages);
+	return set_memory_rw(addr, numpages, debug);
 }
 
 #ifdef CONFIG_DEBUG_PAGEALLOC
@@ -1244,7 +1290,7 @@ static int __set_pages_p(struct page *page, int numpages)
 	 * mappings (this adds to complexity if we want to do this from
 	 * atomic context especially). Let's keep it simple!
 	 */
-	return __change_page_attr_set_clr(&cpa, 0);
+	return __change_page_attr_set_clr(&cpa, 0, 0);
 }
 
 static int __set_pages_np(struct page *page, int numpages)
@@ -1262,7 +1308,7 @@ static int __set_pages_np(struct page *page, int numpages)
 	 * mappings (this adds to complexity if we want to do this from
 	 * atomic context especially). Let's keep it simple!
 	 */
-	return __change_page_attr_set_clr(&cpa, 0);
+	return __change_page_attr_set_clr(&cpa, 0, 0);
 }
 
 void kernel_map_pages(struct page *page, int numpages, int enable)
diff --git a/init/main.c b/init/main.c
index 4cb47a1..6fba891 100644
--- a/init/main.c
+++ b/init/main.c
@@ -91,7 +91,7 @@ extern void prio_tree_init(void);
 extern void radix_tree_init(void);
 extern void free_initmem(void);
 #ifndef CONFIG_DEBUG_RODATA
-static inline void mark_rodata_ro(void) { }
+//static inline void mark_rodata_ro(void) { }
 #endif
 
 #ifdef CONFIG_TC

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2010-03-03 18:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-25  8:46 Nouveau on dom0 Arvind R
2010-02-25 12:55 ` Konrad Rzeszutek Wilk
2010-02-25 17:01   ` Arvind R
2010-02-25 17:44     ` Konrad Rzeszutek Wilk
2010-02-26 15:34       ` Arvind R
2010-03-01 16:01         ` Konrad Rzeszutek Wilk
2010-03-02 21:34           ` Arvind R
2010-03-03 17:11             ` Arvind R
2010-03-03 18:13               ` Konrad Rzeszutek Wilk [this message]
2010-03-04  9:17                 ` Arvind R
2010-03-04 18:25                   ` Konrad Rzeszutek Wilk
2010-03-05  7:46                     ` Arvind R
2010-03-05 20:23                       ` Konrad Rzeszutek Wilk
2010-03-06  8:16                         ` Arvind R
2010-03-06 20:59                           ` Arvind R
2010-03-06 23:56                             ` Arvind R
2010-03-08 17:51                               ` Konrad Rzeszutek Wilk
2010-03-10 12:50                                 ` [Solved] " Arvind R
2010-03-10 14:00                                   ` Pasi Kärkkäinen
2010-03-10 19:37                                   ` Jeremy Fitzhardinge
     [not found]                                   ` <20100311201536.GA22182@phenom.dumpdata.com>
2010-03-12  6:12                                     ` Arvind R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100303181303.GA21078@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=arvino55@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.