From nobody Mon Jan 22 18:07:42 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 4TJdVQ3hYgz57vFp; Mon, 22 Jan 2024 18:07:42 +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 4TJdVQ2v5Pz4p2B; Mon, 22 Jan 2024 18:07:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705946862; 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=akURnw2c+uxX1XGLJnMIlCsfLqODKEbEywBfH955GMM=; b=Z44joHIC/n+I+r4I4vk0j/uFphvXi47o354jKj997q8hmUD1a3M9DcoocAH8Wk6uLGtSa8 wHT4GDlb2vQdcodX+dpwtcMrG/4vKvbjOxFEmaSotoUHlX9GbEqSyjeeXF71YHAJJ8E+xY GcBo+iRMc/7xskTPEooYpT62jEnhG/LKgi//e+UCA3xUZvlvefAALU+rrwlIBwQ2U/n6Ft bGBLyT/o0SlaBe3pHE5lneViaBMnI+9p6DqhIOPSh+8XHZLlfLBxGK33VMJy9IWpx3Y96q H3uTaZBsYZt0BR//IsK3zRzhZwQHwsiHydIOqN0m+AfReVbNxWXoLJ+a2c38aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705946862; 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=akURnw2c+uxX1XGLJnMIlCsfLqODKEbEywBfH955GMM=; b=nkiPXvIdpYm1mZveTqmuzT7bU9MXtk4b7QI23C4pq7FzmT8ywRQliCn5ZOAj/q92+GWPaq 1h3X/5aBzze6ApyYTgRca/7ud1ONTjjcWFIXzsbQNJ9jEKhYolrLY88tKsLctNEsKMmBHX 8Y7TN+Z9QPGyPE1rJUKqgQYaBz7+v+45aeJHMf3OVZ0WYWH5+QjCMjVHZbdoumZ5m0O4Ho FyTfXb1KNO4kTGLWW/AqWOfjVcAtrtbzwQ4AGKPyUAL6aNmhuBOWyzkvH3YUhkep6DcyeD EiXZIhfymKH5mKNjFB6fVznWO31827gDGi1UvcQuhcZIm0ZsmLrV6Q0PGOtw6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705946862; a=rsa-sha256; cv=none; b=JIeIsGk8YA7skZck67THOikt8i1qDe3RiItqHs6rgGe9qI//iV7YX/L0jXD3OFB1oisouh oHokF8IyDsK3+nX1uQEbCMauTrTspNdOmxAnLqXXqQxhYC7y7kzFY70MhEjOt86qEWF/Tn aLxXiJlieWRPQC+y4UzI8rwfZLq6VMmuBolIAKSvfw7nuMLck+SgCN9hb/iVio90hpj93l 58Yj17RX+lMntlXjmDyHd019B9+bGUOV2NbkoyMH6oz6+BlD8bNS3aWkjlwR8x4jKoIlcN qricS5BNCAbCN52AyHnH5672bzIqv5okLWqCT/qAD7ldzx6395JZn/FjwAlZSQ== 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 4TJdVQ1yzvz1Bl0; Mon, 22 Jan 2024 18:07:42 +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 40MI7gZ6076200; Mon, 22 Jan 2024 18:07:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40MI7gDE076197; Mon, 22 Jan 2024 18:07:42 GMT (envelope-from git) Date: Mon, 22 Jan 2024 18:07:42 GMT Message-Id: <202401221807.40MI7gDE076197@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: 4057fb12a1d7 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 4057fb12a1d7147b85062ad9f3916138c3956cf3 Auto-Submitted: auto-generated The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4057fb12a1d7147b85062ad9f3916138c3956cf3 commit 4057fb12a1d7147b85062ad9f3916138c3956cf3 Author: Mitchell Horne AuthorDate: 2024-01-17 16:45:41 +0000 Commit: Mitchell Horne CommitDate: 2024-01-22 18:05:27 +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 0c369ba87709..65af5395500e 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)