From 55520851150bcb298984bd73dfa90cfb2f2df66c Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Sun, 3 Jul 2022 22:34:37 +0800 Subject: [PATCH 1/3] add SECURITY.md --- SECURITY.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..5398de8c --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,2 @@ +aquynh -at- gmail.com +mio -at- lazym.io From 22ea31cdf752c3307c5008cb2987536e8f0d6930 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 20 Jul 2022 13:48:13 +0200 Subject: [PATCH 2/3] Fail when VEX.L is set in SSE instructions (AVX is not supported) Closes #1656 --- qemu/target/i386/translate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu/target/i386/translate.c b/qemu/target/i386/translate.c index eef26242..b4dc56f2 100644 --- a/qemu/target/i386/translate.c +++ b/qemu/target/i386/translate.c @@ -3378,6 +3378,10 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, if (is_xmm) reg |= rex_r; mod = (modrm >> 6) & 3; + /* VEX.L (256 bit) encodings are not supported */ + if (s->vex_l != 0) { + goto illegal_op; // perhaps it should be unknown_op? + } if (sse_fn_epp == SSE_SPECIAL) { b |= (b1 << 8); switch(b) { From e485f398467252106abb1da6b04a8afbe37c7f04 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 20 Jul 2022 13:59:27 +0200 Subject: [PATCH 3/3] Add a test to make sure VEX.L stops emulation with an error --- tests/regress/x86_vex.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/regress/x86_vex.c b/tests/regress/x86_vex.c index a05f2cf6..1808de42 100644 --- a/tests/regress/x86_vex.c +++ b/tests/regress/x86_vex.c @@ -47,12 +47,37 @@ static void test_vmovdqu(void) OK(uc_close(uc)); } +/* https://github.com/unicorn-engine/unicorn/issues/1656 */ +static void test_vex_l(void) +{ + uc_engine *uc; + uc_err err; + + /* vmovdqu ymm1, [rcx] */ + char code[] = { '\xC5', '\xFE', '\x6F', '\x09' }; + + /* initialize memory and run emulation */ + OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc)); + OK(uc_mem_map(uc, 0, 2 * 1024 * 1024, UC_PROT_ALL)); + + OK(uc_mem_write(uc, 0, code, sizeof(code) / sizeof(code[0]))); + + err = uc_emu_start(uc, 0, sizeof(code) / sizeof(code[0]), 0, 0); + if(err != UC_ERR_INSN_INVALID) { + fprintf(stderr, "%s", uc_strerror(err)); + assert(false); + } + + OK(uc_close(uc)); +} + /* TODO: Add more vex prefixed instructions Suggestions: vxorpd, vxorps, vandpd, ... */ int main(int argc, char **argv, char **envp) { test_vmovdqu(); + test_vex_l(); return 0; }