From nobody Wed May 29 16:57:43 2024 X-Original-To: riscv@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 4VqFtc1hHmz5MrQH for ; Wed, 29 May 2024 16:57:44 +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 4VqFtb6N37z4l6B for ; Wed, 29 May 2024 16:57:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717001863; a=rsa-sha256; cv=none; b=n44jGHkZ1Q8/U62KJM0I9FKXNcg6LyPxRVjH4F9g3GHGoYI5yjP2ZrgX6Ql4nO9Ws3HQRL g0tvUW89rY08e8ellOVqcJXn2F5OuCfRZXc8MA3X9EB/OCoEUzykGodyoXKCd7ZDTRHbYf 1cOpUHyf6ru8HImie85xXJBpNYH31LwbNdb+eiVDOHOXT/kHvgbBtxh6slBS69H5BA9Seh T/QsZ/y/mBQWqFAVgks+1Yg77/0QBa+uJoQ42yt4gRj5q38Q0hhBlISq3LTEcWIvnkjNTm I/9CEpmQyfLeC5S1ulNQgk5RUAQdDlFG/GNOHmyWfItkUSJzsWx6ngALFbnrXA== 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=1717001863; 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=sfNHDNKIRa4I8QXrRcBhuHI8me0AtwAVW10X5+v7JzI=; b=QZKAgKhs5+dt08vFFHLU/Nv/zDegOmU15/fiSuYg47iIXgcfVEKsIbFotIdLkpqxp7ALlW 1ibSsAOnhw/Ft8oaUQu64R+/QM4l4g6GlSNACdKFu7Ooo9G7b1NYxdxTqY8f0TbGH7lHgM eV3w4bwX9MkDIWzntxvZ49dNxVv2XGFotyvp+YuBq26O4eABNMoxg/qaGqKl68llXadw9H OTxZZSSyyh0F4W3mpKTXkL+m5kQSz3QLvvbJ3mOjoU7hpMDfjH8iLgbb/6W9AL01kHHVL9 Z23wDgQQXCqTzlCzJQNPd/ctxVGRzWbmvpf2Yes8h1ky40iUblAyB0oup1GnEA== 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 4VqFtb5sNkz14Xf for ; Wed, 29 May 2024 16:57:43 +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 44TGvhVr045415 for ; Wed, 29 May 2024 16:57:43 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 44TGvh9W045411 for riscv@FreeBSD.org; Wed, 29 May 2024 16:57:43 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: riscv@FreeBSD.org Subject: [Bug 279383] riscv bounce_bus_dmamap_load_buffer() Date: Wed, 29 May 2024 16:57:43 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: riscv X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: rtm@lcs.mit.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: riscv@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 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: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-riscv@freebsd.org Sender: owner-freebsd-riscv@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279383 Bug ID: 279383 Summary: riscv bounce_bus_dmamap_load_buffer() Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: riscv Assignee: riscv@FreeBSD.org Reporter: rtm@lcs.mit.edu I use an old riscv simulator whose virtio block device doesn't support the VIRTIO_BLK_F_SEG_MAX feature, so FreeBSD's vtblk_maximum_segments() decides it supports only three segments. This has worked, but stopped working after a recent update to the riscv busdma_bounce.c. The very first read of a virtio block device is 20 bytes (to read the label?). The riscv bounce_bus_dmamap_load_buffer() decides a bounce page is needed. But it rounds up the size from buflen=3D20 bytes to a whole page (since dmat->common.alignment is 4096): sgsize =3D MIN(buflen, PAGE_SIZE - (curaddr & PAGE_MASK)); if (((dmat->bounce_flags & BF_COULD_BOUNCE) !=3D 0) && map->pagesneeded !=3D 0 && addr_needs_bounce(dmat, curaddr)) { sgsize =3D roundup2(sgsize, dmat->common.alignment); curaddr =3D add_bounce_page(dmat, map, kvaddr, cura= ddr, sgsize); The immediate problem is that later the=20 buflen -=3D sgsize; wraps (since buflen is 20 and sgsize is 4096), so that buflen is huge and the while loop incorrectly makes a second iteration.=20 A potential fix is to restore the bounce_bus_dmamap_load_buffer() code from a few months ago that limits sgsize to be no more than buflen. FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #312 main-n250991-01d33dbbb3f8-dirty: Wed May 29 12:49:02 EDT 2024=20=20=20=20 rtm@zika:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv --=20 You are receiving this mail because: You are the assignee for the bug.=