All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0 of 8] x86: unify asm/page.h
@ 2008-01-03 20:10 Jeremy Fitzhardinge
  2008-01-03 20:10 ` [PATCH 1 of 8] x86: page.h: unify constants Jeremy Fitzhardinge
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

Hi Ingo,

Here's a series which concentrates on unifying and cleaning up
asm-86/page*.h.  Each patch in the series restricts itself to doing
one thing fairly simply, so it should be fairly low-risk and easy to
bisect.

The early version of this patch got rid of asm/page_32|64.h entirely,
but I decided the resulting #ifdef hell was too hard to deal with, so
I moved purely 32/64-bit specific stuff into their own files.

Thanks,
	J



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1 of 8] x86: page.h: unify constants
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
@ 2008-01-03 20:10 ` Jeremy Fitzhardinge
  2008-01-07 17:17   ` Andi Kleen
  2008-01-03 20:10 ` [PATCH 2 of 8] x86: page.h: unify page copying and clearing Jeremy Fitzhardinge
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199317360 28800
# Node ID ba0ec40a50a7aef1a3153cea124c35e261f5a2df
# Parent  c45c263179cb78284b6b869c574457df088027d1
x86: page.h: unify constants

There are many constants which are shared by 32 and 64-bit.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/asm-x86/page.h    |  130 +++++++++++++++++++++++++++++++++++++++++----
 include/asm-x86/page_32.h |   46 ---------------
 include/asm-x86/page_64.h |   73 -------------------------
 3 files changed, 119 insertions(+), 130 deletions(-)

diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -1,13 +1,116 @@
-#ifdef __KERNEL__
-# ifdef CONFIG_X86_32
-#  include "page_32.h"
-# else
-#  include "page_64.h"
-# endif
+#ifndef _ASM_X86_PAGE_H
+#define _ASM_X86_PAGE_H
+
+#include <linux/const.h>
+
+/* PAGE_SHIFT determines the page size */
+#define PAGE_SHIFT	12
+#define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
+#define PAGE_MASK	(~(PAGE_SIZE-1))
+
+#define PHYSICAL_PAGE_MASK	(PAGE_MASK & __PHYSICAL_MASK)
+
+#define LARGE_PAGE_SIZE		(_AC(1,UL) << PMD_SHIFT)
+#define LARGE_PAGE_MASK		(~(LARGE_PAGE_SIZE-1))
+
+#define HPAGE_SHIFT		PMD_SHIFT
+#define HPAGE_SIZE		(_AC(1,UL) << HPAGE_SHIFT)
+#define HPAGE_MASK		(~(HPAGE_SIZE - 1))
+#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
+
+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
+
+#define __PHYSICAL_MASK		((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
+#define __VIRTUAL_MASK		((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
+
+
+#ifdef CONFIG_X86_64
+#define THREAD_ORDER	1
+#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
+#define CURRENT_MASK (~(THREAD_SIZE-1))
+
+#define EXCEPTION_STACK_ORDER 0
+#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
+
+#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
+#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
+
+#define IRQSTACK_ORDER 2
+#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
+
+#define STACKFAULT_STACK 1
+#define DOUBLEFAULT_STACK 2
+#define NMI_STACK 3
+#define DEBUG_STACK 4
+#define MCE_STACK 5
+#define N_EXCEPTION_STACKS 5  /* hw limit: 7 */
+
+#define __PAGE_OFFSET           _AC(0xffff810000000000, UL)
+
+#define __PHYSICAL_START	CONFIG_PHYSICAL_START
+#define __KERNEL_ALIGN		0x200000
+
+/*
+ * Make sure kernel is aligned to 2MB address. Catching it at compile
+ * time is better. Change your config file and compile the kernel
+ * for a 2MB aligned address (CONFIG_PHYSICAL_START)
+ */
+#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
+#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
+#endif
+
+#define __START_KERNEL		(__START_KERNEL_map + __PHYSICAL_START)
+#define __START_KERNEL_map	_AC(0xffffffff80000000, UL)
+
+/* See Documentation/x86_64/mm.txt for a description of the memory map. */
+#define __PHYSICAL_MASK_SHIFT	46
+#define __VIRTUAL_MASK_SHIFT	48
+
+#define KERNEL_TEXT_SIZE  (40*1024*1024)
+#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
+
+#endif	/* CONFIG_X86_64 */
+
+#ifdef CONFIG_X86_32
+
+/*
+ * This handles the memory map.
+ *
+ * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
+ * a virtual address space of one gigabyte, which limits the
+ * amount of physical memory you can use to about 950MB.
+ *
+ * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
+ * and CONFIG_HIGHMEM64G options in the kernel configuration.
+ */
+#define __PAGE_OFFSET		_AC(CONFIG_PAGE_OFFSET, UL)
+
+#ifdef CONFIG_X86_PAE
+#define __PHYSICAL_MASK_SHIFT	36
+#define __VIRTUAL_MASK_SHIFT	32
+#else  /* !CONFIG_X86_PAE */
+#define __PHYSICAL_MASK_SHIFT	32
+#define __VIRTUAL_MASK_SHIFT	32
+#endif	/* CONFIG_X86_PAE */
+
+#ifdef CONFIG_HUGETLB_PAGE
+#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
+#endif
+
+#endif	/* CONFIG_X86_32 */
+
+#define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
+
+#define VM_DATA_DEFAULT_FLAGS \
+	(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
+	 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+
+
+#ifdef CONFIG_X86_32
+# include "page_32.h"
 #else
-# ifdef __i386__
-#  include "page_32.h"
-# else
-#  include "page_64.h"
-# endif
+# include "page_64.h"
 #endif
+
+#endif	/* _ASM_X86_PAGE_H */
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -1,13 +1,5 @@
 #ifndef _I386_PAGE_H
 #define _I386_PAGE_H
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT	12
-#define PAGE_SIZE	(1UL << PAGE_SHIFT)
-#define PAGE_MASK	(~(PAGE_SIZE-1))
-
-#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
-#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -111,7 +103,6 @@ static inline pte_t native_make_pte(unsi
 #define __pmd(x)	native_make_pmd(x)
 #endif
 
-#define HPAGE_SHIFT	21
 #include <asm-generic/pgtable-nopud.h>
 #else  /* !CONFIG_X86_PAE */
 typedef struct { unsigned long pte_low; } pte_t;
@@ -139,18 +130,10 @@ static inline pte_t native_make_pte(unsi
 	return (pte_t) { .pte_low = val };
 }
 
-#define HPAGE_SHIFT	22
 #include <asm-generic/pgtable-nopmd.h>
 #endif	/* CONFIG_X86_PAE */
 
 #define PTE_MASK	PAGE_MASK
-
-#ifdef CONFIG_HUGETLB_PAGE
-#define HPAGE_SIZE	((1UL) << HPAGE_SHIFT)
-#define HPAGE_MASK	(~(HPAGE_SIZE - 1))
-#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
-#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
-#endif
 
 #define pgprot_val(x)	((x).pgprot)
 #define __pgprot(x)	((pgprot_t) { (x) } )
@@ -163,22 +146,6 @@ static inline pte_t native_make_pte(unsi
 #endif
 
 #endif /* !__ASSEMBLY__ */
-
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-/*
- * This handles the memory map.. We could make this a config
- * option, but too many people screw it up, and too few need
- * it.
- *
- * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
- * a virtual address space of one gigabyte, which limits the
- * amount of physical memory you can use to about 950MB. 
- *
- * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
- * and CONFIG_HIGHMEM64G options in the kernel configuration.
- */
 
 #ifndef __ASSEMBLY__
 
@@ -196,14 +163,6 @@ extern int page_is_ram(unsigned long pag
 
 #endif /* __ASSEMBLY__ */
 
-#ifdef __ASSEMBLY__
-#define __PAGE_OFFSET		CONFIG_PAGE_OFFSET
-#else
-#define __PAGE_OFFSET		((unsigned long)CONFIG_PAGE_OFFSET)
-#endif
-
-
-#define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
 #define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
 #define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
 #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
@@ -219,11 +178,6 @@ extern int page_is_ram(unsigned long pag
 
 #define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
 
-#define VM_DATA_DEFAULT_FLAGS \
-	(VM_READ | VM_WRITE | \
-	((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
-		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-
 #include <asm-generic/memory_model.h>
 #include <asm-generic/page.h>
 
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -1,41 +1,5 @@
 #ifndef _X86_64_PAGE_H
 #define _X86_64_PAGE_H
-
-#include <linux/const.h>
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT	12
-#define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK	(~(PAGE_SIZE-1))
-#define PHYSICAL_PAGE_MASK	(~(PAGE_SIZE-1) & __PHYSICAL_MASK)
-
-#define THREAD_ORDER 1 
-#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
-#define CURRENT_MASK (~(THREAD_SIZE-1))
-
-#define EXCEPTION_STACK_ORDER 0
-#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
-
-#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
-#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
-
-#define IRQSTACK_ORDER 2
-#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
-
-#define STACKFAULT_STACK 1
-#define DOUBLEFAULT_STACK 2
-#define NMI_STACK 3
-#define DEBUG_STACK 4
-#define MCE_STACK 5
-#define N_EXCEPTION_STACKS 5  /* hw limit: 7 */
-
-#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
-#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)
-
-#define HPAGE_SHIFT PMD_SHIFT
-#define HPAGE_SIZE	(_AC(1,UL) << HPAGE_SHIFT)
-#define HPAGE_MASK	(~(HPAGE_SIZE - 1))
-#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -90,35 +54,6 @@ extern unsigned long phys_base;
 
 #endif /* !__ASSEMBLY__ */
 
-#define __PHYSICAL_START	CONFIG_PHYSICAL_START
-#define __KERNEL_ALIGN		0x200000
-
-/*
- * Make sure kernel is aligned to 2MB address. Catching it at compile
- * time is better. Change your config file and compile the kernel
- * for a 2MB aligned address (CONFIG_PHYSICAL_START)
- */
-#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
-#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
-#endif
-
-#define __START_KERNEL		(__START_KERNEL_map + __PHYSICAL_START)
-#define __START_KERNEL_map	_AC(0xffffffff80000000, UL)
-#define __PAGE_OFFSET           _AC(0xffff810000000000, UL)
-
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-/* See Documentation/x86_64/mm.txt for a description of the memory map. */
-#define __PHYSICAL_MASK_SHIFT	46
-#define __PHYSICAL_MASK		((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
-#define __VIRTUAL_MASK_SHIFT	48
-#define __VIRTUAL_MASK		((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
-
-#define KERNEL_TEXT_SIZE  (40*1024*1024)
-#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
-#define PAGE_OFFSET		__PAGE_OFFSET
-
 #ifndef __ASSEMBLY__
 
 #include <asm/bug.h>
@@ -138,10 +73,6 @@ extern unsigned long __phys_addr(unsigne
 #define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 
-#define VM_DATA_DEFAULT_FLAGS \
-	(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
-	 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-
 #define __HAVE_ARCH_GATE_AREA 1	
 #define vmemmap ((struct page *)VMEMMAP_START)
 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2 of 8] x86: page.h: unify page copying and clearing
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
  2008-01-03 20:10 ` [PATCH 1 of 8] x86: page.h: unify constants Jeremy Fitzhardinge
@ 2008-01-03 20:10 ` Jeremy Fitzhardinge
  2008-01-03 20:11 ` [PATCH 3 of 8] x86: add _AT() macro to conditionally cast Jeremy Fitzhardinge
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199317362 28800
# Node ID 4d9a413a0f4c1d98dbea704f0366457b5117045d
# Parent  ba0ec40a50a7aef1a3153cea124c35e261f5a2df
x86: page.h: unify page copying and clearing

Move, and to some extent unify, the various page copying and clearing
functions.  The only unification here is that both architectures use
the same function for copying/clearing user and kernel pages.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/asm-x86/page.h    |   55 +++++++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/page_32.h |   53 -------------------------------------------
 include/asm-x86/page_64.h |   20 ----------------
 3 files changed, 55 insertions(+), 73 deletions(-)

diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -70,6 +70,11 @@
 #define KERNEL_TEXT_SIZE  (40*1024*1024)
 #define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
 
+#ifndef __ASSEMBLY__
+void clear_page(void *page);
+void copy_page(void *to, void *from);
+#endif	/* !__ASSEMBLY__ */
+
 #endif	/* CONFIG_X86_64 */
 
 #ifdef CONFIG_X86_32
@@ -98,6 +103,34 @@
 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
 #endif
 
+#ifndef __ASSEMBLY__
+#ifdef CONFIG_X86_USE_3DNOW
+#include <asm/mmx.h>
+
+static inline void clear_page(void *page)
+{
+	mmx_clear_page(page);
+}
+
+static inline void copy_page(void *to, void *from)
+{
+	mmx_copy_page(to, from);
+}
+#else  /* !CONFIG_X86_USE_3DNOW */
+#include <linux/string.h>
+
+static inline void clear_page(void *page)
+{
+	memset(page, 0, PAGE_SIZE);
+}
+
+static inline void copy_page(void *to, void *from)
+{
+	memcpy(to, from, PAGE_SIZE);
+}
+#endif	/* CONFIG_X86_3DNOW */
+#endif	/* !__ASSEMBLY__ */
+
 #endif	/* CONFIG_X86_32 */
 
 #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
@@ -107,6 +140,28 @@
 	 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 
+#ifndef __ASSEMBLY__
+struct page;
+
+static void inline clear_user_page(void *page, unsigned long vaddr,
+				struct page *pg)
+{
+	clear_page(page);
+}
+
+static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
+				struct page *topage)
+{
+	copy_page(to, from);
+}
+
+#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
+	alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
+#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
+
+#endif	/* __ASSEMBLY__ */
+
+
 #ifdef CONFIG_X86_32
 # include "page_32.h"
 #else
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -3,59 +3,6 @@
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
-
-#include <linux/string.h>
-
-#ifdef CONFIG_X86_USE_3DNOW
-
-#include <asm/mmx.h>
-
-static inline void clear_page(void *page)
-{
-	mmx_clear_page(page);
-}
-
-static inline void copy_page(void *to, void *from)
-{
-	mmx_copy_page(to, from);
-}
-
-#else
-
-/*
- *	On older X86 processors it's not a win to use MMX here it seems.
- *	Maybe the K6-III ?
- */
- 
-static inline void clear_page(void *page)
-{
-	memset(page, 0, PAGE_SIZE);
-}
-
-static inline void copy_page(void *to, void *from)
-{
-	memcpy(to, from, PAGE_SIZE);
-}
-
-#endif
-
-struct page;
-
-static void inline clear_user_page(void *page, unsigned long vaddr,
-				struct page *pg)
-{
-	clear_page(page);
-}
-
-static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
-				struct page *topage)
-{
-	copy_page(to, from);
-}
-
-#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
-	alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
-#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
 
 /*
  * These are used to make use of C type-checking..
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -7,26 +7,6 @@ extern unsigned long end_pfn;
 extern unsigned long end_pfn;
 extern unsigned long end_pfn_map;
 
-void clear_page(void *page);
-void copy_page(void *to, void *from);
-
-struct page;
-
-static void inline clear_user_page(void *page, unsigned long vaddr,
-				struct page *pg)
-{
-	clear_page(page);
-}
-
-static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
-				struct page *topage)
-{
-	copy_page(to, from);
-}
-
-#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
-	alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
-#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
 /*
  * These are used to make use of C type-checking..
  */



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3 of 8] x86: add _AT() macro to conditionally cast
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
  2008-01-03 20:10 ` [PATCH 1 of 8] x86: page.h: unify constants Jeremy Fitzhardinge
  2008-01-03 20:10 ` [PATCH 2 of 8] x86: page.h: unify page copying and clearing Jeremy Fitzhardinge
@ 2008-01-03 20:11 ` Jeremy Fitzhardinge
  2008-01-03 20:11 ` [PATCH 4 of 8] x86: page.h: move and unify types for pagetable entry definitions Jeremy Fitzhardinge
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199317452 28800
# Node ID f7e7db3facd9406545103164f9be8f9ba1a2b549
# Parent  4d9a413a0f4c1d98dbea704f0366457b5117045d
x86: add _AT() macro to conditionally cast

Define _AT(type, value) to conditionally cast a value when compiling C
code, but not when used in assembler.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/linux/const.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/const.h b/include/linux/const.h
--- a/include/linux/const.h
+++ b/include/linux/const.h
@@ -7,13 +7,18 @@
  * C code.  Therefore we cannot annotate them always with
  * 'UL' and other type specifiers unilaterally.  We
  * use the following macros to deal with this.
+ *
+ * Similarly, _AT() will cast an expression with a type in C, but
+ * leave it unchanged in asm.
  */
 
 #ifdef __ASSEMBLY__
 #define _AC(X,Y)	X
+#define _AT(T,X)	X
 #else
 #define __AC(X,Y)	(X##Y)
 #define _AC(X,Y)	__AC(X,Y)
+#define _AT(T,X)	((T)(X))
 #endif
 
 #endif /* !(_LINUX_CONST_H) */



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 4 of 8] x86: page.h: move and unify types for pagetable entry definitions
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
                   ` (2 preceding siblings ...)
  2008-01-03 20:11 ` [PATCH 3 of 8] x86: add _AT() macro to conditionally cast Jeremy Fitzhardinge
@ 2008-01-03 20:11 ` Jeremy Fitzhardinge
  2008-01-03 20:11 ` [PATCH 5 of 8] x86: page.h: move pa and va related things Jeremy Fitzhardinge
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199319654 28800
# Node ID 3bd7db6e85e66e7f3362874802df26a82fcb2d92
# Parent  f7e7db3facd9406545103164f9be8f9ba1a2b549
x86: page.h: move and unify types for pagetable entry definitions

This patch:

1. Defines arch-specific types for the contents of a pagetable entry.
That is, 32-bit entries for 32-bit non-PAE, and 64-bit entries for
32-bit PAE and 64-bit.  However, even though the latter two are the
same size, they're defined with different types in order to retain
compatibility with printk format strings, etc.

2. Defines arch-specific pte_t.  This is different because 32-bit PAE
defines it in two halves, whereas 32-bit PAE and 64-bit define it as a
single entry.  All the other pagetable levels can be defined in a
common way.  This also defines arch-specific pte_val/make_pte functions.

3. Define PAGETABLE_LEVELS for each architecture variation, for later use.

4. Define common pagetable entry accessors in a paravirt-compatible
way. (64-bit does not yet use paravirt-ops in any way).

5. Convert a few instances of using a *_val() as an lvalue where it is
no longer a macro.  There are still places in the 64-bit code which
use pte_val() as an lvalue.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/asm-x86/page.h       |  139 +++++++++++++++++++++++++++++++++++++++++-
 include/asm-x86/page_32.h    |   83 -------------------------
 include/asm-x86/page_64.h    |   22 ------
 include/asm-x86/pgtable_64.h |    6 -
 4 files changed, 141 insertions(+), 109 deletions(-)

diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -9,6 +9,7 @@
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
 #define PHYSICAL_PAGE_MASK	(PAGE_MASK & __PHYSICAL_MASK)
+#define PTE_MASK		PHYSICAL_PAGE_MASK
 
 #define LARGE_PAGE_SIZE		(_AC(1,UL) << PMD_SHIFT)
 #define LARGE_PAGE_MASK		(~(LARGE_PAGE_SIZE-1))
@@ -21,11 +22,16 @@
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-#define __PHYSICAL_MASK		((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
+#define __PHYSICAL_MASK		_AT(phys_addr_t, (_AC(1,ULL) << __PHYSICAL_MASK_SHIFT) - 1)
 #define __VIRTUAL_MASK		((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
 
+#ifndef __ASSEMBLER__
+#include <linux/types.h>
+#endif
 
 #ifdef CONFIG_X86_64
+#define PAGETABLE_LEVELS	4
+
 #define THREAD_ORDER	1
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE-1))
@@ -73,6 +79,22 @@
 #ifndef __ASSEMBLY__
 void clear_page(void *page);
 void copy_page(void *to, void *from);
+
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef unsigned long	pteval_t;
+typedef unsigned long	pmdval_t;
+typedef unsigned long	pudval_t;
+typedef unsigned long	pgdval_t;
+typedef unsigned long	pgprotval_t;
+typedef unsigned long	phys_addr_t;
+
+typedef struct { pteval_t pte; } pte_t;
+
+#define native_pte_val(x)	((x).pte)
+#define native_make_pte(x) ((pte_t) { (x) } )
+
 #endif	/* !__ASSEMBLY__ */
 
 #endif	/* CONFIG_X86_64 */
@@ -94,9 +116,57 @@ void copy_page(void *to, void *from);
 #ifdef CONFIG_X86_PAE
 #define __PHYSICAL_MASK_SHIFT	36
 #define __VIRTUAL_MASK_SHIFT	32
+#define PAGETABLE_LEVELS	3
+
+#ifndef __ASSEMBLY__
+typedef u64	pteval_t;
+typedef u64	pmdval_t;
+typedef u64	pudval_t;
+typedef u64	pgdval_t;
+typedef u64	pgprotval_t;
+typedef u64	phys_addr_t;
+
+typedef struct { unsigned long pte_low, pte_high; } pte_t;
+
+static inline unsigned long long native_pte_val(pte_t pte)
+{
+	return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
+}
+
+static inline pte_t native_make_pte(unsigned long long val)
+{
+	return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
+}
+
+#endif	/* __ASSEMBLY__
+ */
 #else  /* !CONFIG_X86_PAE */
 #define __PHYSICAL_MASK_SHIFT	32
 #define __VIRTUAL_MASK_SHIFT	32
+#define PAGETABLE_LEVELS	2
+
+#ifndef __ASSEMBLY__
+typedef unsigned long	pteval_t;
+typedef unsigned long	pmdval_t;
+typedef unsigned long	pudval_t;
+typedef unsigned long	pgdval_t;
+typedef unsigned long	pgprotval_t;
+typedef unsigned long	phys_addr_t;
+
+typedef struct { pteval_t pte_low; } pte_t;
+typedef pte_t boot_pte_t;
+
+static inline unsigned long native_pte_val(pte_t pte)
+{
+	return pte.pte_low;
+}
+
+static inline pte_t native_make_pte(unsigned long val)
+{
+	return (pte_t) { .pte_low = val };
+}
+
+#endif	/* __ASSEMBLY__ */
 #endif	/* CONFIG_X86_PAE */
 
 #ifdef CONFIG_HUGETLB_PAGE
@@ -159,6 +229,76 @@ static void inline copy_user_page(void *
 	alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
 
+typedef struct { pgdval_t pgd; } pgd_t;
+typedef struct { pgprotval_t pgprot; } pgprot_t;
+
+static inline pgd_t native_make_pgd(pgdval_t val)
+{
+	return (pgd_t) { val };
+}
+
+static inline pgdval_t native_pgd_val(pgd_t pgd)
+{
+	return pgd.pgd;
+}
+
+#if PAGETABLE_LEVELS >= 3
+#if PAGETABLE_LEVELS == 4
+typedef struct { pudval_t pud; } pud_t;
+
+static inline pud_t native_make_pud(pmdval_t val)
+{
+	return (pud_t) { val };
+}
+
+static inline pudval_t native_pud_val(pud_t pud)
+{
+	return pud.pud;
+}
+#else	/* PAGETABLE_LEVELS == 3 */
+#include <asm-generic/pgtable-nopud.h>
+#endif	/* PAGETABLE_LEVELS == 4 */
+
+typedef struct { pmdval_t pmd; } pmd_t;
+
+static inline pmd_t native_make_pmd(pmdval_t val)
+{
+	return (pmd_t) { val };
+}
+
+static inline pmdval_t native_pmd_val(pmd_t pmd)
+{
+	return pmd.pmd;
+}
+#else  /* PAGETABLE_LEVELS == 2 */
+#include <asm-generic/pgtable-nopmd.h>
+#endif	/* PAGETABLE_LEVELS >= 3 */
+
+#define pgprot_val(x)	((x).pgprot)
+#define __pgprot(x)	((pgprot_t) { (x) } )
+
+#ifdef CONFIG_PARAVIRT
+#include <asm/paravirt.h>
+#else  /* !CONFIG_PARAVIRT */
+
+#define pgd_val(x)	native_pgd_val(x)
+#define __pgd(x)	native_make_pgd(x)
+
+#ifndef __PAGETABLE_PUD_FOLDED
+#define pud_val(x)	native_pud_val(x)
+#define __pud(x)	native_make_pud(x)
+#endif
+
+#ifndef __PAGETABLE_PMD_FOLDED
+#define pmd_val(x)	native_pmd_val(x)
+#define __pmd(x)	native_make_pmd(x)
+#endif
+
+#define pte_val(x)	native_pte_val(x)
+#define __pte(x)	native_make_pte(x)
+
+#endif	/* CONFIG_PARAVIRT */
+
 #endif	/* __ASSEMBLY__ */
 
 
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -8,89 +8,6 @@
  * These are used to make use of C type-checking..
  */
 extern int nx_enabled;
-
-#ifdef CONFIG_X86_PAE
-typedef struct { unsigned long pte_low, pte_high; } pte_t;
-typedef struct { unsigned long long pmd; } pmd_t;
-typedef struct { unsigned long long pgd; } pgd_t;
-typedef struct { unsigned long long pgprot; } pgprot_t;
-
-static inline unsigned long long native_pgd_val(pgd_t pgd)
-{
-	return pgd.pgd;
-}
-
-static inline unsigned long long native_pmd_val(pmd_t pmd)
-{
-	return pmd.pmd;
-}
-
-static inline unsigned long long native_pte_val(pte_t pte)
-{
-	return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
-}
-
-static inline pgd_t native_make_pgd(unsigned long long val)
-{
-	return (pgd_t) { val };
-}
-
-static inline pmd_t native_make_pmd(unsigned long long val)
-{
-	return (pmd_t) { val };
-}
-
-static inline pte_t native_make_pte(unsigned long long val)
-{
-	return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
-}
-
-#ifndef CONFIG_PARAVIRT
-#define pmd_val(x)	native_pmd_val(x)
-#define __pmd(x)	native_make_pmd(x)
-#endif
-
-#include <asm-generic/pgtable-nopud.h>
-#else  /* !CONFIG_X86_PAE */
-typedef struct { unsigned long pte_low; } pte_t;
-typedef struct { unsigned long pgd; } pgd_t;
-typedef struct { unsigned long pgprot; } pgprot_t;
-#define boot_pte_t pte_t /* or would you rather have a typedef */
-
-static inline unsigned long native_pgd_val(pgd_t pgd)
-{
-	return pgd.pgd;
-}
-
-static inline unsigned long native_pte_val(pte_t pte)
-{
-	return pte.pte_low;
-}
-
-static inline pgd_t native_make_pgd(unsigned long val)
-{
-	return (pgd_t) { val };
-}
-
-static inline pte_t native_make_pte(unsigned long val)
-{
-	return (pte_t) { .pte_low = val };
-}
-
-#include <asm-generic/pgtable-nopmd.h>
-#endif	/* CONFIG_X86_PAE */
-
-#define PTE_MASK	PAGE_MASK
-
-#define pgprot_val(x)	((x).pgprot)
-#define __pgprot(x)	((pgprot_t) { (x) } )
-
-#ifndef CONFIG_PARAVIRT
-#define pgd_val(x)	native_pgd_val(x)
-#define __pgd(x)	native_make_pgd(x)
-#define pte_val(x)	native_pte_val(x)
-#define __pte(x)	native_make_pte(x)
-#endif
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -7,30 +7,8 @@ extern unsigned long end_pfn;
 extern unsigned long end_pfn;
 extern unsigned long end_pfn_map;
 
-/*
- * These are used to make use of C type-checking..
- */
-typedef struct { unsigned long pte; } pte_t;
-typedef struct { unsigned long pmd; } pmd_t;
-typedef struct { unsigned long pud; } pud_t;
-typedef struct { unsigned long pgd; } pgd_t;
-#define PTE_MASK	PHYSICAL_PAGE_MASK
-
-typedef struct { unsigned long pgprot; } pgprot_t;
 
 extern unsigned long phys_base;
-
-#define pte_val(x)	((x).pte)
-#define pmd_val(x)	((x).pmd)
-#define pud_val(x)	((x).pud)
-#define pgd_val(x)	((x).pgd)
-#define pgprot_val(x)	((x).pgprot)
-
-#define __pte(x) ((pte_t) { (x) } )
-#define __pmd(x) ((pmd_t) { (x) } )
-#define __pud(x) ((pud_t) { (x) } )
-#define __pgd(x) ((pgd_t) { (x) } )
-#define __pgprot(x)	((pgprot_t) { (x) } )
 
 #endif /* !__ASSEMBLY__ */
 
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -79,12 +79,12 @@ static inline void set_pte(pte_t *dst, p
 
 static inline void set_pmd(pmd_t *dst, pmd_t val)
 {
-        pmd_val(*dst) = pmd_val(val); 
+	*dst = val;
 } 
 
 static inline void set_pud(pud_t *dst, pud_t val)
 {
-	pud_val(*dst) = pud_val(val);
+	*dst = val;
 }
 
 static inline void pud_clear (pud_t *pud)
@@ -94,7 +94,7 @@ static inline void pud_clear (pud_t *pud
 
 static inline void set_pgd(pgd_t *dst, pgd_t val)
 {
-	pgd_val(*dst) = pgd_val(val); 
+	*dst = val;
 } 
 
 static inline void pgd_clear (pgd_t * pgd)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 5 of 8] x86: page.h: move pa and va related things
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
                   ` (3 preceding siblings ...)
  2008-01-03 20:11 ` [PATCH 4 of 8] x86: page.h: move and unify types for pagetable entry definitions Jeremy Fitzhardinge
@ 2008-01-03 20:11 ` Jeremy Fitzhardinge
  2008-01-03 20:11 ` [PATCH 6 of 8] x86: page.h: move remaining bits and pieces Jeremy Fitzhardinge
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199319656 28800
# Node ID d617b72a0cc9d14bde2087d065c36d4ed3265761
# Parent  3bd7db6e85e66e7f3362874802df26a82fcb2d92
x86: page.h: move pa and va related things

Move and unify the virtual<->physical address space conversion
functions.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/asm-x86/page.h    |   24 ++++++++++++++++++++++++
 include/asm-x86/page_32.h |   11 -----------
 include/asm-x86/page_64.h |   13 -------------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -79,6 +79,9 @@
 #ifndef __ASSEMBLY__
 void clear_page(void *page);
 void copy_page(void *to, void *from);
+
+extern unsigned long __phys_addr(unsigned long);
+#define __phys_reloc_hide(x)	(x)
 
 /*
  * These are used to make use of C type-checking..
@@ -174,6 +177,13 @@ static inline pte_t native_make_pte(unsi
 #endif
 
 #ifndef __ASSEMBLY__
+#define __phys_addr(x)		((x)-PAGE_OFFSET)
+#define __phys_reloc_hide(x)	RELOC_HIDE((x), 0)
+
+#ifdef CONFIG_FLATMEM
+#define pfn_valid(pfn)		((pfn) < max_mapnr)
+#endif /* CONFIG_FLATMEM */
+
 #ifdef CONFIG_X86_USE_3DNOW
 #include <asm/mmx.h>
 
@@ -299,6 +309,20 @@ static inline pmdval_t native_pmd_val(pm
 
 #endif	/* CONFIG_PARAVIRT */
 
+#define __pa(x)		__phys_addr((unsigned long)(x))
+/* __pa_symbol should be used for C visible symbols.
+   This seems to be the official gcc blessed way to do such arithmetic. */
+#define __pa_symbol(x)	__pa(__phys_reloc_hide((unsigned long)(x)))
+
+#define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
+
+#define __boot_va(x)		__va(x)
+#define __boot_pa(x)		__pa(x)
+
+#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
+#define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
+#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
+
 #endif	/* __ASSEMBLY__ */
 
 
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -29,18 +29,7 @@ extern int page_is_ram(unsigned long pag
 
 #define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
 #define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
-#define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
-/* __pa_symbol should be used for C visible symbols.
-   This seems to be the official gcc blessed way to do such arithmetic. */
-#define __pa_symbol(x)          __pa(RELOC_HIDE((unsigned long)(x),0))
-#define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
-#define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
-#ifdef CONFIG_FLATMEM
-#define pfn_valid(pfn)		((pfn) < max_mapnr)
-#endif /* CONFIG_FLATMEM */
-#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 
-#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
 
 #include <asm-generic/memory_model.h>
 #include <asm-generic/page.h>
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -16,20 +16,7 @@ extern unsigned long phys_base;
 
 #include <asm/bug.h>
 
-extern unsigned long __phys_addr(unsigned long);
-
 #endif /* __ASSEMBLY__ */
-
-#define __pa(x)		__phys_addr((unsigned long)(x))
-#define __pa_symbol(x)	__phys_addr((unsigned long)(x))
-
-#define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
-#define __boot_va(x)		__va(x)
-#define __boot_pa(x)		__pa(x)
-
-#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
-#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
-#define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 
 #define __HAVE_ARCH_GATE_AREA 1	
 #define vmemmap ((struct page *)VMEMMAP_START)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 6 of 8] x86: page.h: move remaining bits and pieces
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
                   ` (4 preceding siblings ...)
  2008-01-03 20:11 ` [PATCH 5 of 8] x86: page.h: move pa and va related things Jeremy Fitzhardinge
@ 2008-01-03 20:11 ` Jeremy Fitzhardinge
  2008-01-03 20:11 ` [PATCH 7 of 8] x86: page.h: move things back to their own files Jeremy Fitzhardinge
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199319657 28800
# Node ID bba9287641ff90e836d090d80b5c0a846aab7162
# Parent  d617b72a0cc9d14bde2087d065c36d4ed3265761
x86: page.h: move remaining bits and pieces

Move the remaining odds and ends into page.h.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/asm-x86/page.h    |   23 +++++++++++++++++++++++
 include/asm-x86/page_32.h |   17 -----------------
 include/asm-x86/page_64.h |   13 -------------
 3 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -80,6 +80,10 @@ void clear_page(void *page);
 void clear_page(void *page);
 void copy_page(void *to, void *from);
 
+extern unsigned long end_pfn;
+extern unsigned long end_pfn_map;
+extern unsigned long phys_base;
+
 extern unsigned long __phys_addr(unsigned long);
 #define __phys_reloc_hide(x)	(x)
 
@@ -97,6 +101,8 @@ typedef struct { pteval_t pte; } pte_t;
 
 #define native_pte_val(x)	((x).pte)
 #define native_make_pte(x) ((pte_t) { (x) } )
+
+#define vmemmap ((struct page *)VMEMMAP_START)
 
 #endif	/* !__ASSEMBLY__ */
 
@@ -183,6 +189,19 @@ static inline pte_t native_make_pte(unsi
 #ifdef CONFIG_FLATMEM
 #define pfn_valid(pfn)		((pfn) < max_mapnr)
 #endif /* CONFIG_FLATMEM */
+
+extern int nx_enabled;
+
+/*
+ * This much address space is reserved for vmalloc() and iomap()
+ * as well as fixmap mappings.
+ */
+extern unsigned int __VMALLOC_RESERVE;
+extern int sysctl_legacy_va_layout;
+extern int page_is_ram(unsigned long pagenr);
+
+#define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
+#define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
 
 #ifdef CONFIG_X86_USE_3DNOW
 #include <asm/mmx.h>
@@ -325,6 +344,10 @@ static inline pmdval_t native_pmd_val(pm
 
 #endif	/* __ASSEMBLY__ */
 
+#include <asm-generic/memory_model.h>
+#include <asm-generic/page.h>
+
+#define __HAVE_ARCH_GATE_AREA 1
 
 #ifdef CONFIG_X86_32
 # include "page_32.h"
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -7,7 +7,6 @@
 /*
  * These are used to make use of C type-checking..
  */
-extern int nx_enabled;
 
 #endif /* !__ASSEMBLY__ */
 
@@ -15,26 +14,10 @@ extern int nx_enabled;
 
 struct vm_area_struct;
 
-/*
- * This much address space is reserved for vmalloc() and iomap()
- * as well as fixmap mappings.
- */
-extern unsigned int __VMALLOC_RESERVE;
-
-extern int sysctl_legacy_va_layout;
-
-extern int page_is_ram(unsigned long pagenr);
-
 #endif /* __ASSEMBLY__ */
 
-#define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
-#define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
 
 
-#include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
-
-#define __HAVE_ARCH_GATE_AREA 1
 #endif /* __KERNEL__ */
 
 #endif /* _I386_PAGE_H */
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -4,25 +4,12 @@
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
-extern unsigned long end_pfn;
-extern unsigned long end_pfn_map;
-
-
-extern unsigned long phys_base;
-
 #endif /* !__ASSEMBLY__ */
 
 #ifndef __ASSEMBLY__
 
-#include <asm/bug.h>
 
 #endif /* __ASSEMBLY__ */
-
-#define __HAVE_ARCH_GATE_AREA 1	
-#define vmemmap ((struct page *)VMEMMAP_START)
-
-#include <asm-generic/memory_model.h>
-#include <asm-generic/page.h>
 
 #endif /* __KERNEL__ */
 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 7 of 8] x86: page.h: move things back to their own files
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
                   ` (5 preceding siblings ...)
  2008-01-03 20:11 ` [PATCH 6 of 8] x86: page.h: move remaining bits and pieces Jeremy Fitzhardinge
@ 2008-01-03 20:11 ` Jeremy Fitzhardinge
  2008-01-03 20:11 ` [PATCH 8 of 8] x86/efi: fix improper use of lvalue Jeremy Fitzhardinge
  2008-01-04  7:38 ` [PATCH 0 of 8] x86: unify asm/page.h Ingo Molnar
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199321648 28800
# Node ID 22f6a5902285b58bfc1fbbd9e183498c9017bd78
# Parent  bba9287641ff90e836d090d80b5c0a846aab7162
x86: page.h: move things back to their own files

Oops, asm/page.h has turned into an #ifdef hellhole.  Move
32/64-specific things back to their own headers to make it somewhat
comprehensible...

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

---
 include/asm-x86/page.h    |  212 +--------------------------------------------
 include/asm-x86/page_32.h |  123 +++++++++++++++++++++++---
 include/asm-x86/page_64.h |   74 ++++++++++++++-
 3 files changed, 187 insertions(+), 222 deletions(-)

diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild
--- a/include/asm-x86/Kbuild
+++ b/include/asm-x86/Kbuild
@@ -15,8 +15,7 @@ unifdef-y += mce.h
 unifdef-y += mce.h
 unifdef-y += msr.h
 unifdef-y += mtrr.h
-unifdef-y += page_32.h
-unifdef-y += page_64.h
+unifdef-y += page.h
 unifdef-y += posix_types_32.h
 unifdef-y += posix_types_64.h
 unifdef-y += ptrace.h
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -7,6 +7,8 @@
 #define PAGE_SHIFT	12
 #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
+
+#ifdef __KERNEL__
 
 #define PHYSICAL_PAGE_MASK	(PAGE_MASK & __PHYSICAL_MASK)
 #define PTE_MASK		PHYSICAL_PAGE_MASK
@@ -30,207 +32,10 @@
 #endif
 
 #ifdef CONFIG_X86_64
-#define PAGETABLE_LEVELS	4
-
-#define THREAD_ORDER	1
-#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
-#define CURRENT_MASK (~(THREAD_SIZE-1))
-
-#define EXCEPTION_STACK_ORDER 0
-#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
-
-#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
-#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
-
-#define IRQSTACK_ORDER 2
-#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
-
-#define STACKFAULT_STACK 1
-#define DOUBLEFAULT_STACK 2
-#define NMI_STACK 3
-#define DEBUG_STACK 4
-#define MCE_STACK 5
-#define N_EXCEPTION_STACKS 5  /* hw limit: 7 */
-
-#define __PAGE_OFFSET           _AC(0xffff810000000000, UL)
-
-#define __PHYSICAL_START	CONFIG_PHYSICAL_START
-#define __KERNEL_ALIGN		0x200000
-
-/*
- * Make sure kernel is aligned to 2MB address. Catching it at compile
- * time is better. Change your config file and compile the kernel
- * for a 2MB aligned address (CONFIG_PHYSICAL_START)
- */
-#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
-#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
-#endif
-
-#define __START_KERNEL		(__START_KERNEL_map + __PHYSICAL_START)
-#define __START_KERNEL_map	_AC(0xffffffff80000000, UL)
-
-/* See Documentation/x86_64/mm.txt for a description of the memory map. */
-#define __PHYSICAL_MASK_SHIFT	46
-#define __VIRTUAL_MASK_SHIFT	48
-
-#define KERNEL_TEXT_SIZE  (40*1024*1024)
-#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
-
-#ifndef __ASSEMBLY__
-void clear_page(void *page);
-void copy_page(void *to, void *from);
-
-extern unsigned long end_pfn;
-extern unsigned long end_pfn_map;
-extern unsigned long phys_base;
-
-extern unsigned long __phys_addr(unsigned long);
-#define __phys_reloc_hide(x)	(x)
-
-/*
- * These are used to make use of C type-checking..
- */
-typedef unsigned long	pteval_t;
-typedef unsigned long	pmdval_t;
-typedef unsigned long	pudval_t;
-typedef unsigned long	pgdval_t;
-typedef unsigned long	pgprotval_t;
-typedef unsigned long	phys_addr_t;
-
-typedef struct { pteval_t pte; } pte_t;
-
-#define native_pte_val(x)	((x).pte)
-#define native_make_pte(x) ((pte_t) { (x) } )
-
-#define vmemmap ((struct page *)VMEMMAP_START)
-
-#endif	/* !__ASSEMBLY__ */
-
+#include <asm/page_64.h>
+#else
+#include <asm/page_32.h>
 #endif	/* CONFIG_X86_64 */
-
-#ifdef CONFIG_X86_32
-
-/*
- * This handles the memory map.
- *
- * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
- * a virtual address space of one gigabyte, which limits the
- * amount of physical memory you can use to about 950MB.
- *
- * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
- * and CONFIG_HIGHMEM64G options in the kernel configuration.
- */
-#define __PAGE_OFFSET		_AC(CONFIG_PAGE_OFFSET, UL)
-
-#ifdef CONFIG_X86_PAE
-#define __PHYSICAL_MASK_SHIFT	36
-#define __VIRTUAL_MASK_SHIFT	32
-#define PAGETABLE_LEVELS	3
-
-#ifndef __ASSEMBLY__
-typedef u64	pteval_t;
-typedef u64	pmdval_t;
-typedef u64	pudval_t;
-typedef u64	pgdval_t;
-typedef u64	pgprotval_t;
-typedef u64	phys_addr_t;
-
-typedef struct { unsigned long pte_low, pte_high; } pte_t;
-
-static inline unsigned long long native_pte_val(pte_t pte)
-{
-	return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
-}
-
-static inline pte_t native_make_pte(unsigned long long val)
-{
-	return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
-}
-
-#endif	/* __ASSEMBLY__
- */
-#else  /* !CONFIG_X86_PAE */
-#define __PHYSICAL_MASK_SHIFT	32
-#define __VIRTUAL_MASK_SHIFT	32
-#define PAGETABLE_LEVELS	2
-
-#ifndef __ASSEMBLY__
-typedef unsigned long	pteval_t;
-typedef unsigned long	pmdval_t;
-typedef unsigned long	pudval_t;
-typedef unsigned long	pgdval_t;
-typedef unsigned long	pgprotval_t;
-typedef unsigned long	phys_addr_t;
-
-typedef struct { pteval_t pte_low; } pte_t;
-typedef pte_t boot_pte_t;
-
-static inline unsigned long native_pte_val(pte_t pte)
-{
-	return pte.pte_low;
-}
-
-static inline pte_t native_make_pte(unsigned long val)
-{
-	return (pte_t) { .pte_low = val };
-}
-
-#endif	/* __ASSEMBLY__ */
-#endif	/* CONFIG_X86_PAE */
-
-#ifdef CONFIG_HUGETLB_PAGE
-#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
-#endif
-
-#ifndef __ASSEMBLY__
-#define __phys_addr(x)		((x)-PAGE_OFFSET)
-#define __phys_reloc_hide(x)	RELOC_HIDE((x), 0)
-
-#ifdef CONFIG_FLATMEM
-#define pfn_valid(pfn)		((pfn) < max_mapnr)
-#endif /* CONFIG_FLATMEM */
-
-extern int nx_enabled;
-
-/*
- * This much address space is reserved for vmalloc() and iomap()
- * as well as fixmap mappings.
- */
-extern unsigned int __VMALLOC_RESERVE;
-extern int sysctl_legacy_va_layout;
-extern int page_is_ram(unsigned long pagenr);
-
-#define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
-#define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
-
-#ifdef CONFIG_X86_USE_3DNOW
-#include <asm/mmx.h>
-
-static inline void clear_page(void *page)
-{
-	mmx_clear_page(page);
-}
-
-static inline void copy_page(void *to, void *from)
-{
-	mmx_copy_page(to, from);
-}
-#else  /* !CONFIG_X86_USE_3DNOW */
-#include <linux/string.h>
-
-static inline void clear_page(void *page)
-{
-	memset(page, 0, PAGE_SIZE);
-}
-
-static inline void copy_page(void *to, void *from)
-{
-	memcpy(to, from, PAGE_SIZE);
-}
-#endif	/* CONFIG_X86_3DNOW */
-#endif	/* !__ASSEMBLY__ */
-
-#endif	/* CONFIG_X86_32 */
 
 #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
 
@@ -349,10 +154,5 @@ static inline pmdval_t native_pmd_val(pm
 
 #define __HAVE_ARCH_GATE_AREA 1
 
-#ifdef CONFIG_X86_32
-# include "page_32.h"
-#else
-# include "page_64.h"
-#endif
-
+#endif	/* __KERNEL__ */
 #endif	/* _ASM_X86_PAGE_H */
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -1,23 +1,124 @@
-#ifndef _I386_PAGE_H
-#define _I386_PAGE_H
-
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
+#ifndef _ASM_X86_PAGE_32_H
+#define _ASM_X86_PAGE_32_H
 
 /*
- * These are used to make use of C type-checking..
+ * This handles the memory map.
+ *
+ * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
+ * a virtual address space of one gigabyte, which limits the
+ * amount of physical memory you can use to about 950MB.
+ *
+ * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
+ * and CONFIG_HIGHMEM64G options in the kernel configuration.
  */
+#define __PAGE_OFFSET		_AC(CONFIG_PAGE_OFFSET, UL)
 
-#endif /* !__ASSEMBLY__ */
+#ifdef CONFIG_X86_PAE
+#define __PHYSICAL_MASK_SHIFT	36
+#define __VIRTUAL_MASK_SHIFT	32
+#define PAGETABLE_LEVELS	3
 
 #ifndef __ASSEMBLY__
+typedef u64	pteval_t;
+typedef u64	pmdval_t;
+typedef u64	pudval_t;
+typedef u64	pgdval_t;
+typedef u64	pgprotval_t;
+typedef u64	phys_addr_t;
 
-struct vm_area_struct;
+typedef struct { unsigned long pte_low, pte_high; } pte_t;
 
-#endif /* __ASSEMBLY__ */
+static inline unsigned long long native_pte_val(pte_t pte)
+{
+	return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
+}
 
+static inline pte_t native_make_pte(unsigned long long val)
+{
+	return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
+}
 
+#endif	/* __ASSEMBLY__
+ */
+#else  /* !CONFIG_X86_PAE */
+#define __PHYSICAL_MASK_SHIFT	32
+#define __VIRTUAL_MASK_SHIFT	32
+#define PAGETABLE_LEVELS	2
 
-#endif /* __KERNEL__ */
+#ifndef __ASSEMBLY__
+typedef unsigned long	pteval_t;
+typedef unsigned long	pmdval_t;
+typedef unsigned long	pudval_t;
+typedef unsigned long	pgdval_t;
+typedef unsigned long	pgprotval_t;
+typedef unsigned long	phys_addr_t;
 
-#endif /* _I386_PAGE_H */
+typedef struct { pteval_t pte_low; } pte_t;
+typedef pte_t boot_pte_t;
+
+static inline unsigned long native_pte_val(pte_t pte)
+{
+	return pte.pte_low;
+}
+
+static inline pte_t native_make_pte(unsigned long val)
+{
+	return (pte_t) { .pte_low = val };
+}
+
+#endif	/* __ASSEMBLY__ */
+#endif	/* CONFIG_X86_PAE */
+
+#ifdef CONFIG_HUGETLB_PAGE
+#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
+#endif
+
+#ifndef __ASSEMBLY__
+#define __phys_addr(x)		((x)-PAGE_OFFSET)
+#define __phys_reloc_hide(x)	RELOC_HIDE((x), 0)
+
+#ifdef CONFIG_FLATMEM
+#define pfn_valid(pfn)		((pfn) < max_mapnr)
+#endif /* CONFIG_FLATMEM */
+
+extern int nx_enabled;
+
+/*
+ * This much address space is reserved for vmalloc() and iomap()
+ * as well as fixmap mappings.
+ */
+extern unsigned int __VMALLOC_RESERVE;
+extern int sysctl_legacy_va_layout;
+extern int page_is_ram(unsigned long pagenr);
+
+#define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
+#define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
+
+#ifdef CONFIG_X86_USE_3DNOW
+#include <asm/mmx.h>
+
+static inline void clear_page(void *page)
+{
+	mmx_clear_page(page);
+}
+
+static inline void copy_page(void *to, void *from)
+{
+	mmx_copy_page(to, from);
+}
+#else  /* !CONFIG_X86_USE_3DNOW */
+#include <linux/string.h>
+
+static inline void clear_page(void *page)
+{
+	memset(page, 0, PAGE_SIZE);
+}
+
+static inline void copy_page(void *to, void *from)
+{
+	memcpy(to, from, PAGE_SIZE);
+}
+#endif	/* CONFIG_X86_3DNOW */
+#endif	/* !__ASSEMBLY__ */
+
+#endif /* _ASM_X86_PAGE_32_H */
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -1,16 +1,80 @@
 #ifndef _X86_64_PAGE_H
 #define _X86_64_PAGE_H
 
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
+#define PAGETABLE_LEVELS	4
 
-#endif /* !__ASSEMBLY__ */
+#define THREAD_ORDER	1
+#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
+#define CURRENT_MASK (~(THREAD_SIZE-1))
+
+#define EXCEPTION_STACK_ORDER 0
+#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
+
+#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
+#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
+
+#define IRQSTACK_ORDER 2
+#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
+
+#define STACKFAULT_STACK 1
+#define DOUBLEFAULT_STACK 2
+#define NMI_STACK 3
+#define DEBUG_STACK 4
+#define MCE_STACK 5
+#define N_EXCEPTION_STACKS 5  /* hw limit: 7 */
+
+#define __PAGE_OFFSET           _AC(0xffff810000000000, UL)
+
+#define __PHYSICAL_START	CONFIG_PHYSICAL_START
+#define __KERNEL_ALIGN		0x200000
+
+/*
+ * Make sure kernel is aligned to 2MB address. Catching it at compile
+ * time is better. Change your config file and compile the kernel
+ * for a 2MB aligned address (CONFIG_PHYSICAL_START)
+ */
+#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
+#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
+#endif
+
+#define __START_KERNEL		(__START_KERNEL_map + __PHYSICAL_START)
+#define __START_KERNEL_map	_AC(0xffffffff80000000, UL)
+
+/* See Documentation/x86_64/mm.txt for a description of the memory map. */
+#define __PHYSICAL_MASK_SHIFT	46
+#define __VIRTUAL_MASK_SHIFT	48
+
+#define KERNEL_TEXT_SIZE  (40*1024*1024)
+#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
 
 #ifndef __ASSEMBLY__
+void clear_page(void *page);
+void copy_page(void *to, void *from);
 
+extern unsigned long end_pfn;
+extern unsigned long end_pfn_map;
+extern unsigned long phys_base;
 
-#endif /* __ASSEMBLY__ */
+extern unsigned long __phys_addr(unsigned long);
+#define __phys_reloc_hide(x)	(x)
 
-#endif /* __KERNEL__ */
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef unsigned long	pteval_t;
+typedef unsigned long	pmdval_t;
+typedef unsigned long	pudval_t;
+typedef unsigned long	pgdval_t;
+typedef unsigned long	pgprotval_t;
+typedef unsigned long	phys_addr_t;
+
+typedef struct { pteval_t pte; } pte_t;
+
+#define native_pte_val(x)	((x).pte)
+#define native_make_pte(x) ((pte_t) { (x) } )
+
+#define vmemmap ((struct page *)VMEMMAP_START)
+
+#endif	/* !__ASSEMBLY__ */
 
 #endif /* _X86_64_PAGE_H */



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 8 of 8] x86/efi: fix improper use of lvalue
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
                   ` (6 preceding siblings ...)
  2008-01-03 20:11 ` [PATCH 7 of 8] x86: page.h: move things back to their own files Jeremy Fitzhardinge
@ 2008-01-03 20:11 ` Jeremy Fitzhardinge
  2008-01-04  7:38 ` [PATCH 0 of 8] x86: unify asm/page.h Ingo Molnar
  8 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-03 20:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich

# HG changeset patch
# User Jeremy Fitzhardinge <jeremy@xensource.com>
# Date 1199391030 28800
# Node ID 5d35c92fdf0e2c52edbb6fc4ccd06c7f65f25009
# Parent  22f6a5902285b58bfc1fbbd9e183498c9017bd78
x86/efi: fix improper use of lvalue

pgd_val is no longer valid as an lvalue, so don't try to assign to it.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>

---
 arch/x86/kernel/efi_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/efi_64.c b/arch/x86/kernel/efi_64.c
--- a/arch/x86/kernel/efi_64.c
+++ b/arch/x86/kernel/efi_64.c
@@ -84,7 +84,7 @@ void __init efi_call_phys_prelog(void)
 	local_irq_save(efi_flags);
 	early_runtime_code_mapping_set_exec(1);
 	vaddress = (unsigned long)__va(0x0UL);
-	pgd_val(save_pgd) = pgd_val(*pgd_offset_k(0x0UL));
+	save_pgd = *pgd_offset_k(0x0UL);
 	set_pgd(pgd_offset_k(0x0UL), *pgd_offset_k(vaddress));
 	__flush_tlb_all();
 }



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0 of 8] x86: unify asm/page.h
  2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
                   ` (7 preceding siblings ...)
  2008-01-03 20:11 ` [PATCH 8 of 8] x86/efi: fix improper use of lvalue Jeremy Fitzhardinge
@ 2008-01-04  7:38 ` Ingo Molnar
  8 siblings, 0 replies; 14+ messages in thread
From: Ingo Molnar @ 2008-01-04  7:38 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich,
	Thomas Gleixner, H. Peter Anvin


* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> Hi Ingo,
> 
> Here's a series which concentrates on unifying and cleaning up 
> asm-86/page*.h.  Each patch in the series restricts itself to doing 
> one thing fairly simply, so it should be fairly low-risk and easy to 
> bisect.

thanks Jeremy, i have applied your patches to x86.git.

> The early version of this patch got rid of asm/page_32|64.h entirely, 
> but I decided the resulting #ifdef hell was too hard to deal with, so 
> I moved purely 32/64-bit specific stuff into their own files.

agreed - and the result certainly looks clean.

	Ingo

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1 of 8] x86: page.h: unify constants
  2008-01-03 20:10 ` [PATCH 1 of 8] x86: page.h: unify constants Jeremy Fitzhardinge
@ 2008-01-07 17:17   ` Andi Kleen
  2008-01-07 22:13     ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 14+ messages in thread
From: Andi Kleen @ 2008-01-07 17:17 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Ingo Molnar, LKML, Andi Kleen, Glauber de Oliveira Costa, Jan Beulich


> +
> +#define LARGE_PAGE_SIZE		(_AC(1,UL) << PMD_SHIFT)
> +#define LARGE_PAGE_MASK		(~(LARGE_PAGE_SIZE-1))
> +
> +#define HPAGE_SHIFT		PMD_SHIFT
> +#define HPAGE_SIZE		(_AC(1,UL) << HPAGE_SHIFT)
> +#define HPAGE_MASK		(~(HPAGE_SIZE - 1))
> +#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)

This will actually stop being the same soon with GB pages which
are only supported on 64bit.

> +
> +#ifdef CONFIG_X86_64
> +#define THREAD_ORDER	1
> +#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
> +#define CURRENT_MASK (~(THREAD_SIZE-1))
> +
> +#define EXCEPTION_STACK_ORDER 0
> +#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
> +
> +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
> +#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
> +
> +#define IRQSTACK_ORDER 2
> +#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)

This all seems hardly 64bit specific (except for THREAD_ORDER
but you can probably handle that in Kconfig or just get rid
of it for 32bit)

> +#define __PHYSICAL_START	CONFIG_PHYSICAL_START

Also not 64bit specific

> +#ifdef CONFIG_X86_PAE
> +#define __PHYSICAL_MASK_SHIFT	36

I originally added the PHYSICAL_MASK stuff to deal with masking off NX,
but I must admit it wasn't the best idea I ever had. It would be probably
better to just get rid of it and always mask off the high reserved flags bit
explicitely. If you make that 0 then there should be no special
case for PAE.

-Andi

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1 of 8] x86: page.h: unify constants
  2008-01-07 17:17   ` Andi Kleen
@ 2008-01-07 22:13     ` Jeremy Fitzhardinge
  2008-01-07 23:13       ` Andi Kleen
  0 siblings, 1 reply; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-07 22:13 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Ingo Molnar, LKML, Glauber de Oliveira Costa, Jan Beulich

Andi Kleen wrote:
>> +
>> +#define LARGE_PAGE_SIZE		(_AC(1,UL) << PMD_SHIFT)
>> +#define LARGE_PAGE_MASK		(~(LARGE_PAGE_SIZE-1))
>> +
>> +#define HPAGE_SHIFT		PMD_SHIFT
>> +#define HPAGE_SIZE		(_AC(1,UL) << HPAGE_SHIFT)
>> +#define HPAGE_MASK		(~(HPAGE_SIZE - 1))
>> +#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
>>     
>
> This will actually stop being the same soon with GB pages which
> are only supported on 64bit.
>   

I was wondering about that.  Will you always use GB pages, or will there 
be two classes of huge pages, or will it be a runtime/compiletime config?

>> +
>> +#ifdef CONFIG_X86_64
>> +#define THREAD_ORDER	1
>> +#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
>> +#define CURRENT_MASK (~(THREAD_SIZE-1))
>> +
>> +#define EXCEPTION_STACK_ORDER 0
>> +#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
>> +
>> +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
>> +#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
>> +
>> +#define IRQSTACK_ORDER 2
>> +#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
>>     
>
> This all seems hardly 64bit specific (except for THREAD_ORDER
> but you can probably handle that in Kconfig or just get rid
> of it for 32bit)
>   

They're only used by 64-bit at the moment, aren't they?  Or are you 
suggesting 32-bit could use them too?  There's no corresponding 
definitions on the 32-bit side at the moment.

>> +#define __PHYSICAL_START	CONFIG_PHYSICAL_START
>>     
>
> Also not 64bit specific
>   

It's use is 64-bit specific though, isn't it?

>> +#ifdef CONFIG_X86_PAE
>> +#define __PHYSICAL_MASK_SHIFT	36
>>     
>
> I originally added the PHYSICAL_MASK stuff to deal with masking off NX,
> but I must admit it wasn't the best idea I ever had. It would be probably
> better to just get rid of it and always mask off the high reserved flags bit
> explicitely. If you make that 0 then there should be no special
> case for PAE.
>   

Hm, OK.  I thought different 64-bit implementations might have different 
sized physical address spaces or something.


    J

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1 of 8] x86: page.h: unify constants
  2008-01-07 22:13     ` Jeremy Fitzhardinge
@ 2008-01-07 23:13       ` Andi Kleen
  2008-01-08  1:11         ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 14+ messages in thread
From: Andi Kleen @ 2008-01-07 23:13 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Andi Kleen, Ingo Molnar, LKML, Glauber de Oliveira Costa, Jan Beulich

On Mon, Jan 07, 2008 at 02:13:52PM -0800, Jeremy Fitzhardinge wrote:
> Andi Kleen wrote:
>>> +
>>> +#define LARGE_PAGE_SIZE		(_AC(1,UL) << PMD_SHIFT)
>>> +#define LARGE_PAGE_MASK		(~(LARGE_PAGE_SIZE-1))
>>> +
>>> +#define HPAGE_SHIFT		PMD_SHIFT
>>> +#define HPAGE_SIZE		(_AC(1,UL) << HPAGE_SHIFT)
>>> +#define HPAGE_MASK		(~(HPAGE_SIZE - 1))
>>> +#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
>>>     
>>
>> This will actually stop being the same soon with GB pages which
>> are only supported on 64bit.
>>   
>
> I was wondering about that.  Will you always use GB pages, or will there be 

When available and not disabled yes.

> two classes of huge pages, or will it be a runtime/compiletime config?

hugetlbfs will use different classes of huge pages depending on configuration
(I haven't posted those patches yet, only those for the direct mapping) 
That all is expressed by different macros.

All runtime; I expect no CONFIGs involved, except that 32bit won't have
it since the architecture doesn't support it there.



>
>>> +
>>> +#ifdef CONFIG_X86_64
>>> +#define THREAD_ORDER	1
>>> +#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
>>> +#define CURRENT_MASK (~(THREAD_SIZE-1))
>>> +
>>> +#define EXCEPTION_STACK_ORDER 0
>>> +#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
>>> +
>>> +#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
>>> +#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
>>> +
>>> +#define IRQSTACK_ORDER 2
>>> +#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
>>>     
>>
>> This all seems hardly 64bit specific (except for THREAD_ORDER
>> but you can probably handle that in Kconfig or just get rid
>> of it for 32bit)
>>   
>
> They're only used by 64-bit at the moment, aren't they?  Or are you 

THREAD_ORDER should be used on 32bit too.

32bit also has the equivalent of irq stacks (quite similar) 
and exception stacks (somewhat different). Currently they use
other defines, but they could use the same. Also i386 has varying
irqstack orders disabling them with 8k stacks, but that is something
that would be best dropped and irqstacks always used imho.

>>> +#define __PHYSICAL_START	CONFIG_PHYSICAL_START
>>>     
>>
>> Also not 64bit specific
>>   
>
> It's use is 64-bit specific though, isn't it?

It might be, but it's not a 64bit specific concept.

>
>>> +#ifdef CONFIG_X86_PAE
>>> +#define __PHYSICAL_MASK_SHIFT	36
>>>     
>>
>> I originally added the PHYSICAL_MASK stuff to deal with masking off NX,
>> but I must admit it wasn't the best idea I ever had. It would be probably
>> better to just get rid of it and always mask off the high reserved flags 
>> bit
>> explicitely. If you make that 0 then there should be no special
>> case for PAE.
>>   
>
> Hm, OK.  I thought different 64-bit implementations might have different 
> sized physical address spaces or something.

Yes they do, but hardcoding that doesn't make sense because it varies.
We already got CPUs with 36, 38, 40 and 48 bits phys size.

The only size that could be hard coded would be 52 bit (theoretical max), but 
that also doesn't make sense if all we want to do is to mask off NX.

The only code that needs to know the real physical size is the MTRR
code, but that one gets it from CPUID as it should.

-Andi

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1 of 8] x86: page.h: unify constants
  2008-01-07 23:13       ` Andi Kleen
@ 2008-01-08  1:11         ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-01-08  1:11 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Ingo Molnar, LKML, Glauber de Oliveira Costa, Jan Beulich

Andi Kleen wrote:
> THREAD_ORDER should be used on 32bit too.
>
> 32bit also has the equivalent of irq stacks (quite similar) 
> and exception stacks (somewhat different). Currently they use
> other defines, but they could use the same. Also i386 has varying
> irqstack orders disabling them with 8k stacks, but that is something
> that would be best dropped and irqstacks always used imho.
> [...]
> It might be, but it's not a 64bit specific concept.
>   

OK.  That's out of the scope of these particular patches, since they're 
restricting themselves to just unifying what's there.  Another pass 
could definitely tidy a lot more up.

> Yes they do, but hardcoding that doesn't make sense because it varies.
> We already got CPUs with 36, 38, 40 and 48 bits phys size.
>
> The only size that could be hard coded would be 52 bit (theoretical max), but 
> that also doesn't make sense if all we want to do is to mask off NX.
>   

OK.  I'll see how much removing it gains us.

    J

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-01-08  1:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-03 20:10 [PATCH 0 of 8] x86: unify asm/page.h Jeremy Fitzhardinge
2008-01-03 20:10 ` [PATCH 1 of 8] x86: page.h: unify constants Jeremy Fitzhardinge
2008-01-07 17:17   ` Andi Kleen
2008-01-07 22:13     ` Jeremy Fitzhardinge
2008-01-07 23:13       ` Andi Kleen
2008-01-08  1:11         ` Jeremy Fitzhardinge
2008-01-03 20:10 ` [PATCH 2 of 8] x86: page.h: unify page copying and clearing Jeremy Fitzhardinge
2008-01-03 20:11 ` [PATCH 3 of 8] x86: add _AT() macro to conditionally cast Jeremy Fitzhardinge
2008-01-03 20:11 ` [PATCH 4 of 8] x86: page.h: move and unify types for pagetable entry definitions Jeremy Fitzhardinge
2008-01-03 20:11 ` [PATCH 5 of 8] x86: page.h: move pa and va related things Jeremy Fitzhardinge
2008-01-03 20:11 ` [PATCH 6 of 8] x86: page.h: move remaining bits and pieces Jeremy Fitzhardinge
2008-01-03 20:11 ` [PATCH 7 of 8] x86: page.h: move things back to their own files Jeremy Fitzhardinge
2008-01-03 20:11 ` [PATCH 8 of 8] x86/efi: fix improper use of lvalue Jeremy Fitzhardinge
2008-01-04  7:38 ` [PATCH 0 of 8] x86: unify asm/page.h Ingo Molnar

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.