target/i386: fix incorrect decoding of EXTRQ_i
PATCH 1/1 target/i386: fix incorrect decoding of EXTRQ_i
The decoding of the extrq instruction with an immediate operand (EXTRQ_i) is incorrect. Per the AMD manual the instruction encoding looks as follows:
EXTRQ xmm1, imm8, imm8 66 0F 78 /0 ib ib
The /0 indicates that the "Reg" field of the ModR/M byte must be equal to 0 and the XMM register operand is specified by the "R/M" field. However, qemu incorrectly uses the "Reg" field to extract the register operand.
This patch instead extracts the XMM register operand from the "R/M" field.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3611
--- target/i386/tcg/decode-new.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/tcg/decode-new.c.inc +1 -1
@@ -605,7 +605,7 @@ static void decode_0F78(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui { static const X86OpEntry opcodes_0F78[4] = { {}, - X86_OP_ENTRY3(EXTRQ_i, V,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ + X86_OP_ENTRY3(EXTRQ_i, U,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ {}, X86_OP_ENTRY3(INSERTQ_i, V,x, U,x, I,w, cpuid(SSE4A)), /* AMD extension */ };
Signature · 1 line
2.53.0
Ping. Just checking if this patch might have been missed, or if anyone has time to take a look. Please let me know if any changes are needed!
Quoted 35 lines · Simon Scherer
The decoding of the extrq instruction with an immediate operand (
EXTRQ_i) is incorrect. Per the AMD manual the instruction encoding looks as follows:EXTRQ xmm1, imm8, imm8 66 0F 78 /0 ib ib
The /0 indicates that the "Reg" field of the ModR/M byte must be equal to 0 and the XMM register operand is specified by the "R/M" field. However, qemu incorrectly uses the "Reg" field to extract the register operand.
This patch instead extracts the XMM register operand from the "R/M" field.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3611
Signed-off-by Simon Scherer <[email protected]>--- target/i386/tcg/decode-new.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/i386/tcg/decode-new.c.inc +1
-2@@ -605,7 +605,7 @@ static void decode_0F78(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui { static const X86OpEntry opcodes_0F78[4] = { {}, - X86_OP_ENTRY3(EXTRQ_i, V,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ + X86_OP_ENTRY3(EXTRQ_i, U,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ {}, X86_OP_ENTRY3(INSERTQ_i, V,x, U,x, I,w, cpuid(SSE4A)), /* AMD extension */ }; --2.53.0
Quoted 9 lines · Simon Scherer
The decoding of the extrq instruction with an immediate operand (
EXTRQ_i) is incorrect. Per the AMD manual the instruction encoding looks as follows:EXTRQ xmm1, imm8, imm8 66 0F 78 /0 ib ib
The /0 indicates that the "Reg" field of the ModR/M byte must be equal to 0 and the XMM register operand is specified by the "R/M" field. However, qemu incorrectly uses the "Reg" field to extract the register operand.
Quoted 8 lines
This patch instead extracts the XMM register operand from the "R/M" field.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3611
Signed-off-by Simon Scherer <[email protected]>--- target/i386/tcg/decode-new.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 11 lines · Simon Scherer
The decoding of the extrq instruction with an immediate operand (
EXTRQ_i) is incorrect. Per the AMD manual the instruction encoding looks as follows:EXTRQ xmm1, imm8, imm8 66 0F 78 /0 ib ib
The /0 indicates that the "Reg" field of the ModR/M byte must be equal to 0 and the XMM register operand is specified by the "R/M" field. However, qemu incorrectly uses the "Reg" field to extract the register operand.
This patch instead extracts the XMM register operand from the "R/M" field.
Thanks, I'll add a check that Reg is indeed 0.
Paolo
Quoted 20 lines
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3611
Signed-off-by Simon Scherer <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target/i386/tcg/decode-new.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/i386/tcg/decode-new.c.inc +1
-1@@ -605,7 +605,7 @@ static void decode_0F78(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui { static const X86OpEntry opcodes_0F78[4] = { {}, - X86_OP_ENTRY3(EXTRQ_i, V,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ + X86_OP_ENTRY3(EXTRQ_i, U,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ {}, X86_OP_ENTRY3(INSERTQ_i, V,x, U,x, I,w, cpuid(SSE4A)), /* AMD extension */ };
Quoted 9 lines · Simon Scherer
The decoding of the extrq instruction with an immediate operand (
EXTRQ_i) is incorrect. Per the AMD manual the instruction encoding looks as follows:EXTRQ xmm1, imm8, imm8 66 0F 78 /0 ib ib
The /0 indicates that the "Reg" field of the ModR/M byte must be equal to 0 and the XMM register operand is specified by the "R/M" field. However, qemu incorrectly uses the "Reg" field to extract the register operand.
Quoted 5 lines
This patch instead extracts the XMM register operand from the "R/M" field.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3611
Signed-off-by Simon Scherer <[email protected]>
This feels like a qemu-stable material.
I'm picking it up, please let me know if I should not.
Thanks,
/mjt
Quoted 17 lines
--- target/i386/tcg/decode-new.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/i386/tcg/decode-new.c.inc +1
-1@@ -605,7 +605,7 @@ static void decode_0F78(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui { static const X86OpEntry opcodes_0F78[4] = { {}, - X86_OP_ENTRY3(EXTRQ_i, V,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ + X86_OP_ENTRY3(EXTRQ_i, U,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */ {}, X86_OP_ENTRY3(INSERTQ_i, V,x, U,x, I,w, cpuid(SSE4A)), /* AMD extension */ };