From 58e38c500340afec2fdf042739400043665e726f Mon Sep 17 00:00:00 2001 From: miod Date: Sun, 1 Jan 2023 19:49:17 +0000 Subject: [PATCH] With the introduction of the PMAP_PREFER_{ALIGN,OFFSET} macros a long time ago, there are actually no more uses of the PMAP_PREFER() macro left in the kernel. Remove that macro but keep PMAP_PREFER as a simple #define for it to let uvm knows the PMAP_PREFER_{ALIGN,OFFSET} macros are available. ok mpi@ --- sys/arch/arm/arm/pmap7.c | 19 +------------------ sys/arch/arm/include/pmap.h | 19 +------------------ sys/arch/hppa/include/cpu.h | 3 +-- sys/arch/hppa/include/pmap.h | 13 ++----------- sys/arch/mips64/include/pmap.h | 6 ++---- sys/arch/mips64/mips64/pmap.c | 15 +-------------- sys/arch/sh/include/pmap.h | 7 +++---- sys/arch/sh/sh/pmap.c | 17 +---------------- sys/arch/sparc64/include/pmap.h | 6 +++--- sys/uvm/uvm_pmap.h | 3 +-- 10 files changed, 16 insertions(+), 92 deletions(-) diff --git a/sys/arch/arm/arm/pmap7.c b/sys/arch/arm/arm/pmap7.c index c4af1c8f72d..44bb3b356b3 100644 --- a/sys/arch/arm/arm/pmap7.c +++ b/sys/arch/arm/arm/pmap7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap7.c,v 1.65 2022/09/12 19:28:19 miod Exp $ */ +/* $OpenBSD: pmap7.c,v 1.66 2023/01/01 19:49:17 miod Exp $ */ /* $NetBSD: pmap.c,v 1.147 2004/01/18 13:03:50 scw Exp $ */ /* @@ -2848,20 +2848,3 @@ pmap_pte_init_armv7(void) if ((id_mmfr3 & 0x00f00000) == 0x00100000) pmap_needs_pte_sync = 0; } - -uint32_t pmap_alias_dist; -uint32_t pmap_alias_bits; - -vaddr_t -pmap_prefer(vaddr_t foff, vaddr_t va) -{ - long d, m; - - m = pmap_alias_dist; - if (m == 0) /* m=0 => no cache aliasing */ - return va; - - d = foff - va; - d &= (m - 1); - return va + d; -} diff --git a/sys/arch/arm/include/pmap.h b/sys/arch/arm/include/pmap.h index 213ff352f6f..eb9ced1a9be 100644 --- a/sys/arch/arm/include/pmap.h +++ b/sys/arch/arm/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.51 2022/09/12 19:28:19 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.52 2023/01/01 19:49:17 miod Exp $ */ /* $NetBSD: pmap.h,v 1.76 2003/09/06 09:10:46 rearnsha Exp $ */ /* @@ -613,23 +613,6 @@ l2pte_is_writeable(pt_entry_t pte, struct pmap *pm) #define L2_L_MAPPABLE_P(va, pa, size) \ ((((va) | (pa)) & L2_L_OFFSET) == 0 && (size) >= L2_L_SIZE) -#ifndef _LOCORE -/* pmap_prefer bits for VIPT ARMv7 */ -#define PMAP_PREFER(fo, ap) pmap_prefer((fo), (ap)) -vaddr_t pmap_prefer(vaddr_t, vaddr_t); - -extern uint32_t pmap_alias_dist; -extern uint32_t pmap_alias_bits; - -/* pmap prefer alias alignment. */ -#define PMAP_PREFER_ALIGN() (pmap_alias_dist) -/* pmap prefer offset withing alignment. */ -#define PMAP_PREFER_OFFSET(of) \ - (PMAP_PREFER_ALIGN() == 0 ? 0 : ((of) & (PMAP_PREFER_ALIGN() - 1))) - - -#endif /* _LOCORE */ - #endif /* _KERNEL */ #ifndef _LOCORE diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h index c3fd832a235..4ad87f3a2f1 100644 --- a/sys/arch/hppa/include/cpu.h +++ b/sys/arch/hppa/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.97 2022/12/06 00:40:09 cheloha Exp $ */ +/* $OpenBSD: cpu.h,v 1.98 2023/01/01 19:49:17 miod Exp $ */ /* * Copyright (c) 2000-2004 Michael Shalayeff @@ -191,7 +191,6 @@ extern int cpu_hvers; */ #define HPPA_PGALIAS 0x00400000 -#define HPPA_PGAMASK 0xffc00000 #define HPPA_PGAOFF 0x003fffff #define HPPA_IOBEGIN 0xf0000000 diff --git a/sys/arch/hppa/include/pmap.h b/sys/arch/hppa/include/pmap.h index 3177608e3c0..cfcea8f9aad 100644 --- a/sys/arch/hppa/include/pmap.h +++ b/sys/arch/hppa/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.52 2022/10/25 18:44:36 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.53 2023/01/01 19:49:17 miod Exp $ */ /* * Copyright (c) 2002-2004 Michael Shalayeff @@ -91,16 +91,7 @@ struct vm_page *pmap_unmap_direct(vaddr_t); * according to the parisc manual aliased va's should be * different by high 12 bits only. */ -#define PMAP_PREFER(o,h) pmap_prefer(o, h) -static __inline__ vaddr_t -pmap_prefer(vaddr_t offs, vaddr_t hint) -{ - vaddr_t pmap_prefer_hint = (hint & HPPA_PGAMASK) | (offs & HPPA_PGAOFF); - if (pmap_prefer_hint < hint) - pmap_prefer_hint += HPPA_PGALIAS; - return pmap_prefer_hint; -} - +#define PMAP_PREFER /* pmap prefer alignment */ #define PMAP_PREFER_ALIGN() (HPPA_PGALIAS) /* pmap prefer offset within alignment */ diff --git a/sys/arch/mips64/include/pmap.h b/sys/arch/mips64/include/pmap.h index ea6cb7252e6..cef8fe7ec33 100644 --- a/sys/arch/mips64/include/pmap.h +++ b/sys/arch/mips64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.50 2022/09/10 20:35:28 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.51 2023/01/01 19:49:17 miod Exp $ */ /* * Copyright (c) 1987 Carnegie-Mellon University @@ -149,8 +149,7 @@ extern struct pmap *const kernel_pmap_ptr; #define PMAP_STEAL_MEMORY /* Enable 'stealing' during boot */ -#define PMAP_PREFER(pa, va) pmap_prefer(pa, va) - +#define PMAP_PREFER extern vaddr_t pmap_prefer_mask; /* pmap prefer alignment */ #define PMAP_PREFER_ALIGN() \ @@ -159,7 +158,6 @@ extern vaddr_t pmap_prefer_mask; #define PMAP_PREFER_OFFSET(of) ((of) & pmap_prefer_mask) void pmap_bootstrap(void); -vaddr_t pmap_prefer(vaddr_t, vaddr_t); int pmap_emulate_modify(pmap_t, vaddr_t); void pmap_page_cache(vm_page_t, u_int); diff --git a/sys/arch/mips64/mips64/pmap.c b/sys/arch/mips64/mips64/pmap.c index d50f8503858..99f45a21b26 100644 --- a/sys/arch/mips64/mips64/pmap.c +++ b/sys/arch/mips64/mips64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.121 2021/09/13 12:19:10 visa Exp $ */ +/* $OpenBSD: pmap.c,v 1.122 2023/01/01 19:49:17 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -1405,19 +1405,6 @@ pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) return found; } -/* - * Find first virtual address >= *vap that - * will not cause cache aliases. - */ -vaddr_t -pmap_prefer(paddr_t foff, vaddr_t va) -{ - if (pmap_prefer_mask != 0) - va += (foff - va) & pmap_prefer_mask; - - return va; -} - /* * Copy the range specified by src_addr/len * from the source map to the range dst_addr/len diff --git a/sys/arch/sh/include/pmap.h b/sys/arch/sh/include/pmap.h index 3314586c3a2..745ddc649cb 100644 --- a/sys/arch/sh/include/pmap.h +++ b/sys/arch/sh/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.16 2022/09/12 19:33:34 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.17 2023/01/01 19:49:17 miod Exp $ */ /* $NetBSD: pmap.h,v 1.28 2006/04/10 23:12:11 uwe Exp $ */ /*- @@ -75,12 +75,11 @@ pmap_remove_all(struct pmap *pmap) } /* - * pmap_prefer() helps to avoid virtual cache aliases on SH4 CPUs + * Avoid virtual cache aliases on SH4 CPUs * which have the virtually-indexed cache. */ #ifdef SH4 -#define PMAP_PREFER(pa, va) pmap_prefer((pa), (va)) -vaddr_t pmap_prefer(vaddr_t, vaddr_t); +#define PMAP_PREFER vaddr_t pmap_prefer_align(void); vaddr_t pmap_prefer_offset(vaddr_t); diff --git a/sys/arch/sh/sh/pmap.c b/sys/arch/sh/sh/pmap.c index fa55f6ccfd2..5785d8366f1 100644 --- a/sys/arch/sh/sh/pmap.c +++ b/sys/arch/sh/sh/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.29 2022/09/12 19:33:34 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.30 2023/01/01 19:49:17 miod Exp $ */ /* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */ /*- @@ -890,21 +890,6 @@ pmap_clear_modify(struct vm_page *pg) } #ifdef SH4 -/* - * pmap_prefer(vaddr_t foff, vaddr_t *vap) - * - * Find first virtual address >= *vap that doesn't cause - * a virtual cache alias against vaddr_t foff. - */ -vaddr_t -pmap_prefer(vaddr_t foff, vaddr_t va) -{ - if (SH_HAS_VIRTUAL_ALIAS) - va += ((foff - va) & sh_cache_prefer_mask); - - return va; -} - /* * pmap_prefer_align() * diff --git a/sys/arch/sparc64/include/pmap.h b/sys/arch/sparc64/include/pmap.h index 3941383f91c..1c9dac9d7b2 100644 --- a/sys/arch/sparc64/include/pmap.h +++ b/sys/arch/sparc64/include/pmap.h @@ -145,8 +145,8 @@ struct prom_map { #define PMAP_4M 0x018 #define PMAP_SZ_TO_TTE(x) (((x)&0x018)<<58) /* If these bits are different in va's to the same PA then there is an aliasing in the d$ */ -#define VA_ALIAS_MASK (1<<13) /* = (VA_ALIAS_ALIGN - 1) & ~PAGE_MASK */ #define VA_ALIAS_ALIGN (1<<14) +#define VA_ALIAS_MASK (VA_ALIAS_ALIGN - 1) typedef struct pmap *pmap_t; @@ -167,9 +167,9 @@ extern struct pmap kernel_pmap_; #define pmap_proc_iflush(p,va,len) /* nothing */ void pmap_bootstrap(u_long, u_long, u_int, u_int); -/* make sure all page mappings are modulo 16K to prevent d$ aliasing */ -#define PMAP_PREFER(pa, va) ((va) + (((va) ^ (pa)) & VA_ALIAS_MASK)) +/* make sure all page mappings are modulo 16K to prevent d$ aliasing */ +#define PMAP_PREFER /* pmap prefer alignment */ #define PMAP_PREFER_ALIGN() (VA_ALIAS_ALIGN) /* pmap prefer offset in alignment */ diff --git a/sys/uvm/uvm_pmap.h b/sys/uvm/uvm_pmap.h index 88bcc0d6fdc..8e31a5e0527 100644 --- a/sys/uvm/uvm_pmap.h +++ b/sys/uvm/uvm_pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pmap.h,v 1.31 2022/09/10 20:35:29 miod Exp $ */ +/* $OpenBSD: uvm_pmap.h,v 1.32 2023/01/01 19:49:18 miod Exp $ */ /* $NetBSD: uvm_pmap.h,v 1.1 2000/06/27 09:00:14 mrg Exp $ */ /* @@ -104,7 +104,6 @@ typedef struct pmap_statistics *pmap_statistics_t; #ifndef PMAP_PREFER #define PMAP_PREFER_ALIGN() 0 #define PMAP_PREFER_OFFSET(off) 0 -#define PMAP_PREFER(addr, off) (addr) #endif #ifdef _KERNEL -- 2.20.1