Skip to contentSkip to conversation

x86-64 linux: a little cleanup

PATCH New Jan Beulich 1 participant 2 messages Feb 14, 2006 – Feb 16, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64 linux: a little cleanup

The recent change to read_cr3() was not correct, and there actually is a user for it. Jan

arch/x86_64/mm/fault-xen.c +1 -2
Index: head-2006-02-13/arch/x86_64/mm/fault-xen.c
===================================================================
@@ -152,8 +152,7 @@ void dump_pagetable(unsigned long addres
 	pmd_t *pmd;
 	pte_t *pte;
 
-	asm("movq %%cr3,%0" : "=r" (pgd));
-	pgd = (pgd_t *)machine_to_phys((maddr_t)pgd);
+	pgd = (pgd_t *)read_cr3();
 
 	pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); 
 	pgd += pgd_index(address);
include/asm-x86_64/mach-xen/asm/system.h +1 -1
Index: head-2006-02-13/include/asm-x86_64/mach-xen/asm/system.h
===================================================================
@@ -182,7 +182,7 @@ static inline void write_cr0(unsigned lo
 #define read_cr3() ({ \
 	unsigned long __dummy; \
 	asm("movq %%cr3,%0" : "=r" (__dummy)); \
-	return machine_to_phys(__dummy); \
+	machine_to_phys(__dummy); \
 })
 
 static inline unsigned long read_cr4(void)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

PATCH 1/1 x86-64 linux: a little cleanup

The recent change to read_cr3() was not correct, and there actually are two users for it. Jan

arch/x86_64/mm/fault-xen.c +2 -7
Index: head-2006-02-16/arch/x86_64/mm/fault-xen.c
===================================================================
@@ -152,10 +152,7 @@ void dump_pagetable(unsigned long addres
 	pmd_t *pmd;
 	pte_t *pte;
 
-	asm("movq %%cr3,%0" : "=r" (pgd));
-	pgd = (pgd_t *)machine_to_phys((maddr_t)pgd);
-
-	pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); 
+	pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK);
 	pgd += pgd_index(address);
 	if (bad_address(pgd)) goto bad;
 	printk("PGD %lx ", pgd_val(*pgd));
@@ -261,9 +258,7 @@ static int vmalloc_fault(unsigned long a
 
 	/* On Xen the line below does not always work. Needs investigating! */
 	/*pgd = pgd_offset(current->mm ?: &init_mm, address);*/
-	asm("movq %%cr3,%0" : "=r" (pgd));
-	pgd = (pgd_t *)machine_to_phys((maddr_t)pgd);
-	pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK);
+	pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK);
 	pgd += pgd_index(address);
 	pgd_ref = pgd_offset_k(address);
 	if (pgd_none(*pgd_ref))
include/asm-x86_64/mach-xen/asm/system.h +1 -1
Index: head-2006-02-16/include/asm-x86_64/mach-xen/asm/system.h
===================================================================
@@ -182,7 +182,7 @@ static inline void write_cr0(unsigned lo
 #define read_cr3() ({ \
 	unsigned long __dummy; \
 	asm("movq %%cr3,%0" : "=r" (__dummy)); \
-	return machine_to_phys(__dummy); \
+	machine_to_phys(__dummy); \
 })
 
 static inline unsigned long read_cr4(void)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel