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
This commit is contained in:
skrll 2024-04-18 12:16:23 +00:00
parent 9626b6b63f
commit c41df0aeb5
2 changed files with 11 additions and 11 deletions

View File

@ -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. * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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. * 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 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 #ifdef MULTIPROCESSOR
for (;;) { for (;;) {
u_int old_attr = *attrp; u_long old_attr = *attrp;
if ((old_attr & clear_attributes) == 0) if ((old_attr & clear_attributes) == 0)
return false; 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)) if (old_attr == atomic_cas_ulong(attrp, old_attr, new_attr))
return true; return true;
} }
#else #else
unsigned long old_attr = *attrp; u_long old_attr = *attrp;
if ((old_attr & clear_attributes) == 0) if ((old_attr & clear_attributes) == 0)
return false; return false;
*attrp &= ~clear_attributes; *attrp &= ~clear_attributes;
@ -438,7 +438,7 @@ pmap_page_clear_attributes(struct vm_page_md *mdpg, u_int clear_attributes)
} }
void 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 #ifdef MULTIPROCESSOR
atomic_or_ulong(&mdpg->mdpg_attrs, set_attributes); atomic_or_ulong(&mdpg->mdpg_attrs, set_attributes);

View File

@ -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 * Copyright (c) 1992, 1993
@ -296,8 +296,8 @@ extern pmap_segtab_t pmap_kern_segtab;
bool pmap_remove_all(pmap_t); bool pmap_remove_all(pmap_t);
void pmap_set_modified(paddr_t); void pmap_set_modified(paddr_t);
bool pmap_page_clear_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_int); void pmap_page_set_attributes(struct vm_page_md *, u_long);
void pmap_pvlist_lock_init(size_t); void pmap_pvlist_lock_init(size_t);
#ifdef PMAP_VIRTUAL_CACHE_ALIASES #ifdef PMAP_VIRTUAL_CACHE_ALIASES
void pmap_page_cache(struct vm_page_md *, bool); void pmap_page_cache(struct vm_page_md *, bool);