Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Jul 2023 20:12:57 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 640e5cb30405 - main - kmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE
Message-ID:  <202307272012.36RKCvX3087672@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=640e5cb30405e98d3888b22bb040485e8bf3b446

commit 640e5cb30405e98d3888b22bb040485e8bf3b446
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-07-15 18:04:55 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-07-27 20:01:58 +0000

    kmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE
    
    Sponsored by:   The FreeBSD Foundation
---
 sys/amd64/include/msan.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/amd64/include/msan.h b/sys/amd64/include/msan.h
index 56460575ea7e..b62b3c243505 100644
--- a/sys/amd64/include/msan.h
+++ b/sys/amd64/include/msan.h
@@ -41,8 +41,9 @@
 typedef uint32_t msan_orig_t;
 
 /*
- * Our 32-bit origin cells encode a 2-bit type and 30-bit pointer.  The pointer
- * is compressed by making it a positive offset relative to KERNBASE.
+ * Our 32-bit origin cells encode a 2-bit type and 30-bit pointer to a kernel
+ * instruction.  The pointer is compressed by making it a positive offset
+ * relative to KERNBASE.
  */
 #define	KMSAN_ORIG_TYPE_SHIFT	30u
 #define	KMSAN_ORIG_PTR_MASK	((1u << KMSAN_ORIG_TYPE_SHIFT) - 1)
@@ -76,6 +77,12 @@ kmsan_md_addr_to_orig(vm_offset_t addr)
 static inline bool
 kmsan_md_unsupported(vm_offset_t addr)
 {
+	/*
+	 * The kernel itself isn't shadowed: for most purposes global variables
+	 * are always initialized, and because KMSAN kernels are large
+	 * (GENERIC-KMSAN is ~80MB at the time of writing), shadowing would
+	 * incur signficant memory usage.
+	 */
 	return (addr < VM_MIN_KERNEL_ADDRESS || addr >= KERNBASE);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307272012.36RKCvX3087672>