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));
                                if (swab)
                                        res = swab64(res);
                                count -= printf(" %016" PRIx64, res);
                        } else if (width == 4) {
                                uint32_t res;
-                               res = (*uip++ = *((uint *)addr));
+                               res = (*uip++ = *((volatile uint *)addr));
                                if (swab)
                                        res = swab32(res);
                                count -= printf(" %08" PRIx32, res);
                        } else if (width == 2) {
                                uint16_t res;
-                               res = (*usp++ = *((ushort *)addr));
+                               res = (*usp++ = *((volatile ushort *)addr));
                                if (swab)
                                        res = swab16(res);
                                count -= printf(" %04" PRIx16, res);
                        } else {
-                               count -= printf(" %02x", (*ucp++ = *((u_char 
*)addr)));
+                               count -= printf(" %02x", (*ucp++ = *((volatile 
u_char *)addr)));
                        }
                        addr += width;
                        offs += width;

========

PS: the below specs are not for the tested system.


-- System Information:
Debian Release: 8.2
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-8-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Reply via email to