From nobody Thu Sep 05 00:37:49 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WzgSS0zkjz5W7CZ; Thu, 05 Sep 2024 00:38:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4WzgSR5sRfz4LnQ; Thu, 5 Sep 2024 00:37:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 4850bnSj032440; Thu, 5 Sep 2024 03:37:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 4850bnSj032440 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 4850bnTr032439; Thu, 5 Sep 2024 03:37:49 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 5 Sep 2024 03:37:49 +0300 From: Konstantin Belousov To: Cy Schubert Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 65b133e5d292 - main - x86: allow to have more than one kind of IOMMU Message-ID: References: <202409042150.484LoeAq031493@gitrepo.freebsd.org> <20240904235204.1FCD9C5@slippy.cwsent.com> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240904235204.1FCD9C5@slippy.cwsent.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4WzgSR5sRfz4LnQ On Wed, Sep 04, 2024 at 04:52:04PM -0700, Cy Schubert wrote: > I suspect this commit but could be one of the others that caused this panic > during intialization. From a serial console log: > > Hit [Enter] to boot immediately, or any other key for command prompt. > Booting [/boot/kernel/kernel] in 10 seconds... ^MBooting > [/boot/kernel/kernel] in 9 seconds... ^MBooting [/boot/kernel/kernel]... > ^M > \^HGDB: no debug ports present > KDB: debugger backends: ddb > KDB: current backend: ddb > ---<>--- > Copyright (c) 1992-2024 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 15.0-CURRENT #60 komquats-n272059-e28ee29d2d13: Wed Sep 4 15:07:36 > PDT 2024 > root@cwsys:/export/obj/opt/src/git-src/amd64.amd64/sys/BREAK amd64 > FreeBSD clang version 18.1.6 (https://github.com/llvm/llvm-project.git > llvmorg-18.1.6-0-g1118c2e05e67) > VT(vga): text 80x25 > CPU: AMD Processor model unknown (3000.06-MHz K8-class CPU) > Origin="AuthenticAMD" Id=0x100f43 Family=0x10 Model=0x4 Stepping=3 > Features=0x178bfbff CA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT> > Features2=0x802009 > AMD Features=0xee500800 Now!> > AMD Features2=0x37ff IBS,SKINIT,WDT> > SVM: NP,NRIP,NAsids=64 > TSC: P-state invariant > real memory = 8589934592 (8192 MB) > avail memory = 8145883136 (7768 MB) > Event timer "LAPIC" quality 100 > ACPI APIC Table: > FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs > FreeBSD/SMP: 1 package(s) x 4 core(s) > random: unblocking device. > Firmware Warning (ACPI): 32/64X length mismatch in FADT/Pm1aEventBlock: > 32/8 (20230628/tbfadt-748) > Firmware Warning (ACPI): 32/64X length mismatch in FADT/Pm1aControlBlock: > 16/8 (20230628/tbfadt-748) > Firmware Warning (ACPI): 32/64X length mismatch in FADT/PmTimerBlock: 32/8 > (20230628/tbfadt-748) > Firmware Warning (ACPI): 32/64X length mismatch in FADT/Gpe0Block: 64/8 > (20230628/tbfadt-748) > Firmware Warning (ACPI): Invalid length for FADT/Pm1aEventBlock: 8, using > default 32 (20230628/tbfadt-850) > Firmware Warning (ACPI): Invalid length for FADT/Pm1aControlBlock: 8, using > default 16 (20230628/tbfadt-850) > Firmware Warning (ACPI): Invalid length for FADT/PmTimerBlock: 8, using > default 32 (20230628/tbfadt-850) > ioapic0: MADT APIC ID 4 != hw id 0 > kernel trap 12 with interrupts disabled > > > Fatal trap 12: page fault while in kernel mode > cpuid = 0; apic id = 00 > fault virtual address = 0x78 > fault code = supervisor read data, page not present > instruction pointer = 0x20:0xffffffff80a2c48b > stack pointer = 0x28:0xffffffff81f05e90 > frame pointer = 0x28:0xffffffff81f05e90 > code segment = base 0x0, limit 0xfffff, type 0x1b > = DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags = resume, IOPL = 0 > current process = 0 (swapper) > rdi: 0000000000000004 rsi: 0000000000000000 rdx: 0000000000000000 > rcx: 0000000000000001 r8: 0000000000000001 r9: 00000000ffffffff > rax: 0000000000000000 rbx: fffff800fec00000 rbp: ffffffff81f05e90 > r10: 0000000000000000 r11: 00000000fff5cfdf r12: 0000000000000010 > r13: fffff800033aa8ec r14: fffff800033aa8e4 r15: 0000000000000000 > trap number = 12 > panic: page fault > cpuid = 0 > time = 1 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame > 0xffffffff81f05b80 > vpanic() at vpanic+0x13f/frame 0xffffffff81f05cb0 > panic() at panic+0x43/frame 0xffffffff81f05d10 > trap_fatal() at trap_fatal+0x40b/frame 0xffffffff81f05d70 > trap_pfault() at trap_pfault+0x46/frame 0xffffffff81f05dc0 > calltrap() at calltrap+0x8/frame 0xffffffff81f05dc0 > --- trap 0xc, rip = 0xffffffff80a2c48b, rsp = 0xffffffff81f05e90, rbp = > 0xffffffff81f05e90 --- > iommu_map_ioapic_intr() at iommu_map_ioapic_intr+0xb/frame > 0xffffffff81f05e90 > ioapic_create() at ioapic_create+0x460/frame 0xffffffff81f05f20 > madt_parse_apics() at madt_parse_apics+0x51/frame 0xffffffff81f05f40 > acpi_walk_subtables() at acpi_walk_subtables+0x31/frame 0xffffffff81f05f70 > madt_setup_io() at madt_setup_io+0x62/frame 0xffffffff81f05f90 > apic_setup_io() at apic_setup_io+0x24/frame 0xffffffff81f05fa0 > mi_startup() at mi_startup+0x1c8/frame 0xffffffff81f05ff0 > Uptime: 1s > Automatic reboot in 15 seconds - press a key on the console to abort > --> Press a key on the console to reboot, > --> or switch off the system now. > Rebooting... Try this commit 27647f0593a0e7c1cdacb8531dd944aa568dbdb5 Author: Konstantin Belousov Date: Thu Sep 5 03:33:34 2024 +0300 x86: always provide dummy x86_iommu virtual methods to make configurations where vendor-specific IOMMU not yet implemented but IOMMU is enabled in config, work when calling into MSI/IOAPIC interrupt remapping. Reported by: cy Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index 2c647fd21c67..ebfcb94c7e97 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -190,12 +190,53 @@ SYSCTL_INT(_hw_iommu, OID_AUTO, batch_coalesce, CTLFLAG_RWTUN, &iommu_qi_batch_coalesce, 0, "Number of qi batches between interrupt"); -static struct x86_iommu *x86_iommu; +static int +x86_no_iommu_alloc_msi_intr(device_t src, u_int *cookies, u_int count) +{ + return (EOPNOTSUPP); +} + +static int +x86_no_iommu_map_msi_intr(device_t src, u_int cpu, u_int vector, + u_int cookie, uint64_t *addr, uint32_t *data) +{ + return (EOPNOTSUPP); +} + +static int +x86_no_iommu_unmap_msi_intr(device_t src, u_int cookie) +{ + return (0); +} + +static int +x86_no_iommu_map_ioapic_intr(u_int ioapic_id, u_int cpu, u_int vector, + bool edge, bool activehi, int irq, u_int *cookie, uint32_t *hi, + uint32_t *lo) +{ + return (EOPNOTSUPP); +} + +static int +x86_no_iommu_unmap_ioapic_intr(u_int ioapic_id, u_int *cookie) +{ + return (0); +} + +static struct x86_iommu x86_no_iommu = { + .alloc_msi_intr = x86_no_iommu_alloc_msi_intr, + .map_msi_intr = x86_no_iommu_map_msi_intr, + .unmap_msi_intr = x86_no_iommu_unmap_msi_intr, + .map_ioapic_intr = x86_no_iommu_map_ioapic_intr, + .unmap_ioapic_intr = x86_no_iommu_unmap_ioapic_intr, +}; + +static struct x86_iommu *x86_iommu = &x86_no_iommu; void set_x86_iommu(struct x86_iommu *x) { - MPASS(x86_iommu == NULL); + MPASS(x86_iommu == &x86_no_iommu); x86_iommu = x; }