Skip to contentSkip to conversation

target/i386: fix width of third operand of VINSERTx128

PATCH In review Paolo Bonzini 5 participants 5 messages Jul 25, 2025 – Jul 28, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386: fix width of third operand of VINSERTx128

Table A-5 of the Intel manual incorrectly lists the third operand of VINSERTx128 as Wqq, but it is actually a 128-bit value. This is visible when W is a memory operand close to the end of the page.

Fixes the recently-added poly1305_kunit test in linux-next.

(No testcase yet, but I plan to modify test-avx2 to use memory close to the end of the page. This would work because the test vectors correctly have the memory operand as xmm2/m128).

Cc Ard Biesheuvel <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Guenter Roeck <[email protected]>
---
 target/i386/tcg/decode-new.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/tcg/decode-new.c.inc +2 -2
index 853b1c8bf95..51038657f0f 100644
@@ -878,10 +878,10 @@ static const X86OpEntry opcodes_0F3A[256] = {
     [0x0e] = X86_OP_ENTRY4(VPBLENDW,   V,x,  H,x,  W,x,  vex4 cpuid(SSE41) avx2_256 p_66),
     [0x0f] = X86_OP_ENTRY4(PALIGNR,    V,x,  H,x,  W,x,  vex4 cpuid(SSSE3) mmx avx2_256 p_00_66),
 
-    [0x18] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,qq, vex6 chk(W0) cpuid(AVX) p_66),
+    [0x18] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,dq, vex6 chk(W0) cpuid(AVX) p_66),
     [0x19] = X86_OP_ENTRY3(VEXTRACTx128, W,dq, V,qq, I,b,  vex6 chk(W0) cpuid(AVX) p_66),
 
-    [0x38] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,qq, vex6 chk(W0) cpuid(AVX2) p_66),
+    [0x38] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,dq, vex6 chk(W0) cpuid(AVX2) p_66),
     [0x39] = X86_OP_ENTRY3(VEXTRACTx128, W,dq, V,qq, I,b,  vex6 chk(W0) cpuid(AVX2) p_66),
 
     /* Listed incorrectly as type 4 */
Signature · 1 line
2.50.1
Tested-by on v1 1/1
#1 lore raw
Quoted 2 lines · Paolo Bonzini

Table A-5 of the Intel manual incorrectly lists the third operand of VINSERTx128 as Wqq, but it is actually a 128-bit value.

That's annoying. I wonder what the way to report that is.

FWIW, AMD's manual gets it right.

Quoted 25 lines

This is
visible when W is a memory operand close to the end of the page.

Fixes the recently-added poly1305_kunit test in linux-next.

(No testcase yet, but I plan to modify test-avx2 to use memory close to the end of the page. This would work because the test vectors correctly have the memory operand as xmm2/m128).

Cc Ard Biesheuvel <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Guenter Roeck <[email protected]>
---
 target/i386/tcg/decode-new.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/tcg/decode-new.c.inc +0 -0
index 853b1c8bf95..51038657f0f 100644
@@ -878,10 +878,10 @@ static const X86OpEntry opcodes_0F3A[256] = {
     [0x0e] = X86_OP_ENTRY4(VPBLENDW,   V,x,  H,x,  W,x,  vex4 cpuid(SSE41) avx2_256 p_66),
     [0x0f] = X86_OP_ENTRY4(PALIGNR,    V,x,  H,x,  W,x,  vex4 cpuid(SSSE3) mmx avx2_256 p_00_66),

target/i386/tcg/decode-new.c.inc static const X86OpEntry opcodes_0F3A[256] = { · line 887

Quoted 10 lines
target/i386/tcg/decode-new.c.inc +2 -2
 
-    [0x18] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,qq, vex6 chk(W0) cpuid(AVX) p_66),
+    [0x18] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,dq, vex6 chk(W0) cpuid(AVX) p_66),
     [0x19] = X86_OP_ENTRY3(VEXTRACTx128, W,dq, V,qq, I,b,  vex6 chk(W0) cpuid(AVX) p_66),
 
-    [0x38] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,qq, vex6 chk(W0) cpuid(AVX2) p_66),
+    [0x38] = X86_OP_ENTRY4(VINSERTx128,  V,qq, H,qq, W,dq, vex6 chk(W0) cpuid(AVX2) p_66),
     [0x39] = X86_OP_ENTRY3(VEXTRACTx128, W,dq, V,qq, I,b,  vex6 chk(W0) cpuid(AVX2) p_66),
 
     /* Listed incorrectly as type 4 */

Thanks,

- Eric

Tested-by on v1 1/1
#2 lore raw
In reply to Paolo Bonzini
Quoted 10 lines · Paolo Bonzini

Table A-5 of the Intel manual incorrectly lists the third operand of VINSERTx128 as Wqq, but it is actually a 128-bit value. This is visible when W is a memory operand close to the end of the page.

Fixes the recently-added poly1305_kunit test in linux-next.

(No testcase yet, but I plan to modify test-avx2 to use memory close to the end of the page. This would work because the test vectors correctly have the memory operand as xmm2/m128).

Quoted 5 lines
Cc Ard Biesheuvel <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Guenter Roeck <[email protected]>

Thanks a lot for the quick fix!

Guenter

Reviewed-by on v1 1/1
#3 lore raw
In reply to Paolo Bonzini
Quoted 10 lines · Paolo Bonzini

Table A-5 of the Intel manual incorrectly lists the third operand of VINSERTx128 as Wqq, but it is actually a 128-bit value. This is visible when W is a memory operand close to the end of the page.

Fixes the recently-added poly1305_kunit test in linux-next.

(No testcase yet, but I plan to modify test-avx2 to use memory close to the end of the page. This would work because the test vectors correctly have the memory operand as xmm2/m128).

Quoted 8 lines
Cc Ard Biesheuvel<[email protected]>
Cc "Jason A. Donenfeld"<[email protected]>
Cc Guenter Roeck<[email protected]>
---
  target/i386/tcg/decode-new.c.inc | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

r~

#4 lore raw
In reply to Paolo Bonzini
Quoted 10 lines · Paolo Bonzini

Table A-5 of the Intel manual incorrectly lists the third operand of VINSERTx128 as Wqq, but it is actually a 128-bit value. This is visible when W is a memory operand close to the end of the page.

Fixes the recently-added poly1305_kunit test in linux-next.

(No testcase yet, but I plan to modify test-avx2 to use memory close to the end of the page. This would work because the test vectors correctly have the memory operand as xmm2/m128).

Fixes 79068477686 ("target/i386: reimplement 0x0f 0x3a, add AVX")
Quoted 8 lines
Cc Ard Biesheuvel <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Guenter Roeck <[email protected]>
---
  target/i386/tcg/decode-new.c.inc | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)