* [PATCH 2/17] Generic backward compatibility includes for 4level
@ 2004-10-25 7:23 Andreas Kleen
2004-10-25 9:39 ` Russell King
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Kleen @ 2004-10-25 7:23 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, akpm
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.
Signed-off-by: Andi Kleen <ak@suse.de>
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
--- linux-2.6.10rc1/include/asm-generic/nopml4-page.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.10rc1-4level/include/asm-generic/nopml4-page.h 2004-10-25 04:48:10.000000000 +0200
@@ -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
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
--- linux-2.6.10rc1/include/asm-generic/nopml4-pgalloc.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.10rc1-4level/include/asm-generic/nopml4-pgalloc.h 2004-10-25 04:48:10.000000000 +0200
@@ -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
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/nopml4-pgtable.h linux-2.6.10rc1-4level/include/asm-generic/nopml4-pgtable.h
--- linux-2.6.10rc1/include/asm-generic/nopml4-pgtable.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.10rc1-4level/include/asm-generic/nopml4-pgtable.h 2004-10-25 04:48:10.000000000 +0200
@@ -0,0 +1,43 @@
+#ifndef _NOPML4_H
+#define _NOPML4_H 1
+
+#ifndef __ASSEMBLY__
+
+/* Included by architectures that don't have a fourth page table level.
+
+ pml4 is simply casted to pgd */
+
+#define pml4_ERROR(x)
+#define pml4_bad(x) 0
+#define pml4_clear(x)
+
+/* Covers all address room. This implies that walks will usually wrap.
+ The code has to handle this.
+
+ Could use TASK_SIZE here, but a lot of architectures make it different
+ for 32bit and 64bit tasks. */
+#define PML4_SIZE (~0UL)
+#define PML4_MASK 0UL
+
+#define pml4_offset(mm, addr) ((mm)->pml4)
+#define pml4_offset_k(addr) (init_mm.pml4)
+#define pml4_pgd_offset(pml4, addr) ((pgd_t *)(pml4) + pgd_index(addr))
+#define pml4_pgd_offset_k(pml4, addr) ((pgd_t *)(pml4) + pgd_index_k(addr))
+
+#define pml4_none(pml4) 0
+#define pml4_present(pml4) 1
+#define pml4_index(pml4) 0
+
+#define swapper_pml4 ((pml4_t *)swapper_pg_dir)
+
+/* Use pml4_pgd_offset and pml4_offset_k instead */
+
+#undef pgd_offset
+#define pgd_offset pgd_offset_is_obsolete
+
+#undef pgd_offset_k
+#define pgd_offset_k pgd_offset_k_is_obsolete
+
+#endif
+
+#endif
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/pgtable.h linux-2.6.10rc1-4level/include/asm-generic/pgtable.h
--- linux-2.6.10rc1/include/asm-generic/pgtable.h 2004-10-19 01:55:32.000000000 +0200
+++ linux-2.6.10rc1-4level/include/asm-generic/pgtable.h 2004-10-25 04:48:10.000000000 +0200
@@ -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 */
diff -urpN -X ../KDIFX linux-2.6.10rc1/include/asm-generic/tlb.h linux-2.6.10rc1-4level/include/asm-generic/tlb.h
--- linux-2.6.10rc1/include/asm-generic/tlb.h 2004-08-15 19:45:46.000000000 +0200
+++ linux-2.6.10rc1-4level/include/asm-generic/tlb.h 2004-10-25 04:48:10.000000000 +0200
@@ -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 */
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/17] Generic backward compatibility includes for 4level
2004-10-25 7:23 [PATCH 2/17] Generic backward compatibility includes for 4level Andreas Kleen
@ 2004-10-25 9:39 ` Russell King
2004-10-25 16:06 ` Andi Kleen
0 siblings, 1 reply; 5+ messages in thread
From: Russell King @ 2004-10-25 9:39 UTC (permalink / raw)
To: Andreas Kleen; +Cc: torvalds, linux-kernel, akpm
On Mon, Oct 25, 2004 at 09:23:49AM +0200, Andreas Kleen wrote:
> +/* 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?
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/17] Generic backward compatibility includes for 4level
2004-10-25 9:39 ` Russell King
@ 2004-10-25 16:06 ` Andi Kleen
2004-10-25 16:50 ` Arjan van de Ven
0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2004-10-25 16:06 UTC (permalink / raw)
To: Andreas Kleen, torvalds, linux-kernel, akpm
On Mon, Oct 25, 2004 at 10:39:26AM +0100, Russell King wrote:
> On Mon, Oct 25, 2004 at 09:23:49AM +0200, Andreas Kleen wrote:
> > +/* 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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/17] Generic backward compatibility includes for 4level
2004-10-25 16:06 ` Andi Kleen
@ 2004-10-25 16:50 ` Arjan van de Ven
2004-10-25 17:02 ` Andi Kleen
0 siblings, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2004-10-25 16:50 UTC (permalink / raw)
To: Andi Kleen; +Cc: torvalds, linux-kernel, akpm
> >
> > 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();
--
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/17] Generic backward compatibility includes for 4level
2004-10-25 16:50 ` Arjan van de Ven
@ 2004-10-25 17:02 ` Andi Kleen
0 siblings, 0 replies; 5+ messages in thread
From: Andi Kleen @ 2004-10-25 17:02 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Andi Kleen, torvalds, linux-kernel, akpm
On Mon, Oct 25, 2004 at 06:50:34PM +0200, Arjan van de Ven wrote:
> > >
> > > 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();
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-10-25 17:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-25 7:23 [PATCH 2/17] Generic backward compatibility includes for 4level Andreas Kleen
2004-10-25 9:39 ` Russell King
2004-10-25 16:06 ` Andi Kleen
2004-10-25 16:50 ` Arjan van de Ven
2004-10-25 17:02 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox