vm_fault_lookup: fault on nofault entry, while loading module cc_cubic with GENERIC-KASAN

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Tue, 05 Sep 2023 00:47:56 UTC
Hi,

Observed unexpected kernel panic while loading modules.

I have a test VM installed 13.2. I have `cc_cubic_load=YES` in
/boot/loader.conf to test cc_cubic. Recently I installed custom 
GENERIC-DEBUG kernel (current/15) to test some features and the
kernel panics during early boot.

To narrow down the root cause, I tested stable/14 (d6fec2dacf80)
with stock kernel config GENERIC-KASAN, it still panics. I can
reliably repeat the panic with `options KASAN`.

I'm not familiar with KASAN, so post here.

Steps to repeat:

On current/15 or stable/14 built with `options KASAN`.

# kldload cc_cubic
interface cubic.2 already present in the KLD 'kernel'!
panic: vm_fault_lookup: fault on nofault entry, addr: 0xfffffe0061b0f000
cpuid = 1
time = 1693873182
KDB: stack backtrace:
#0 0xffffffff813419b3 at kdb_backtrace+0x103
#1 0xffffffff81287ced at vpanic+0x1fd
#2 0xffffffff81287ae5 at panic+0xb5
#3 0xffffffff819b1db0 at vm_fault+0x2e80
#4 0xffffffff819aedff at vm_fault_trap+0xdf
#5 0xffffffff81c27c38 at trap_pfault+0x378
#6 0xffffffff81c2696b at trap+0x4db
#7 0xffffffff81be4c08 at calltrap+0x8
Uptime: 23s
Dumping 162 out of 951 MB:..10%..20%..30%..40%..50%..60%..70%..79%..89%..99%
Dump complete


Some informations that may help:
loaded modules:

root@:~ # kldstat 
Id Refs Address                Size Name
 1   11 0xffffffff80200000  34b4cd8 kernel
 2    1 0xffffffff83e19000     7208 intpm.ko
 3    1 0xffffffff83e21000     39a8 smbus.ko
 4    1 0xffffffff83e25000     cd10 vmci.ko
 5    1 0xffffffff83e32000     3428 mac_ntpd.ko


part of dmesg:

---<<BOOT>>---
Copyright (c) 1992-2023 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-ALPHA4 amd64 1400097 #0 stable/14-n265029-d6fec2dacf80: Mon Sep  4 16:32:22 CST 2023
    zlei@:/usr/obj/home/zlei/freebsd-src-stable14/amd64.amd64/sys/GENERIC-KASAN amd64
FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
VT(vga): text 80x25
CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz (2700.00-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x306d4  Family=0x6  Model=0x3d  Stepping=4
  Features=0xf83fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2,SS>
  Features2=0xfffa3203<SSE3,PCLMULQDQ,SSSE3,FMA,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND,HV>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x121<LAHF,ABM,Prefetch>
  Structured Extended Features=0x1c27ab<FSGSBASE,TSCADJ,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,NFPUSG,RDSEED,ADX,SMAP>
  Structured Extended Features3=0xbc000400<MD_CLEAR,IBPB,STIBP,L1DFL,ARCH_CAP,SSBD>
  XSAVE Features=0x1<XSAVEOPT>
  IA32_ARCH_CAPS=0xc<RSBA,SKIP_L1DFL_VME>
  TSC: P-state invariant
Hypervisor: Origin = "VMwareVMware"
real memory  = 1073741824 (1024 MB)
avail memory = 801873920 (764 MB)



Best regards,
Zhenlei