Skip to contentSkip to conversation

x86 MMX register access problem seen on Sparc host

Qemu-devel Blue Swirl 3 participants 7 messages Sep 21, 2008 – Nov 15, 2008

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

The first line is the following:

    val |= (s->XMM_B(0) >> 7);

In cpu.h, the macro is defined on big endian host as #define XMM_B(n) _b[15 - (n)]

But the type of Reg argument is MMXReg for pmovmskb_mmx and then the _b array has only 8 items.

#1 lore raw
Quoted 11 lines · Blue Swirl

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

The first line is the following:

   val |= (s->XMM_B(0) >> 7);

All the lines before #if SHIFT == 1 should be MMX_B really.

Quoted 8 lines

In cpu.h, the macro is defined on big endian host as #define XMM_B(n) _b[15 - (n)]

But the type of Reg argument is MMXReg for pmovmskb_mmx and then the _b array has only 8 items.

Signature · 1 line
mailto:[email protected]
#2 lore raw
Quoted 11 lines · malc
Quoted 9 lines · Blue Swirl

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

Quoted 4 lines
Quoted 2 lines

The first line is the following:

   val |= (s->XMM_B(0) >> 7);

All the lines before #if SHIFT == 1 should be MMX_B really.

Scratch that. It should be this instead:

target-i386/ops_sse.h +16 -16
index 7568681..2b594db 100644
@@ -979,23 +979,23 @@ uint32_t glue(helper_pmovmskb, SUFFIX)(Reg *s)
 {
     uint32_t val;
     val = 0;
-    val |= (s->XMM_B(0) >> 7);
-    val |= (s->XMM_B(1) >> 6) & 0x02;
-    val |= (s->XMM_B(2) >> 5) & 0x04;
-    val |= (s->XMM_B(3) >> 4) & 0x08;
-    val |= (s->XMM_B(4) >> 3) & 0x10;
-    val |= (s->XMM_B(5) >> 2) & 0x20;
-    val |= (s->XMM_B(6) >> 1) & 0x40;
-    val |= (s->XMM_B(7)) & 0x80;
+    val |= (s->B(0) >> 7);
+    val |= (s->B(1) >> 6) & 0x02;
+    val |= (s->B(2) >> 5) & 0x04;
+    val |= (s->B(3) >> 4) & 0x08;
+    val |= (s->B(4) >> 3) & 0x10;
+    val |= (s->B(5) >> 2) & 0x20;
+    val |= (s->B(6) >> 1) & 0x40;
+    val |= (s->B(7)) & 0x80;
 #if SHIFT == 1
-    val |= (s->XMM_B(8) << 1) & 0x0100;
-    val |= (s->XMM_B(9) << 2) & 0x0200;
-    val |= (s->XMM_B(10) << 3) & 0x0400;
-    val |= (s->XMM_B(11) << 4) & 0x0800;
-    val |= (s->XMM_B(12) << 5) & 0x1000;
-    val |= (s->XMM_B(13) << 6) & 0x2000;
-    val |= (s->XMM_B(14) << 7) & 0x4000;
-    val |= (s->XMM_B(15) << 8) & 0x8000;
+    val |= (s->B(8) << 1) & 0x0100;
+    val |= (s->B(9) << 2) & 0x0200;
+    val |= (s->B(10) << 3) & 0x0400;
+    val |= (s->B(11) << 4) & 0x0800;
+    val |= (s->B(12) << 5) & 0x1000;
+    val |= (s->B(13) << 6) & 0x2000;
+    val |= (s->B(14) << 7) & 0x4000;
+    val |= (s->B(15) << 8) & 0x8000;
 #endif
     return val;
 }
Quoted 11 lines
Quoted 9 lines

In cpu.h, the macro is defined on big endian host as #define XMM_B(n) _b[15 - (n)]

But the type of Reg argument is MMXReg for pmovmskb_mmx and then the _b array has only 8 items.

Signature · 1 line
mailto:[email protected]
#3 lore raw
Quoted 13 lines · malc
Quoted 11 lines · malc
Quoted 9 lines · Blue Swirl

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The first line is the following:

   val |= (s->XMM_B(0) >> 7);

All the lines before #if SHIFT == 1 should be MMX_B really.

Scratch that. It should be this instead:

Care to commit the patch?

