From nobody Mon Jan 22 18:05:03 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 4TJdRN0WLsz57v6s; Mon, 22 Jan 2024 18:05:04 +0000 (UTC) (envelope-from git@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 4TJdRM6m16z4nXS; Mon, 22 Jan 2024 18:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705946703; 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=awDVNGzV5WnnusoxNiXRgaYoRjNTXNm65tkWuj86yVM=; b=DYMLH4d+2f0y6TEboZzDJTJkDYwKxsBo6aNQez+TtO1lskgL+eevEI49c0+CcI2W1nwy+i WW4trbbOKoB7qr5hw80zYj9XpPl9qncoMDidMwW6lcdsX10SAL7aZUg9qREBP5VA3DSCs4 HYQG2nrvq//mAbWlPeBHWidOukFuTLmawiJVfWpik8eYmNZkAggmtcHJRs1GiJqGvSyDae mkrtHjZeAqoE0UGGXknMhdd2Z8e4EcBCnovSMslCw7BLZpIVCkMtD8ROBUbjPKgo2gZ720 5mAtsNobHLz9JWcBN6Cq3aC1Fee9FtLtkaDeJbDg+85qWgJuIvNXR9zBgmQkog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705946703; 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=awDVNGzV5WnnusoxNiXRgaYoRjNTXNm65tkWuj86yVM=; b=iVzQFQqmb7AKIhx7CqzIj88ok61DFtdfpMDYKJyEGJ7mme+qtt9QKHga91Ryafwg8xdvFh RlpTaTolSJl4FJbDlEu6QCEBorc66/XP5t9U8f2Lm+Ms3AMknN4AiY5jJItEkBkVchRygc t9H9y4DafFIHW6EuqUMIwh/Q803gNpTq09dAYxzRQqVJCyM7aOq3AlSaQJ46ieTdGlwTGB Ryn0qftBCRstjGF7Nbs4Yd3yzrCQqMmdvceq14wZWDZ9VhXVkocDQqOeJM1iO+fueellBI 5d5GvLbaH3jvdyN6OXvFYzDxb0zjTZUc2pRWo6qik/CErqqGOsqih+5KQESbAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705946703; a=rsa-sha256; cv=none; b=jPtZ1u8khxM0F3+Bpn7ebmOApTjnRdab1zZTBA6DSV0gWvDgyo7bC/KtBourdFyT3mM5mC TLBYtSv9zXVl+oo5UG/j+fKqNJKuQ+0mQUwlmX2KeF3Hq9y822TB85vB0wRyYCy2ivYblL nEp1hYCed2+M28/UsmFQrXafYHWdC3KhOolGQO7wRKUJexMnc2fZfxLzilMefj2IBk2KgB 6BlKOra93MR5dnDVALwgiNQMF+eDzkaMwF5gdhPfknOSjCyAU4eMagKdqup92thB0lb4qm qH0VhaQF9FbScZx+vHxlnblz3WcCECnnMjLF/PRO9tr0yU9uJmTnQH9ytd3pFw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4TJdRM5pjYz1BN8; Mon, 22 Jan 2024 18:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40MI53q3075731; Mon, 22 Jan 2024 18:05:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40MI53en075728; Mon, 22 Jan 2024 18:05:03 GMT (envelope-from git) Date: Mon, 22 Jan 2024 18:05:03 GMT Message-Id: <202401221805.40MI53en075728@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: c738eac52e05 - stable/14 - arm64: fix db_read_bytes() for size == 8 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c738eac52e05204e443841cf1ae6cce32c6a7525 Auto-Submitted: auto-generated The branch stable/14 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=c738eac52e05204e443841cf1ae6cce32c6a7525 commit c738eac52e05204e443841cf1ae6cce32c6a7525 Author: Mitchell Horne AuthorDate: 2024-01-17 16:45:41 +0000 Commit: Mitchell Horne CommitDate: 2024-01-22 18:04:26 +0000 arm64: fix db_read_bytes() for size == 8 There is a mistake in the cast, resulting in a truncated read to tmp64. Switch from int to uint64_t, and adjust the other casts for clarity. Add a comment explaining why we do this at all. Reported by: dfr Reviewed by: dfr, mmel, emaste, jhb (all a previous version) PR: 276406 Fixes: a67687fcd8f5 ("Use native-sized accesses when accessing memory from kdb") Differential Revision: https://reviews.freebsd.org/D43479 (cherry picked from commit 9c2e1a54f71a399fc4645c4b8bed044705629143) --- sys/arm64/arm64/db_interface.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/arm64/arm64/db_interface.c b/sys/arm64/arm64/db_interface.c index 24ce0327e086..01bbd7835450 100644 --- a/sys/arm64/arm64/db_interface.c +++ b/sys/arm64/arm64/db_interface.c @@ -125,14 +125,20 @@ db_read_bytes(vm_offset_t addr, size_t size, char *data) if (ret == 0) { src = (const char *)addr; + + /* + * Perform a native-sized memory access, if possible. This + * enables reading from MMIO devices that don't support single + * byte access. + */ if (size == 8 && (addr & 7) == 0) { - tmp64 = *((const int *)src); + tmp64 = *((const uint64_t *)src); src = (const char *)&tmp64; } else if (size == 4 && (addr & 3) == 0) { - tmp32 = *((const int *)src); + tmp32 = *((const uint32_t *)src); src = (const char *)&tmp32; } else if (size == 2 && (addr & 1) == 0) { - tmp16 = *((const short *)src); + tmp16 = *((const uint16_t *)src); src = (const char *)&tmp16; } while (size-- > 0)