On Tue, Jul 15, 2025 at 10:52:35AM +0200, Kristof Provost wrote:
> On 15 Jul 2025, at 0:03, Konstantin Belousov wrote:
> > The branch main has been updated by kib:
> >
> > URL: 
> > https://cgit.FreeBSD.org/src/commit/?id=4dd828c80828637452a8a4e07a64e294c82e5d8b
> >
> > commit 4dd828c80828637452a8a4e07a64e294c82e5d8b
> > Author:     Konstantin Belousov <k...@freebsd.org>
> > AuthorDate: 2025-06-15 21:39:10 +0000
> > Commit:     Konstantin Belousov <k...@freebsd.org>
> > CommitDate: 2025-07-14 22:03:28 +0000
> >
> >     amd64: add kva_layout
> >
> >     Reviewed by:    markj
> >     Tested by:      pho
> >     Sponsored by:   The FreeBSD Foundation
> >     Differential revision:  https://reviews.freebsd.org/D51085
> > ---
> ..
> > diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h
> > index 0cd9bb4fa7a4..f12e5217a44b 100644
> > --- a/sys/amd64/include/vmparam.h
> > +++ b/sys/amd64/include/vmparam.h
> > @@ -181,12 +181,9 @@
> >   * 0xffffffff80000000                        KERNBASE
> >   */
> >
> > -#define    VM_MIN_KERNEL_ADDRESS   KV4ADDR(KPML4BASE, 0, 0, 0)
> > -#define    VM_MAX_KERNEL_ADDRESS   KV4ADDR(KPML4BASE + NKPML4E - 1, \
> > -                                   NPDPEPG-1, NPDEPG-1, NPTEPG-1)
> > -
> > -#define    DMAP_MIN_ADDRESS        KV4ADDR(DMPML4I, 0, 0, 0)
> > -#define    DMAP_MAX_ADDRESS        KV4ADDR(DMPML4I + NDMPML4E, 0, 0, 0)
> > +#define    VM_MIN_KERNEL_ADDRESS_LA48      KV4ADDR(KPML4BASE, 0, 0, 0)
> > +#define    VM_MIN_KERNEL_ADDRESS           kva_layout.km_low
> > +#define    VM_MAX_KERNEL_ADDRESS           kva_layout.km_high
> 
> The removal of DMAP_MIN_ADDRESS breaks the KASAN build.
> 
> This seems to fix it for me, but I’m not familiar enough with this code to be 
> confident to commit it:
> 
>       diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c
>       index 0edb631d1475..31204bad8c30 100644
>       --- a/sys/kern/subr_asan.c
>       +++ b/sys/kern/subr_asan.c
>       @@ -263,8 +263,8 @@ kasan_mark(const void *addr, size_t size, size_t 
> redzsize, uint8_t code)
>               if (__predict_false(!kasan_enabled))
>                       return;
> 
>       -       if ((vm_offset_t)addr >= DMAP_MIN_ADDRESS &&
>       -           (vm_offset_t)addr < DMAP_MAX_ADDRESS)
>       +       if ((vm_offset_t)addr >= kva_layout.dmap_low &&
>       +           (vm_offset_t)addr < kva_layout.dmap_high)
>                       return;

That restores the old behaviour, but it would break on arm64, which
doesn't have a kva_layout.

I pushed a different patch as commit 1f683624df878b2e4c0187137640bf2e6662c36f.
That way is also consistent with how unhandled addresses are handled in
KMSAN.

Reply via email to