Skip to contentSkip to conversation

x86emul: correct EVEX register extension bit handling for non-64-bit modes

PATCH In review Jan Beulich 2 participants 4 messages Jul 10, 2017 – Sep 5, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86emul: correct EVEX register extension bit handling for non-64-bit modes

While these are latent issues only for now, correct them right away:
- EVEX.V' (called RX in our code) needs to uniformly be 1,
- EXEX.R' (called R in our code) is uniformly being ignored.

xen/arch/x86/x86_emulate/x86_emulate.c +6 -0
@@ -2544,6 +2544,12 @@ x86_decode(
                         evex.raw[1] = vex.raw[1];
                         evex.raw[2] = insn_fetch_type(uint8_t);
 
+                        if ( !mode_64bit() )
+                        {
+                            generate_exception_if(!evex.RX, EXC_UD);
+                            evex.R = 1;
+                        }
+
                         vex.opcx = evex.opcx;
                         break;
                     case 0xc4:

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 5 lines · Jan Beulich

While these are latent issues only for now, correct them right away:
- EVEX.V' (called RX in our code) needs to uniformly be 1,
- EXEX.R' (called R in our code) is uniformly being ignored.

Those changes do match table 2-40 in the manual, but what about other cases?

EVEX.B is uniformly ignored outside of 64bit as well.

What about the opcode independent cases? We should check that the two MBZ bits (currently an anonymous bitfield) are zero, and the MBS bit (currently evex.evex) is set.

~Andrew

Quoted 9 lines
xen/arch/x86/x86_emulate/x86_emulate.c +0 -0
@@ -2544,6 +2544,12 @@ x86_decode(
                         evex.raw[1] = vex.raw[1];
                         evex.raw[2] = insn_fetch_type(uint8_t);

xen/arch/x86/x86_emulate/x86_emulate.c x86_decode( · line 2555

Quoted 10 lines
xen/arch/x86/x86_emulate/x86_emulate.c +6 -0
 
+                        if ( !mode_64bit() )
+                        {
+                            generate_exception_if(!evex.RX, EXC_UD);
+                            evex.R = 1;
+                        }
+
                         vex.opcx = evex.opcx;
                         break;
                     case 0xc4:

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 05.09.17 at 15:07, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

While these are latent issues only for now, correct them right away:
- EVEX.V' (called RX in our code) needs to uniformly be 1,
- EXEX.R' (called R in our code) is uniformly being ignored.

Those changes do match table 2-40 in the manual, but what about other cases?

EVEX.B is uniformly ignored outside of 64bit as well.

Which is being taken care of by

                        /* Operand size fixed at 4 (no override via W bit). */
                        op_bytes = 4;
                        vex.b = 1;

followed a few lines later by

                        opcode = X86EMUL_OPC_EVEX_;
                        evex.raw[0] = vex.raw[0];
                        evex.raw[1] = vex.raw[1];
                        evex.raw[2] = insn_fetch_type(uint8_t);

.

Quoted 3 lines

What about the opcode independent cases? We should check that the two MBZ bits (currently an anonymous bitfield) are zero, and the MBS bit (currently evex.evex) is set.

Yes, I could add these here right away instead of deferring until later.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines · On 05.09.17 at 15:36, <[email protected]> wrote:
Quoted 1 line · On 05.09.17 at 15:07, <[email protected]> wrote:

On 10/07/17 08:25, Jan Beulich wrote:
What about the opcode independent cases? We should check that the two MBZ bits (currently an anonymous bitfield) are zero, and the MBS bit (currently evex.evex) is set.

Yes, I could add these here right away instead of deferring until later.

I'll send an updated v2, but while doing the additions I've noticed that the original patch title justified why the other checks weren't being added at the same time.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel