Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern vmem(9): Assert addresses are quantum-aligned.
details: https://anonhg.NetBSD.org/src/rev/c836a65972f1
branches: trunk
changeset: 362445:c836a65972f1
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Feb 27 14:24:11 2022 +0000
description:
vmem(9): Assert addresses are quantum-aligned.
diffstat:
sys/kern/subr_vmem.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diffs (67 lines):
diff -r 7e4e21413f3b -r c836a65972f1 sys/kern/subr_vmem.c
--- a/sys/kern/subr_vmem.c Sun Feb 27 14:23:24 2022 +0000
+++ b/sys/kern/subr_vmem.c Sun Feb 27 14:24:11 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_vmem.c,v 1.106 2021/08/17 22:00:32 andvar Exp $ */
+/* $NetBSD: subr_vmem.c,v 1.107 2022/02/27 14:24:11 riastradh Exp $ */
/*-
* Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.106 2021/08/17 22:00:32 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.107 2022/02/27 14:24:11 riastradh Exp $");
#if defined(_KERNEL) && defined(_KERNEL_OPT)
#include "opt_ddb.h"
@@ -1095,6 +1095,10 @@
error = vmem_xalloc(vm, size, 0, 0, 0, VMEM_ADDR_MIN, VMEM_ADDR_MAX,
flags, addrp);
out:
+ KASSERTMSG(error || addrp == NULL ||
+ (*addrp & vm->vm_quantum_mask) == 0,
+ "vmem %s mask=0x%jx addr=0x%jx",
+ vm->vm_name, (uintmax_t)vm->vm_quantum_mask, (uintmax_t)*addrp);
KASSERT(error == 0 || (flags & VM_SLEEP) == 0);
return error;
}
@@ -1285,6 +1289,10 @@
if (addrp != NULL)
*addrp = btnew->bt_start;
VMEM_UNLOCK(vm);
+ KASSERTMSG(addrp == NULL ||
+ (*addrp & vm->vm_quantum_mask) == 0,
+ "vmem %s mask=0x%jx addr=0x%jx",
+ vm->vm_name, (uintmax_t)vm->vm_quantum_mask, (uintmax_t)*addrp);
return 0;
}
@@ -1297,6 +1305,9 @@
{
KASSERT(size > 0);
+ KASSERTMSG((addr & vm->vm_quantum_mask) == 0,
+ "vmem %s mask=0x%jx addr=0x%jx",
+ vm->vm_name, (uintmax_t)vm->vm_quantum_mask, (uintmax_t)addr);
#if defined(QCACHE)
if (size <= vm->vm_qcache_max) {
@@ -1317,11 +1328,15 @@
bt_t *bt;
KASSERT(size > 0);
+ KASSERTMSG((addr & vm->vm_quantum_mask) == 0,
+ "vmem %s mask=0x%jx addr=0x%jx",
+ vm->vm_name, (uintmax_t)vm->vm_quantum_mask, (uintmax_t)addr);
VMEM_LOCK(vm);
bt = bt_lookupbusy(vm, addr);
- KASSERT(bt != NULL);
+ KASSERTMSG(bt != NULL, "vmem %s addr 0x%jx size 0x%jx",
+ vm->vm_name, (uintmax_t)addr, (uintmax_t)size);
KASSERT(bt->bt_start == addr);
KASSERT(bt->bt_size == vmem_roundup_size(vm, size) ||
bt->bt_size - vmem_roundup_size(vm, size) <= vm->vm_quantum_mask);
Home |
Main Index |
Thread Index |
Old Index