Bug 276406

Summary: arm64 ddb: x/hx truncates value to 32bit
Product: Base System Reporter: dfr
Component: kernAssignee: Mitchell Horne <mhorne>
Status: Closed FIXED    
Severity: Affects Only Me CC: mhorne
Priority: ---    
Version: 14.0-RELEASE   
Hardware: Any   
OS: Any   

Description dfr 2024-01-17 16:13:42 UTC
Note: the high bits of this value should be 0xffff0000 as seen in the x/x output.

Stopped at      kdb_sysctl_enter+0x98:  str     xzr, [x19, #256]
db> x/x preload_metadata
preload_metadata:       1874000
db>
preload_metadata+0x4:   ffff0000
db> x/gx preload_metadata
preload_metadata:       1874000
Comment 1 Mitchell Horne freebsd_committer freebsd_triage 2024-01-17 16:52:35 UTC
I managed to find the issue fairly quickly. Thanks for the report.

https://reviews.freebsd.org/D43479
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-01-18 17:00:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2e297cbb4fc057e1872114ef8a37a41a6669dd5b

commit 2e297cbb4fc057e1872114ef8a37a41a6669dd5b
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-01-17 16:45:41 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
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(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-01-18 17:22:53 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9c2e1a54f71a399fc4645c4b8bed044705629143

commit 9c2e1a54f71a399fc4645c4b8bed044705629143
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-01-17 16:45:41 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-01-18 17:20:42 +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")
    Differential Revision:  https://reviews.freebsd.org/D43479

 sys/arm64/arm64/db_interface.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-01-22 18:05:45 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c738eac52e05204e443841cf1ae6cce32c6a7525

commit c738eac52e05204e443841cf1ae6cce32c6a7525
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-01-17 16:45:41 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
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(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-01-22 18:07:47 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4057fb12a1d7147b85062ad9f3916138c3956cf3

commit 4057fb12a1d7147b85062ad9f3916138c3956cf3
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-01-17 16:45:41 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
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(-)