From nobody Thu Jan 18 17:00:19 2024 X-Original-To: dev-commits-src-main@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 4TG8BW2jgbz56Tsy; Thu, 18 Jan 2024 17:00:19 +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 4TG8BW244jz42hS; Thu, 18 Jan 2024 17:00:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705597219; 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=M6Iik1JJgBDn/IGhPWDtW9kQWysZkdu3A3pWOaYhtBk=; b=C27VOiICaqMJAi1n/8WyWHuxc3pZGZELIrj2Ru3767uPG3YXo0jKfUeOLfjrjtpwSvUaaG RBZpGm19E9Esrwc2inqm+2tlaOyb9OGFSJLw98sdgwrzOQaJaxi6rPflRIB1NBx6zqCRAo qN/kcbgI1uE2428gkPlUiav3+SUBz9kFSRPKGunIhOQ4cFpK+ZZZ0R1Gguo7o4pQDdjCPS yIpZqZtKzPaY1dWC4rv6f7KE3EAqa1mlnErEE3/M/65VzVGcDWZONzOF8InDDS3NK5d4Nc MQm5j9HWJht0fbPx/M0sl8yJU8wURCuikj3F3OfxXnJvsRNVsNwN5NdVMSYwPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705597219; 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=M6Iik1JJgBDn/IGhPWDtW9kQWysZkdu3A3pWOaYhtBk=; b=aF74JDcK6hbjsE6JeRIwCsYS30miTjNA9f45g7d1UM/KEQ3JzEVLNJoaYlhCBvmVn5VoKX Hnod4nZRRUM/FsEzMf3DpCuxeahZGLsYY6WHdUrQV00aeJ6HCE2d0CFfFCA9CkRjALpKqx SewyO/jbhL5kq/3H4JHvwQb+z1LNIXe8rAMICfaTSrFiW6yZIglkDTHSNsexrVVqn/tnuR ZC8Ri4T/R0MXUweAe+YB/qzPrLGfxvB7CnVoOVoA3x9Nn8jrvo0yTXIQIM0LcPCTZ8jL7X WO7d9qz7RY+qBPIZFEawrAEfLBnEqi66tQTunOfhBDTT2WXz+2UMOkR0rLKbMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705597219; a=rsa-sha256; cv=none; b=Zl2vXoK4Jm7x8GcweGBW+LETsVTBdgXYortdAHMriivnNFNsClEKehXUZHL7UqU2LsQg5y jRKYrjS3ec8VBSM6ne1K3cYVgBDzFGD68ppxStSdJjn4klLhVXh9Wh2fGVR2AgXmWLWj8i lfjavz6FJWucXJxSUcQNNeYWDLky13tHJwU09l6UA9OtbiUKvHzcoHxK2I84qK/anFODz1 U+fwqwAnn2AfWwAFDd23sKMNvOIwcTqCqSs+zALbidOvYP8vcyFEamKLXPvHxMA5O7090e ZdfFYLgUodHxKXtaska7GZ+9WrHtM56u8doyAN6+mPytLxzbH6yfxDurAa3Chw== 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 4TG8BW193bzFjC; Thu, 18 Jan 2024 17:00:19 +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 40IH0Jgg039388; Thu, 18 Jan 2024 17:00:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40IH0JP5039383; Thu, 18 Jan 2024 17:00:19 GMT (envelope-from git) Date: Thu, 18 Jan 2024 17:00:19 GMT Message-Id: <202401181700.40IH0JP5039383@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 2e297cbb4fc0 - main - arm64: fix db_read_bytes() for size == 8 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2e297cbb4fc057e1872114ef8a37a41a6669dd5b Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=2e297cbb4fc057e1872114ef8a37a41a6669dd5b commit 2e297cbb4fc057e1872114ef8a37a41a6669dd5b Author: Mitchell Horne AuthorDate: 2024-01-17 16:45:41 +0000 Commit: Mitchell Horne CommitDate: 2024-01-18 17:00:07 +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 MFC after: 3 days Fixes: a67687fcd8f5 ("Use native-sized accesses when accessing memory from kdb") --- 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 8d97ab46a837..0b1c58ca88a0 100644 --- a/sys/arm64/arm64/db_interface.c +++ b/sys/arm64/arm64/db_interface.c @@ -124,14 +124,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)