Module Name: src Committed By: skrll Date: Sat Nov 7 08:48:11 UTC 2020
Modified Files: src/sys/arch/aarch64/aarch64: pmapboot.c Log Message: Fix the use of the contiguous bit by checking the output address as well. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/pmapboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/aarch64/aarch64/pmapboot.c diff -u src/sys/arch/aarch64/aarch64/pmapboot.c:1.10 src/sys/arch/aarch64/aarch64/pmapboot.c:1.11 --- src/sys/arch/aarch64/aarch64/pmapboot.c:1.10 Fri Jul 17 07:21:44 2020 +++ src/sys/arch/aarch64/aarch64/pmapboot.c Sat Nov 7 08:48:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmapboot.c,v 1.10 2020/07/17 07:21:44 ryo Exp $ */ +/* $NetBSD: pmapboot.c,v 1.11 2020/11/07 08:48:11 skrll Exp $ */ /* * Copyright (c) 2018 Ryo Shimizu <r...@nerv.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v 1.10 2020/07/17 07:21:44 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v 1.11 2020/11/07 08:48:11 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_ddb.h" @@ -46,7 +46,6 @@ __KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v #include <aarch64/pmap.h> #include <aarch64/pte.h> - #define OPTIMIZE_TLB_CONTIG static void @@ -180,16 +179,23 @@ pmapboot_pte_print(pt_entry_t pte, int l #ifdef OPTIMIZE_TLB_CONTIG static inline bool -tlb_contiguous_p(vaddr_t addr, vaddr_t start, vaddr_t end, vsize_t blocksize) +tlb_contiguous_p(vaddr_t va, paddr_t pa, vaddr_t start, vaddr_t end, + vsize_t blocksize) { /* * when using 4KB granule, 16 adjacent and aligned entries can be * unified to one TLB cache entry. * in other size of granule, not supported. */ - if (((addr & ~((blocksize << 4) - 1)) >= start) && - ((addr | ((blocksize << 4) - 1)) <= end)) + const vaddr_t mask = (blocksize << 4) - 1; + + /* if the output address doesn't align it can't be contiguous */ + if ((va & mask) != (pa & mask)) + return false; + + if ((va & ~mask) >= start && (va | mask) <= end) return true; + return false; } #endif /* OPTIMIZE_TLB_CONTIG */ @@ -288,7 +294,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p #endif attr; #ifdef OPTIMIZE_TLB_CONTIG - if (tlb_contiguous_p(va, va_start, va_end, blocksize)) + if (tlb_contiguous_p(va, pa, va_start, va_end, blocksize)) pte |= LX_BLKPAG_CONTIG; ll = l1; llidx = idx1; @@ -333,7 +339,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p #endif attr; #ifdef OPTIMIZE_TLB_CONTIG - if (tlb_contiguous_p(va, va_start, va_end, blocksize)) + if (tlb_contiguous_p(va, pa, va_start, va_end, blocksize)) pte |= LX_BLKPAG_CONTIG; ll = l2; llidx = idx2; @@ -377,7 +383,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p #endif attr; #ifdef OPTIMIZE_TLB_CONTIG - if (tlb_contiguous_p(va, va_start, va_end, blocksize)) + if (tlb_contiguous_p(va, pa, va_start, va_end, blocksize)) pte |= LX_BLKPAG_CONTIG; ll = l3; llidx = idx3;