x86emul: reject clear EVEX.V' outside of 64-bit mode
PATCH 1/1 x86emul: reject clear EVEX.V' outside of 64-bit mode
This bit, when clear, uniformly causes #UD in 32- and 16-bit modes. This is unlike the top bit of EVEX.vvvv, which is ignored.
Besides raising #UD, also play safe and force the bit set in copy_EVEX().
---
In principle we could then drop the mode_64bit() check in sib_index calculation, yet seeing the copy_EVEX() change here we may want to keep that as a safeguard.
As to 5d91b689dde4, I'm puzzled why that removed the check being re-added
here: The "Note:" in the description says the check is needed in at least certain cases, and that instead the info in that SDM revision wasn't correct for those. As I don't have that SDM rev around anymore, I can only assume it may have said "ignored" for the "does encode a register" case.
xen/arch/x86/x86_emulate/decode.c +3 -0
@@ -1205,7 +1205,10 @@ int x86emul_decode(struct x86_emulate_stgenerate_exception_if (!s->evex.opmsk && s->evex.z,X86_EXC_UD );if ( !mode_64bit () ) + { +generate_exception_if (!s->evex.RX,X86_EXC_UD ); s->evex.R =1 ; + } s->vex.opcx = s->evex.opcx;break ;
xen/arch/x86/x86_emulate/x86_emulate.c +3 -0
@@ -148,7 +148,10 @@ static const uint8_t sse_prefix[] = { 0x#define copy_EVEX (ptr, evex) ({ \ if ( !mode_64bit() ) \ + { \ (evex).reg |= 8; \ + (evex).RX = 1; \ + } \ (ptr)[1 - EVEX_PFX_BYTES] = (evex).raw[0]; \ (ptr)[2 - EVEX_PFX_BYTES] = (evex).raw[1]; \ (ptr)[3 - EVEX_PFX_BYTES] = (evex).raw[2]; \