Hello Gergely,

On 1/2/21 8:34 PM, Gergely Peli wrote:
Package: memtool
Severity: normal
Tags: upstream patch

Hello,

I tried memtool on a 32 bit ARM system, and the supposedly 64 bit reads
with the "-q" option are done by 2 separate 32 bit "ldr" instructions.
Adding a volatile qualifier to the pointers accessing the memory could
convince gcc to generate a single "ldrd" instruction instead, which uses
a 64 bit memory transfer. See below a proposed patch. Adding volatile to all
4 cases may be an overkill, but can't hurt. Cheers,

Gergely Peli

========

--- memtool-2016.10.0.orig/memtool.c
+++ memtool-2016.10.0/memtool.c
@@ -152,24 +152,24 @@ static int memory_display(const void *ad
                 for (i = 0; i < linebytes; i += width) {
                         if (width == 8) {
                                 uint64_t res;
-                               res = (*uqp++ = *((uint64_t *)addr));
+                               res = (*uqp++ = *((volatile uint64_t *)addr));

In this code location it doesn't matter if two ldrs instead of a single ldrd is used. This is only the code printing the data from the buffer that holds the read data. If memtools behaves wrong the problem is likely in mmap_read.

This makes me wonder how you found the bug and how you tested that your patch indeed fixes it.

Best regards
Uwe

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to