Module Name:    src
Committed By:   ad
Date:           Sun Sep 10 14:29:13 UTC 2023

Modified Files:
        src/sys/kern: subr_kmem.c

Log Message:
Assert that kmem_alloc() provides the expected alignment.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/kern/subr_kmem.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/kern/subr_kmem.c
diff -u src/sys/kern/subr_kmem.c:1.88 src/sys/kern/subr_kmem.c:1.89
--- src/sys/kern/subr_kmem.c:1.88	Sun Apr  9 08:50:20 2023
+++ src/sys/kern/subr_kmem.c	Sun Sep 10 14:29:13 2023
@@ -1,7 +1,7 @@
-/*	$NetBSD: subr_kmem.c,v 1.88 2023/04/09 08:50:20 riastradh Exp $	*/
+/*	$NetBSD: subr_kmem.c,v 1.89 2023/09/10 14:29:13 ad Exp $	*/
 
 /*
- * Copyright (c) 2009-2020 The NetBSD Foundation, Inc.
+ * Copyright (c) 2009-2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.88 2023/04/09 08:50:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.89 2023/09/10 14:29:13 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kmem.h"
@@ -325,6 +325,8 @@ kmem_intr_alloc(size_t requested_size, k
 			return NULL;
 		}
 		FREECHECK_OUT(&kmem_freecheck, p);
+		KASSERT(size < coherency_unit ||
+		    ALIGNED_POINTER(p, coherency_unit));
 		return p;
 	}
 
@@ -334,6 +336,8 @@ kmem_intr_alloc(size_t requested_size, k
 		kasan_mark(p, origsize, size, KASAN_KMEM_REDZONE);
 		return p;
 	}
+
+	KASSERT(size < coherency_unit || ALIGNED_POINTER(p, coherency_unit));
 	return p;
 }
 

Reply via email to