Re: [PATCH 3/4] x86,module: Detect VMX vs SLD conflicts
From: Masami Hiramatsu
Date: Tue Apr 07 2020 - 12:51:34 EST
Hi Peter,
On Tue, 07 Apr 2020 13:02:39 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> +static bool insn_is_vmx(struct insn *insn)
> +{
> + u8 modrm = insn->modrm.bytes[0];
> + u8 modrm_mod = X86_MODRM_MOD(modrm);
> + u8 modrm_reg = X86_MODRM_REG(modrm);
> +
> + u8 prefix = insn->prefixes.bytes[0];
> +
> + if (insn->opcode.bytes[0] != 0x0f)
> + return false;
> +
> + switch (insn->opcode.bytes[1]) {
> + case 0x01:
> + switch (insn->opcode.bytes[2]) {
> + case 0xc1: /* VMCALL */
> + case 0xc2: /* VMLAUNCH */
> + case 0xc3: /* VMRESUME */
> + case 0xc4: /* VMXOFF */
> + return true;
> +
> + default:
> + break;
> + }
> + break;
> +
> + case 0x78: /* VMREAD */
> + case 0x79: /* VMWRITE */
> + return true;
> +
> + case 0xc7:
> + /* VMPTRLD, VMPTRST, VMCLEAR, VMXON */
> + if (modrm_mod == 0x03)
> + break;
> +
> + if ((modrm_reg == 6 && (!prefix || prefix == 0x66 || prefix == 0xf3)) ||
> + (modrm_reg == 7 && (!prefix || prefix == 0xf3)))
> + return true;
> +
> + break;
> +
> + default:
> + break;
> + }
> +
> + return false;
> +}
OK, so here is what you need ;)