Skip to contentSkip to conversation

Generic backward compatibility includes for 4level

PATCH In review Andreas Kleen 3 participants 5 messages Oct 25, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/17 Generic backward compatibility includes for 4level

Generic backward compatibility includes for 4level

This adds some asm-generic file to allow conversion of 2level and 3level architectures to 4levels without much duplicated code.

The pml4 is simply a pointer to the pgd.

include/asm-generic/nopml4-page.h +14 -0
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/nopml4-page.h linux-2.6.10rc1-4level/include/asm-generic/nopml4-page.h
@@ -0,0 +1,14 @@
+#ifndef _NOPML4_PAGE_H
+#define _NOPML4_PAGE_H 1
+
+#ifndef __ASSEMBLY__
+
+/* 
+ * Generic page.h declarations for architectures without four level
+ * page tables 
+ */
+
+typedef struct { pgd_t pgd; } pml4_t; 
+#endif
+
+#endif
include/asm-generic/nopml4-pgalloc.h +21 -0
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/nopml4-pgalloc.h linux-2.6.10rc1-4level/include/asm-generic/nopml4-pgalloc.h
@@ -0,0 +1,21 @@
+#ifndef _NOPML4_PGALLOC_H
+#define _NOPML4_PGALLOC_H 1
+
+/* Fallback used for architectures without 4 level pagetables */
+
+#define pml4_populate(mm, pml4, pgd) ((mm)->pml4 = (pml4_t *)(pgd)) 
+
+static inline pml4_t *pml4_alloc(struct mm_struct *mm)
+{
+	pml4_t dummy;
+	return (pml4_t *)__pgd_alloc(mm, &dummy, 0);
+} 
+
+static inline void pml4_free(pml4_t *pml4)
+{
+	pgd_free((pgd_t *)pml4);
+}
+
+#define __pgd_free_tlb(tlb,x)   do {} while(0)
+
+#endif
include/asm-generic/nopml4-pgtable.h +43 -0

43 lines not on this page · raw message

include/asm-generic/pgtable.h +1 -1
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/pgtable.h linux-2.6.10rc1-4level/include/asm-generic/pgtable.h
@@ -131,7 +131,7 @@ static inline void ptep_mkdirty(pte_t *p
 #endif
 
 #ifndef __HAVE_ARCH_PGD_OFFSET_GATE
-#define pgd_offset_gate(mm, addr)	pgd_offset(mm, addr)
+#define pml4_offset_gate(mm, addr)	pml4_offset(mm, addr)
 #endif
 
 #endif /* _ASM_GENERIC_PGTABLE_H */
include/asm-generic/tlb.h +6 -0
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/tlb.h linux-2.6.10rc1-4level/include/asm-generic/tlb.h
@@ -147,6 +147,12 @@ static inline void tlb_remove_page(struc
 		__pmd_free_tlb(tlb, pmdp);			\
 	} while (0)
 
+#define pgd_free_tlb(tlb, pgdp)					\
+	do {							\
+		tlb->need_flush = 1;				\
+		__pgd_free_tlb(tlb, pgdp);			\
+	} while (0)
+
 #define tlb_migrate_finish(mm) do {} while (0)
 
 #endif /* _ASM_GENERIC__TLB_H */
#1 lore raw

include/asm-generic/nopml4-pgtable.h line 10

Quoted 5 lines · Andreas Kleen
include/asm-generic/nopml4-pgtable.h +5 -0
+/* Included by architectures that don't have a fourth page table level.
+
+   pml4 is simply casted to pgd */
+
+#define pml4_ERROR(x) 

Don't we normally add do { } while (0) after empty macros which look like a function?

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
author
#2 lore raw
Quoted 9 lines · Russell King

include/asm-generic/nopml4-pgtable.h line 10

Quoted 5 lines · Andreas Kleen
include/asm-generic/nopml4-pgtable.h +5 -0
+/* Included by architectures that don't have a fourth page table level.
+
+   pml4 is simply casted to pgd */
+
+#define pml4_ERROR(x) 

Don't we normally add do { } while (0) after empty macros which look like a function?

iirc Rusty tried to come up with an example some time ago where it actually made a difference, but failed. But I can change it.

-Andi

#3 lore raw
Quoted 6 lines
Quoted 3 lines

Don't we normally add do { } while (0) after empty macros which look like a function?

iirc Rusty tried to come up with an example some time ago where it actually made a difference, but failed. But I can change it.

if (foo)

	bar(); 
else 
	pml4_ERROR(x);

something_else();

author
#4 lore raw
Quoted 8 lines · Arjan van de Ven
Quoted 6 lines
Quoted 3 lines

Don't we normally add do { } while (0) after empty macros which look like a function?

iirc Rusty tried to come up with an example some time ago where it actually made a difference, but failed. But I can change it.

Quoted 5 lines

if (foo)

	bar(); 
else 
	pml4_ERROR(x);

something_else();

Doesn't make any difference. Try it. With a double else it may make a difference, but that is extremly bad style imho and better resolved with a {}. Also you'll get a clear compile error.

-Andi