Exclude the PTE space from KCSAN, since there the same VA can point to

different PAs.
This commit is contained in:
maxv 2019-11-08 12:36:10 +00:00
parent abf664cfda
commit b081609ec2
2 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: csan.h,v 1.2 2019/11/06 06:57:22 maxv Exp $ */
/* $NetBSD: csan.h,v 1.3 2019/11/08 12:36:11 maxv Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@ -30,8 +30,17 @@
*/
#include <sys/ksyms.h>
#include <uvm/uvm.h>
#include <amd64/pmap.h>
#include <x86/cpufunc.h>
static inline bool
kcsan_md_unsupported(vaddr_t addr)
{
return (addr >= (vaddr_t)PTE_BASE &&
addr < ((vaddr_t)PTE_BASE + NBPD_L4));
}
static inline bool
kcsan_md_is_avail(void)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_csan.c,v 1.2 2019/11/06 06:57:22 maxv Exp $ */
/* $NetBSD: subr_csan.c,v 1.3 2019/11/08 12:36:10 maxv Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_csan.c,v 1.2 2019/11/06 06:57:22 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_csan.c,v 1.3 2019/11/08 12:36:10 maxv Exp $");
#include "opt_kcsan.h"
@ -136,6 +136,8 @@ kcsan_access(uintptr_t addr, size_t size, bool write, bool atomic, uintptr_t pc)
if (__predict_false(!kcsan_enabled))
return;
if (__predict_false(kcsan_md_unsupported((vaddr_t)addr)))
return;
new.addr = addr;
new.size = size;