From d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a Mon Sep 17 00:00:00 2001 From: Jakub Jermar Date: Fri, 1 Dec 2006 22:10:40 +0000 Subject: [PATCH] Introduce page colors. So far, only sparc64 uses correct page color bits. Other architectures have a dummy define specifying zero bits for a page color. There is a new check of page color in as_area_share(). Because of lack of support for this in the userspace, the check has been #ifef'ed out. --- kernel/arch/amd64/include/mm/page.h | 2 ++ kernel/arch/ia32/include/mm/page.h | 2 ++ kernel/arch/ia32xen/include/mm/page.h | 2 ++ kernel/arch/ia64/include/mm/page.h | 5 +++-- kernel/arch/mips32/include/mm/page.h | 2 ++ kernel/arch/ppc32/include/mm/page.h | 2 ++ kernel/arch/ppc64/include/mm/page.h | 2 ++ kernel/arch/sparc64/include/mm/page.h | 2 ++ kernel/genarch/src/mm/asid_fifo.c | 4 ++-- kernel/generic/include/mm/page.h | 6 ++++++ kernel/generic/src/mm/as.c | 27 +++++++++++++++++++++------ 11 files changed, 46 insertions(+), 10 deletions(-) diff --git a/kernel/arch/amd64/include/mm/page.h b/kernel/arch/amd64/include/mm/page.h index f849d4dd6..d0a1e05eb 100644 --- a/kernel/arch/amd64/include/mm/page.h +++ b/kernel/arch/amd64/include/mm/page.h @@ -52,6 +52,8 @@ #define PAGE_WIDTH FRAME_WIDTH #define PAGE_SIZE FRAME_SIZE +#define PAGE_COLOR_BITS 0 /* dummy */ + #ifdef KERNEL #ifndef __ASM__ diff --git a/kernel/arch/ia32/include/mm/page.h b/kernel/arch/ia32/include/mm/page.h index 636d9e015..349ae06df 100644 --- a/kernel/arch/ia32/include/mm/page.h +++ b/kernel/arch/ia32/include/mm/page.h @@ -40,6 +40,8 @@ #define PAGE_WIDTH FRAME_WIDTH #define PAGE_SIZE FRAME_SIZE +#define PAGE_COLOR_BITS 0 /* dummy */ + #ifdef KERNEL #ifndef __ASM__ diff --git a/kernel/arch/ia32xen/include/mm/page.h b/kernel/arch/ia32xen/include/mm/page.h index 760c8c7eb..1b171145b 100644 --- a/kernel/arch/ia32xen/include/mm/page.h +++ b/kernel/arch/ia32xen/include/mm/page.h @@ -40,6 +40,8 @@ #define PAGE_WIDTH FRAME_WIDTH #define PAGE_SIZE FRAME_SIZE +#define PAGE_COLOR_BITS 0 /* dummy */ + #ifdef KERNEL #ifndef __ASM__ diff --git a/kernel/arch/ia64/include/mm/page.h b/kernel/arch/ia64/include/mm/page.h index 9ee6d4d6c..868a4aa2e 100644 --- a/kernel/arch/ia64/include/mm/page.h +++ b/kernel/arch/ia64/include/mm/page.h @@ -41,11 +41,12 @@ #define PAGE_SIZE FRAME_SIZE #define PAGE_WIDTH FRAME_WIDTH +#define PAGE_COLOR_BITS 0 /* dummy */ #ifdef KERNEL /** Bit width of the TLB-locked portion of kernel address space. */ -#define KERNEL_PAGE_WIDTH 28 /* 256M */ +#define KERNEL_PAGE_WIDTH 28 /* 256M */ #define PPN_SHIFT 12 @@ -64,7 +65,7 @@ #define KA2PA(x) ((uintptr_t) (x-(VRN_KERNEL<> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1)) + /** Page fault access type. */ enum pf_access { PF_ACCESS_READ, diff --git a/kernel/generic/src/mm/as.c b/kernel/generic/src/mm/as.c index a7602b8c2..2f3d726ec 100644 --- a/kernel/generic/src/mm/as.c +++ b/kernel/generic/src/mm/as.c @@ -550,12 +550,13 @@ int as_area_destroy(as_t *as, uintptr_t address) * @param dst_base Target base address. * @param dst_flags_mask Destination address space area flags mask. * - * @return Zero on success or ENOENT if there is no such task or - * if there is no such address space area, - * EPERM if there was a problem in accepting the area or - * ENOMEM if there was a problem in allocating destination - * address space area. ENOTSUP is returned if an attempt - * to share non-anonymous address space area is detected. + * @return Zero on success or ENOENT if there is no such task or if there is no + * such address space area, EPERM if there was a problem in accepting the area + * or ENOMEM if there was a problem in allocating destination address space + * area. ENOTSUP is returned if the address space area backend does not support + * sharing. It can be also returned if the architecture uses virtually indexed + * caches and the source and destination areas start at pages with different + * page colors. */ int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size, as_t *dst_as, uintptr_t dst_base, int dst_flags_mask) @@ -580,6 +581,20 @@ int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size, return ENOENT; } +#if 0 /* disable the check for now */ +#ifdef CONFIG_VIRT_IDX_CACHE + if (PAGE_COLOR(src_area->base) != PAGE_COLOR(dst_base)) { + /* + * Refuse to create illegal address alias. + */ + mutex_unlock(&src_area->lock); + mutex_unlock(&src_as->lock); + interrupts_restore(ipl); + return ENOTSUP; + } +#endif /* CONFIG_VIRT_IDX_CACHE */ +#endif + if (!src_area->backend || !src_area->backend->share) { /* * There is no backend or the backend does not -- 2.11.4.GIT