From nobody Sun Apr 7 13:00:47 2024 X-Original-To: freebsd-arm@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 4VCC5J05yjz5Gmdn for ; Sun, 7 Apr 2024 13:00:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VCC5H5CKNz3yB6 for ; Sun, 7 Apr 2024 13:00:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712494851; a=rsa-sha256; cv=none; b=B7/KgpQQYsGTZBmCmYzFnK3U8Qwm6njWdIPgHgUp2Qoj6qRcrCoakiOBmjWVWLBJdBvkBq L3mCyD7CfYB3wsAGFcDHKCXA9R0yPCssKcsNV3j/Vpk4gZ2xHxW8LtUHAo6PnQfv5q98p5 Wo4htHyOk2BA+Wk50CaWqVDRxbzRgypmSP8UwjEIYfukMId1eLJiC67NUAd0GPLoA3HZZu C4d+85ucds6uxmkVkquKDBQ7MkR3FuAcjvGCWSroYCLEF72/mRqRj0BkB58GJeIIUyui9f XRC1nda3m+PNTQNWibepEH3LyRw84+Ld75tH+SbZsszsRGJysqBhK9GM+f98Qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712494851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CE8gq9N+HqnvZdjwUQKkn5nLTpW2qeD9kXIilt6XyPs=; b=g7Tq/UpXXj9YzjLvruTiXpH6qW20A0RIOlFD/kSt9h06jQmNROWCJLzgyuq9KGJuR9D/1c B3Xcohh/TnQedhJpnQd+fSLorfsDNzaadnKtCgtMtV7TBe55cFL1OaTbdjMB17ufA0pCNJ NDRdZvdUSTH7jSWsQLLhUcobLfKF4naXMeihWJHTVWyglmGOOFcN6ld6JTjLQ+8CZGrCov mcXJ8SuitbQ0bCsghBy0eO7HfN0InjdZVQ1oB0dT/snYLjpkIHDKdBWOpGGLhbJZOvsmyS IOD127M/WuwGzghfpGZB+o/4Evop/j+qoZODqSGpg0UlZiFMTVVa4HoR0O3LbQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VCC5H4qBFzSmV for ; Sun, 7 Apr 2024 13:00:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 437D0pEe081143 for ; Sun, 7 Apr 2024 13:00:51 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 437D0pJx081120 for freebsd-arm@FreeBSD.org; Sun, 7 Apr 2024 13:00:51 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: freebsd-arm@FreeBSD.org Subject: [Bug 278233] PHYS_IN_DMAP and VIRT_IN_DMAP macros assume contiguous DMAP memory Date: Sun, 07 Apr 2024 13:00:47 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: arm X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: zeev@amazon.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-arm@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D278233 Bug ID: 278233 Summary: PHYS_IN_DMAP and VIRT_IN_DMAP macros assume contiguous DMAP memory Product: Base System Version: Unspecified Hardware: arm64 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: arm Assignee: freebsd-arm@FreeBSD.org Reporter: zeev@amazon.com Created attachment 249802 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D249802&action= =3Dedit bug fix: support non-contiguous memory in PHYS_IN_DMAP and VIRT_IN_DMAP The issue was observed on r8g.metal-48xl which is a coherent Graviton4-based system with 2 SoCs. ENA driver crashes when trying to remap BAR2 memory with WC attributes: ena0: Elastic Network Adapter (ENA)ena v2.7.0 panic: Invalid DMAP table level: 0 cpuid =3D 0 time =3D 1 KDB: stack backtrace: db_trace_self() at db_trace_self db_trace_self_wrapper() at db_trace_self_wrapper+0x38 vpanic() at vpanic+0x1a4 panic() at panic+0x48 pmap_change_props_locked() at pmap_change_props_locked+0x6dc pmap_change_props_locked() at pmap_change_props_locked+0x550 pmap_change_attr() at pmap_change_attr+0x5c ena_attach() at ena_attach+0x264 device_attach() at device_attach+0x3fc device_probe_and_attach() at device_probe_and_attach+0x80 bus_generic_attach() at bus_generic_attach+0x1c pci_attach() at pci_attach+0xec ... The memory map on those systems has 2 large DRAM regions, one for each SoC.= The regions are non contiguous and IO memory that includes the PCI BARs for the= 2nd SoC is between those 2 regions. So the memory map looks like following DRAM region 0: 0x10000000000-0x1c000000000 IO memory(SoC1): 0x41000000000-0x050000000000 DRAM region 1: 0x50000000000-0x5c000000000 PHYS_IN_DMAP and VIRT_IN_DMAP macros in arm64 vmparam.h that inherently ass= ume that the DMAP region is contiguous with current implementation: /* True if pa is in the dmap range */ #define PHYS_IN_DMAP(pa) ((pa) >=3D DMAP_MIN_PHYSADDR && \ (pa) < DMAP_MAX_PHYSADDR) /* True if va is in the dmap range */ #define VIRT_IN_DMAP(va) ((va) >=3D DMAP_MIN_ADDRESS && \ (va) < (dmap_max_addr)) This causes the following check in sys/arm64/arm64/pmap.c, pmap_change_props_locked() to wrongly conclude that PCI memory is part of D= MAP: if (!VIRT_IN_DMAP(tmpva) && PHYS_IN_DMAP(pa)) { /* * Keep the DMAP memory in sync. */ rv =3D pmap_change_props_locked( PHYS_TO_DMAP(pa), pte_size, prot, mode, true); if (rv !=3D 0) return (rv); } And consequent lookup of this memory in DMAP page tables fails, as PCI memo= ry is not mapped in DMAP. Attached a proposed patch that stores a list of DMAP regions and changes the macros above to functions that check the address vs the list. (Based on https://reviews.freebsd.org/D3538) The instance boots properly after applying this patch. --=20 You are receiving this mail because: You are the assignee for the bug.=