From c41df0aeb584cf617dc636049d193c4f8858686f Mon Sep 17 00:00:00 2001 From: skrll Date: Thu, 18 Apr 2024 12:16:23 +0000 Subject: [PATCH] Fix types in pmap_page_clear_attributes so that the top bits of the u_long mdpg_attrs aren't dropped giving atomic_cas_ulong no chance of completing if any of the top bits is set. Update pmap_page_set_attributes for consistency. An ATF test run completed for me with this fix. port-riscv/58006: ATF tests no longer complete on riscv-riscv64 --- sys/uvm/pmap/pmap.c | 16 ++++++++-------- sys/uvm/pmap/pmap.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/uvm/pmap/pmap.c b/sys/uvm/pmap/pmap.c index d28b7521abb2..ca130968dff9 100644 --- a/sys/uvm/pmap/pmap.c +++ b/sys/uvm/pmap/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.77 2024/03/23 08:31:15 skrll Exp $ */ +/* $NetBSD: pmap.c,v 1.78 2024/04/18 12:16:23 skrll Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77 2024/03/23 08:31:15 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.78 2024/04/18 12:16:23 skrll Exp $"); /* * Manages physical address maps. @@ -415,21 +415,21 @@ pmap_addr_range_check(pmap_t pmap, vaddr_t sva, vaddr_t eva, const char *func) */ bool -pmap_page_clear_attributes(struct vm_page_md *mdpg, u_int clear_attributes) +pmap_page_clear_attributes(struct vm_page_md *mdpg, u_long clear_attributes) { - volatile unsigned long * const attrp = &mdpg->mdpg_attrs; + volatile u_long * const attrp = &mdpg->mdpg_attrs; #ifdef MULTIPROCESSOR for (;;) { - u_int old_attr = *attrp; + u_long old_attr = *attrp; if ((old_attr & clear_attributes) == 0) return false; - u_int new_attr = old_attr & ~clear_attributes; + u_long new_attr = old_attr & ~clear_attributes; if (old_attr == atomic_cas_ulong(attrp, old_attr, new_attr)) return true; } #else - unsigned long old_attr = *attrp; + u_long old_attr = *attrp; if ((old_attr & clear_attributes) == 0) return false; *attrp &= ~clear_attributes; @@ -438,7 +438,7 @@ pmap_page_clear_attributes(struct vm_page_md *mdpg, u_int clear_attributes) } void -pmap_page_set_attributes(struct vm_page_md *mdpg, u_int set_attributes) +pmap_page_set_attributes(struct vm_page_md *mdpg, u_long set_attributes) { #ifdef MULTIPROCESSOR atomic_or_ulong(&mdpg->mdpg_attrs, set_attributes); diff --git a/sys/uvm/pmap/pmap.h b/sys/uvm/pmap/pmap.h index 8a9877e5a318..0672afd87d07 100644 --- a/sys/uvm/pmap/pmap.h +++ b/sys/uvm/pmap/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.26 2022/11/03 18:55:07 skrll Exp $ */ +/* $NetBSD: pmap.h,v 1.27 2024/04/18 12:16:23 skrll Exp $ */ /* * Copyright (c) 1992, 1993 @@ -296,8 +296,8 @@ extern pmap_segtab_t pmap_kern_segtab; bool pmap_remove_all(pmap_t); void pmap_set_modified(paddr_t); -bool pmap_page_clear_attributes(struct vm_page_md *, u_int); -void pmap_page_set_attributes(struct vm_page_md *, u_int); +bool pmap_page_clear_attributes(struct vm_page_md *, u_long); +void pmap_page_set_attributes(struct vm_page_md *, u_long); void pmap_pvlist_lock_init(size_t); #ifdef PMAP_VIRTUAL_CACHE_ALIASES void pmap_page_cache(struct vm_page_md *, bool);