Quoted 62 lines
target-i386/ops_sse.h +16 -16
index 7568681..2b594db 100644
@@ -979,23 +979,23 @@ uint32_t glue(helper_pmovmskb, SUFFIX)(Reg *s)
 {
     uint32_t val;
     val = 0;
-    val |= (s->XMM_B(0) >> 7);
-    val |= (s->XMM_B(1) >> 6) & 0x02;
-    val |= (s->XMM_B(2) >> 5) & 0x04;
-    val |= (s->XMM_B(3) >> 4) & 0x08;
-    val |= (s->XMM_B(4) >> 3) & 0x10;
-    val |= (s->XMM_B(5) >> 2) & 0x20;
-    val |= (s->XMM_B(6) >> 1) & 0x40;
-    val |= (s->XMM_B(7)) & 0x80;
+    val |= (s->B(0) >> 7);
+    val |= (s->B(1) >> 6) & 0x02;
+    val |= (s->B(2) >> 5) & 0x04;
+    val |= (s->B(3) >> 4) & 0x08;
+    val |= (s->B(4) >> 3) & 0x10;
+    val |= (s->B(5) >> 2) & 0x20;
+    val |= (s->B(6) >> 1) & 0x40;
+    val |= (s->B(7)) & 0x80;
 #if SHIFT == 1
-    val |= (s->XMM_B(8) << 1) & 0x0100;
-    val |= (s->XMM_B(9) << 2) & 0x0200;
-    val |= (s->XMM_B(10) << 3) & 0x0400;
-    val |= (s->XMM_B(11) << 4) & 0x0800;
-    val |= (s->XMM_B(12) << 5) & 0x1000;
-    val |= (s->XMM_B(13) << 6) & 0x2000;
-    val |= (s->XMM_B(14) << 7) & 0x4000;
-    val |= (s->XMM_B(15) << 8) & 0x8000;
+    val |= (s->B(8) << 1) & 0x0100;
+    val |= (s->B(9) << 2) & 0x0200;
+    val |= (s->B(10) << 3) & 0x0400;
+    val |= (s->B(11) << 4) & 0x0800;
+    val |= (s->B(12) << 5) & 0x1000;
+    val |= (s->B(13) << 6) & 0x2000;
+    val |= (s->B(14) << 7) & 0x4000;
+    val |= (s->B(15) << 8) & 0x8000;
 #endif
     return val;
 }
Quoted 12 lines
Quoted 10 lines

In cpu.h, the macro is defined on big endian host as #define XMM_B(n) _b[15 - (n)]

But the type of Reg argument is MMXReg for pmovmskb_mmx and then the _b array has only 8 items.

Signature · 1 line
mailto:[email protected]
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#4 lore raw
Quoted 17 lines · Aurelien Jarno
Quoted 16 lines · malc
Quoted 14 lines · malc
Quoted 11 lines · Blue Swirl

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

The first line is the following:

   val |= (s->XMM_B(0) >> 7);
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

All the lines before #if SHIFT == 1 should be MMX_B really.

Scratch that. It should be this instead:

Care to commit the patch?

Fabrice was CCed, but i haven't heard his opinion.

[..snip..]

Signature · 1 line
mailto:[email protected]
#5 lore raw
Quoted 21 lines · malc
Quoted 19 lines · Aurelien Jarno
Quoted 18 lines · malc
Quoted 15 lines · malc
Quoted 11 lines · Blue Swirl

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

The first line is the following:
val |= (s->XMM_B(0) >> 7);

All the lines before #if SHIFT == 1 should be MMX_B really.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Scratch that. It should be this instead:

Care to commit the patch?

Fabrice was CCed, but i haven't heard his opinion.

Any news on that? I think the patch could be committed in any case. Otherwise we will forget it. I can commit it if you prefer.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#6 lore raw
Quoted 26 lines · Aurelien Jarno
Quoted 25 lines · malc
Quoted 23 lines · Aurelien Jarno
Quoted 13 lines · malc
Quoted 11 lines · malc
Quoted 9 lines · Blue Swirl

Hi,

I get these warnings when compiling i386 targets on Sparc host using a gcc 4.3 series compiler:
/src/qemu/target-i386/ops_sse.h: In function 'helper_pmovmskb_mmx':
/src/qemu/target-i386/ops_sse.h:982: warning: array subscript is above array bounds
etc.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The first line is the following:
val |= (s->XMM_B(0) >> 7);

All the lines before #if SHIFT == 1 should be MMX_B really.

Scratch that. It should be this instead:

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Care to commit the patch?

Fabrice was CCed, but i haven't heard his opinion.

Any news on that? I think the patch could be committed in any case. Otherwise we will forget it. I can commit it if you prefer.

Yes, i think so too, go ahead.

Signature · 1 line
mailto:[email protected]