Bug 230318

Summary: options EFIRT: immediate crash of CURRENT with aio boot(clover EFI + rEFInd)
Product: Base System Reporter: Masachika ISHIZUKA <ish>
Component: kernAssignee: Kyle Evans <kevans>
Status: Closed FIXED    
Severity: Affects Only Me CC: ish
Priority: --- Keywords: crash, regression
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Masachika ISHIZUKA 2018-08-03 05:44:26 UTC
I'm using aio boot that can UEFI boot on legacy bios machine (DELL studio 1558).
I can UEFI boot with aio boot(clover EFI bootloader + rEFInd) until r336919.
But I can not UEFI boot with aio boot after r336921 on GENERIC kernel.
On r336921 and after, it loaded kernel and soon automatic rebooted as follows.

==== r336921 (automatic rebooted)
Copyright (c) 1992-2018 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 12.0-CURRENT #8 r336921: Fri Aug  3 12:39:09 JST 2018
    ishizuka@cucumber.ish.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
WARNING: WITNESS option enabled, expect reduced performance.
VT(efifb): resolution 1024x768
info: [drm] Initialized drm 1.1.0 20060810
CPU: Intel(R) Core(TM) i7 CPU       Q 840  @ 1.87GHz (1862.04-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x106e5  Family=0x6  Model=0x1e  Stepping=5
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x98e3fd<SSE3,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT>
  AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,VPID
  TSC: P-state invariant, performance statistics
real memory  = 4294967296 (4096 MB)
avail memory = 4003057664 (3817 MB)
Event timer "LAPIC" quality 100
ACPI APIC Table: <PTLTD          APIC  >
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 hardware threads
random: unblocking device.
ioapic0 <Version 2.0> irqs 0-23 on motherboard
Launching APs: 1 3 4 6 2 5 
(automatic rebooted)

==== r336919 (good worked)
Copyright (c) 1992-2018 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 12.0-CURRENT #7 r336919: Fri Aug  3 12:09:03 JST 2018
    ishizuka@cucumber.ish.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
WARNING: WITNESS option enabled, expect reduced performance.
VT(efifb): resolution 1024x768
info: [drm] Initialized drm 1.1.0 20060810
CPU: Intel(R) Core(TM) i7 CPU       Q 840  @ 1.87GHz (1862.04-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x106e5  Family=0x6  Model=0x1e  Stepping=5
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x98e3fd<SSE3,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT>
  AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,VPID
  TSC: P-state invariant, performance statistics
real memory  = 4294967296 (4096 MB)
avail memory = 4003057664 (3817 MB)
Event timer "LAPIC" quality 100
ACPI APIC Table: <PTLTD          APIC  >
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 hardware threads
random: unblocking device.
ioapic0 <Version 2.0> irqs 0-23 on motherboard
Launching APs: 1 6 3 5 2 4 7
Timecounter "TSC" frequency 1862042047 Hz quality 1000
random: entropy device external interface
[ath_hal] loaded
module_register_init: MOD_LOAD (vesa, 0xffffffff810fb020, 0) error 19
kbd1 at kbdmux0
netmap: loaded module
nexus0
cryptosoft0: <software crypto> on motherboard
acpi0: <DELL QA09   > on motherboard
acpi0: Power Button (fixed)
cpu0: <ACPI CPU> on acpi0
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff irq 0,8 on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 950
Event timer "HPET" frequency 14318180 Hz quality 550
atrtc0: <AT realtime clock> port 0x70-0x77 on acpi0
atrtc0: Warning: Couldn't map I/O.
atrtc0: registered as a time-of-day clock, resolution 1.000000s
Event timer "RTC" frequency 32768 Hz quality 0
attimer0: <AT timer> port 0x40-0x43,0x50-0x53 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
acpi_ec0: <Embedded Controller: GPE 0x16> port 0x62,0x66 on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pcib1: <ACPI PCI-PCI bridge> irq 16 at device 3.0 on pci0
pci1: <ACPI PCI bus> on pcib1
vgapci0: <VGA-compatible display> port 0x2000-0x20ff mem 0xd0000000-0xdfffffff,0xcfee0000-0xcfefffff irq 16 at device 0.0 on pci1
drmn0: <Manhattan [Mobility Radeon HD 5400 Series]> on vgapci0
info: [drm] RADEON_IS_PCIE
info: [drm] initializing kernel modesetting (CEDAR 0x1002:0x68E0 0x1028:0x0413).
info: [drm] register mmio base: 0xCFEE0000
info: [drm] register mmio size: 131072
info: [drm] radeon_atrm_get_bios: ===> Try ATRM...
...[snip]...
Comment 1 Masachika ISHIZUKA 2018-08-03 23:59:19 UTC
(In reply to Masachika ISHIZUKA from comment #0)

I can boot with aio boot if comment out the 'options EFIRT'.
I tested on r337230.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2018-08-04 04:13:34 UTC
Over to committer of r336921.
Comment 3 Kyle Evans freebsd_committer freebsd_triage 2018-08-04 04:37:14 UTC
(In reply to Masachika ISHIZUKA from comment #1)

Hi,

With EFIRT removed (or efi.rt.disabled=1 set in loader.conf(5)), can you try a `kldload efirt` when you hit userland and see if that gives you any meaningful output/panic?
Comment 4 Masachika ISHIZUKA 2018-08-04 14:38:01 UTC
(In reply to Kyle Evans from comment #3)

Thank you for reply.
I'm using kernel without 'options EFIRT'.  'kldload efirt' works fine.
# uname -a
FreeBSD cucumber.ish.org 12.0-CURRENT FreeBSD 12.0-CURRENT #1 r337230: Fri Aug  3 20:46:38 JST 2018     root@cucumber.ish.org:/usr/obj/usr/src/amd64.amd64/sys/cucumber  amd64
cucumber# kldload efirt
cucumber# kldstat
Id Refs Address                Size Name
 1   64 0xffffffff80200000  24bb338 kernel
 2    1 0xffffffff826bd000    a6d18 iwn6000g2bfw.ko
 3    1 0xffffffff82764000   1a0518 radeonkms.ko
 4    2 0xffffffff82905000     4c98 iicbb.ko
 5    5 0xffffffff8290a000     6bb0 iicbus.ko
 6    2 0xffffffff82911000     37e0 iic.ko
 7    2 0xffffffff82915000    75f80 drm2.ko
 8    1 0xffffffff82d11000     b308 tmpfs.ko
 9    1 0xffffffff82d1d000     4850 linprocfs.ko
10    3 0xffffffff82d22000     32c8 linux_common.ko
11    1 0xffffffff82d26000     a200 if_lagg.ko
12    1 0xffffffff82d31000     2388 ums.ko
13    1 0xffffffff82d34000     1780 uhid.ko
14    1 0xffffffff82d36000    25a78 ipfw.ko
15    1 0xffffffff82d5c000    38d08 linux.ko
16    1 0xffffffff82d95000    33508 linux64.ko
17    1 0xffffffff82dc9000     4670 autofs.ko
18    1 0xffffffff82dce000      acf mac_ntpd.ko
19    1 0xffffffff82dcf000     2598 efirt.ko
cucumber# grep -i efirt /var/log/messages
Aug  4 23:27:00 cucumber kernel: efirtc0: <EFI Realtime Clock> on motherboard
Aug  4 23:27:00 cucumber kernel: efirtc0: registered as a time-of-day clock, resolution 1.000000s
cucumber# efibootmgr -v
BootCurrent: 0000
BootOrder  : 0000
+Boot0000* EFI Hard Drive PcieRoot(0x0)/Pci(0x1f,0x2)/Ata(Primary,Master,0x0)


Unreferenced Variables:
cucumber#
Comment 5 Masachika ISHIZUKA 2018-08-04 15:34:31 UTC
(In reply to Kyle Evans from comment #3)

I copied GENERIC kernel from another machine and set efi.rt.disabled=1 in /boot/loader.conf, it started up normally.
I want to use GENERIC kernel for upcoming 12.0-RELEASE because I want to use freebsd-update, so this workaround is very happy.
Thank you.
Comment 6 Kyle Evans freebsd_committer freebsd_triage 2018-08-04 16:37:44 UTC
(In reply to Masachika ISHIZUKA from comment #5)

Hi,

Ok, good. =) Can you try applying the patch at [1] and running that with options EFIRT and efi.rt.disabled=0 or unset? You might be running into the same problem reported by eadler on current@, but manifesting in a different way.

If it boots, can you also please confirm that `efivar -l` still works?

Thanks,

Kyle Evans

[1] https://reviews.freebsd.org/D16591
Comment 7 Kyle Evans freebsd_committer freebsd_triage 2018-08-04 21:42:29 UTC
(In reply to Kyle Evans from comment #6)

Now committed as r337331; please do let me know if >= r337331 works as-is for you with efi.rt.disabled=0.
Comment 8 Masachika ISHIZUKA 2018-08-04 22:24:51 UTC
(In reply to Kyle Evans from comment #7)

On my machine, it still panics without 'efi.rt.disabled' in loader.conf.
I can boot GENERIC kernel r337331 with 'efi.rt.disabled=1'
Comment 9 Kyle Evans freebsd_committer freebsd_triage 2018-08-04 22:43:25 UTC
(In reply to Masachika ISHIZUKA from comment #8)

For reference, when you boot GENERIC with UEFI and efirt disabled, what does `sysctl machdep.efi_map` output?
Comment 10 Masachika ISHIZUKA 2018-08-05 00:31:51 UTC
(In reply to Kyle Evans from comment #9)

cucumber# uname -a
FreeBSD cucumber.ish.org 12.0-CURRENT FreeBSD 12.0-CURRENT #10 r337331: Sun Aug  5 07:11:09 JST 2018     root@cucumber.ish.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
cucumber# sysctl machdep.efi_map
machdep.efi_map: 
                   Type     Physical      Virtual   #Pages Attr
     ConventionalMemory 000000018000          0x0 0000006c UC WC WT WB 
       BootServicesData 000000084000          0x0 00000010 UC WC WT WB 
          ACPIMemoryNVS 000000094000          0x0 00000004 UC WC WT WB 
       BootServicesData 000000098000          0x0 00000001 UC WC WT WB 
          ACPIMemoryNVS 000000099000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000000100000          0x0 0003befc UC WC WT WB 
             LoaderData 00003bffc000          0x0 00004004 UC WC WT WB 
     ConventionalMemory 000040000000          0x0 00075014 UC WC WT WB 
             LoaderData 0000b5014000          0x0 00004000 UC WC WT WB 
             LoaderCode 0000b9014000          0x0 0000007a UC WC WT WB 
     ConventionalMemory 0000b908e000          0x0 00000073 UC WC WT WB 
       BootServicesData 0000b9101000          0x0 0000006a UC WC WT WB 
     ConventionalMemory 0000b916b000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000b916c000          0x0 00000a4a UC WC WT WB 
     ConventionalMemory 0000b9bb6000          0x0 00000005 UC WC WT WB 
       BootServicesData 0000b9bbb000          0x0 00001208 UC WC WT WB 
     ConventionalMemory 0000badc3000          0x0 000000ff UC WC WT WB 
             LoaderData 0000baec2000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000baec3000          0x0 0000000c UC WC WT WB 
             LoaderCode 0000baecf000          0x0 000000f4 UC WC WT WB 
       BootServicesData 0000bafc3000          0x0 00000200 UC WC WT WB 
     ConventionalMemory 0000bb1c3000          0x0 000000c6 UC WC WT WB 
       BootServicesCode 0000bb289000          0x0 0000013a UC WC WT WB 
    RuntimeServicesCode 0000bb3c3000   0xbb3c3000 00000100 UC WC WT WB RUNTIME
    RuntimeServicesData 0000bb4c3000   0xbb4c3000 00000100 UC WC WT WB RUNTIME
     ConventionalMemory 0000bb5c3000          0x0 00000101 UC WC WT WB 
          ACPIMemoryNVS 0000bb6c4000          0x0 00000003 UC WC WT WB 
      ACPIReclaimMemory 0000bb6c7000          0x0 00000080 UC WC WT WB 
       BootServicesData 0000bb747000          0x0 00000065 UC WC WT WB 
               Reserved 0000bba7c000          0x0 00000006 UC 
     ConventionalMemory 0000bba82000          0x0 00000163 WB 
               Reserved 0000bbbe5000          0x0 0000002a UC 
     ConventionalMemory 0000bbc0f000          0x0 00000060 WB 
               Reserved 0000bbc6f000          0x0 00000001 UC 
          ACPIMemoryNVS 0000bbc70000          0x0 00000081 UC 
               Reserved 0000bbcf1000          0x0 0000021e UC 
     ConventionalMemory 0000bbf0f000          0x0 00000009 WB 
               Reserved 0000bbf18000          0x0 00000007 UC 
     ConventionalMemory 0000bbf1f000          0x0 00000062 WB 
          ACPIMemoryNVS 0000bbf81000          0x0 0000001e UC 
     ConventionalMemory 0000bbf9f000          0x0 0000002a WB 
       BootServicesData 0000bbfc9000          0x0 00000001 WB 
       BootServicesCode 0000bbfca000          0x0 00000018 WB 
      ACPIReclaimMemory 0000bbfe2000          0x0 0000001d WB 
               Reserved 0000bc000000          0x0 00002000 UC 
               Reserved 0000bf800000          0x0 00000800 UC 
               Reserved 0000e0000000          0x0 00010000 UC 
               Reserved 0000f0b04000          0x0 00000001 UC 
               Reserved 0000feaff000          0x0 00000001 UC 
               Reserved 0000fec00000          0x0 00000010 UC 
               Reserved 0000fed00000          0x0 00000001 UC 
               Reserved 0000fed1c000          0x0 00000074 UC 
               Reserved 0000fee00000          0x0 00000001 UC 
               Reserved 0000ff000000          0x0 00001000 UC 
     ConventionalMemory 000100000000          0x0 00040000 WB 
cucumber#
Comment 11 Kyle Evans freebsd_committer freebsd_triage 2018-08-07 19:36:47 UTC
(In reply to Masachika ISHIZUKA from comment #10)

Hi,

FYI- I'm trying to put together a Clover disk to try and reproduce this locally for further debugging. Thank you again for the information. =)
Comment 12 Kyle Evans freebsd_committer freebsd_triage 2018-08-08 00:55:40 UTC
Hi,

While I'm figuring out a setup for testing this- could you give this patch a shot? https://reviews.freebsd.org/D16618

It fixes a problem reported by others with machines w/o PCID panicking upon entering EFI context in early boot- if no PCID is the case here, we should rule this out before we can proceed.
Comment 13 Masachika ISHIZUKA 2018-08-08 06:28:21 UTC
(In reply to Kyle Evans from comment #12)

Thank you very much.
It can boot normally with D16618 on r337409.
Comment 14 Kyle Evans freebsd_committer freebsd_triage 2018-08-08 12:43:57 UTC
(In reply to Masachika ISHIZUKA from comment #13)

Ah, good to hear. Thanks! =)
Comment 15 Kyle Evans freebsd_committer freebsd_triage 2018-08-14 16:38:07 UTC
Fix for this has been committed in r337773.
Comment 16 Masachika ISHIZUKA 2018-08-16 10:34:53 UTC
(In reply to Kyle Evans from comment #15)

Thank you for fixing.
It is good working on r337885 GENERIC kernel without efi.rt.disabled=1.