From patchwork Thu Oct 26 10:50:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117192 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp607776qgn; Thu, 26 Oct 2017 03:50:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RBAAMDpiyaO8fIrcyWR6jdJ1yghS46bHE9P89sRts2lGPIh0pVWZnNeoEKeeFxZS6x+3L6 X-Received: by 10.37.61.7 with SMTP id k7mr3143630yba.164.1509015038936; Thu, 26 Oct 2017 03:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509015038; cv=none; d=google.com; s=arc-20160816; b=j1cdEKXEVV4m6IpDLatr6RO8LlLi/OcQyNcHkvCXqoxrMCwzKBaEPd7ifuWt7rzgBY x6YCZGycXts8tp/oT8WY4EkrRRRapx3xfRXKd8R39bz8d7/uch4DninphevEMsA+WVx9 5bVhtXXZjt37U8J+i9Bm6FtaVL9NtfuuEh8O52iirQ+J5qJ3PVv2PdgqAtTkadsr8IQD K6ikoRhdFD4UpYBnhoeiR53ggzfh1hoYdsfyc+cWqVf6/gg/f/eX1HqPJkG2+pGBArp4 oGLCpIvYzzPkiwCzUrNu8IFyqZTTh7ml3Xb4bVdfh8Jg/gXUPYcvDHGsatHoPUJ7VHVM 67pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=IsIfMjqihBxBB/wxTQnqMo3Bnm37m0AYcO1/doCyeaI=; b=zU667qBSv0hN0EKko1/h++L4vaVb+BGf4Nc+ihYCKN5b4P+a4WtskpjLgv6wl07pWS N7NrSV2MQLWcH/suXwQgD2UtDj/PTcOIe3qwwtSwYNUOygwqpCr/8UtXVgVIT02l/M73 xd2IVCScjKIkRxJCyC+79jJejSIdHKN9gwke9M2x+8mvk1cLaaa9rgqH+xvF5sXjFApz tB9DnU+tZQ9ySvLnWiaaGbmUGH7681hxZrKXJyqTP4wvE3xISnVyDlx8DxU9S5Z+7cQg ox8xGwkEbv4TwcksT0TfN023m4zdciPC6vyuxQZvRg1QEqb6e0LS8E5pgvZOzSCAG1Dm /vAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O5hcE1Sn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e188si745822ybh.691.2017.10.26.03.50.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 26 Oct 2017 03:50:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O5hcE1Sn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7fkE-0007q2-Cs for patch@linaro.org; Thu, 26 Oct 2017 06:50:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7fjs-0007oY-BL for qemu-devel@nongnu.org; Thu, 26 Oct 2017 06:50:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7fjp-0002jM-Ud for qemu-devel@nongnu.org; Thu, 26 Oct 2017 06:50:16 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:56663) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7fjp-0002iZ-Ku for qemu-devel@nongnu.org; Thu, 26 Oct 2017 06:50:13 -0400 Received: by mail-wr0-x241.google.com with SMTP id r79so2700250wrb.13 for ; Thu, 26 Oct 2017 03:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IsIfMjqihBxBB/wxTQnqMo3Bnm37m0AYcO1/doCyeaI=; b=O5hcE1SnjkeEH26NOp0skQeE93Aw+6ingaenuv1s3AwrSA96MN9nktEVpw8nJdNO1K ZpYr4lV+FAa5aZBmVF0zr/26W2iWSSQpodn0manyi24lbWZFx0JgUWGympJC9uupY/tt WGKZWCAKD+u0mY6VL5ocRqbjLgBD+x7bSJPzg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IsIfMjqihBxBB/wxTQnqMo3Bnm37m0AYcO1/doCyeaI=; b=KLEBYakXdRp8GxZqraHiO71uvodj2HlEaMuQk0LIW0o9uDny18ZRwwmlFKhgqifF7U VUfeZ2R65nGWXCE/Q0I0aR/OCpMuqfio/M/bE9YV/9k+tzpufh+mW3U7kwgKko2CDOqI wPgTWhXylw9dHCr0+WY1EkXa8EtyPdo1xP1Y5TMBCp3QcsmOtkZsPMO3wjCP9DqgABkY Av6/I97+seXwebfFJ0WrCPmNon2tA6O4+YSIk6pXiO9Ti9lcSM4qf7YAdjKMu6QtFMip sJmQNRs/31RRXDPnkY32PxgKQId52EeDlElamlkkYQ8JYItYNOgzFVGH+ELg30HIB6Mr YlqQ== X-Gm-Message-State: AMCzsaW83/hXQ1Rb8Q3Zxvd534xtvX5aZFaYsmtu82QB4s0NGBscoyqn m8DOlbBbXNeU9phrRiUTktPr7mAYFBo= X-Received: by 10.223.179.20 with SMTP id j20mr5269767wrd.116.1509015012282; Thu, 26 Oct 2017 03:50:12 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.124]) by smtp.gmail.com with ESMTPSA id p128sm924484wmb.1.2017.10.26.03.50.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Oct 2017 03:50:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 26 Oct 2017 12:50:04 +0200 Message-Id: <20171026105007.31777-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171026105007.31777-1-richard.henderson@linaro.org> References: <20171026105007.31777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v2 1/4] target/i386: Decode AMD XOP prefix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, ehabkost@redhat.com, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson --- target/i386/translate.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) -- 2.13.6 diff --git a/target/i386/translate.c b/target/i386/translate.c index 7df9233ded..db88cc4764 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -4536,8 +4536,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) #endif case 0xc5: /* 2-byte VEX */ case 0xc4: /* 3-byte VEX */ + case 0x8f: /* 3-byte XOP */ /* VEX prefixes cannot be used except in 32-bit mode. - Otherwise the instruction is LES or LDS. */ + Otherwise the instruction is LES, LDS, or POP. */ if (s->code32 && !s->vm86) { static const int pp_prefix[4] = { 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ @@ -4546,7 +4547,13 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) if (!CODE64(s) && (vex2 & 0xc0) != 0xc0) { /* 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b, - otherwise the instruction is LES or LDS. */ + otherwise the instruction is LES, LDS, or POP. */ + break; + } + if (b == 0x8f && (vex2 & 0x1f) < 8) { + /* If the value of the XOP.map_select field is less than 8, + the first two bytes of the three-byte XOP are interpreted + as a form of the POP instruction. */ break; } s->pc++; @@ -4572,18 +4579,25 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) #endif vex3 = x86_ldub_code(env, s); rex_w = (vex3 >> 7) & 1; - switch (vex2 & 0x1f) { - case 0x01: /* Implied 0f leading opcode bytes. */ - b = x86_ldub_code(env, s) | 0x100; - break; - case 0x02: /* Implied 0f 38 leading opcode bytes. */ - b = 0x138; - break; - case 0x03: /* Implied 0f 3a leading opcode bytes. */ - b = 0x13a; - break; - default: /* Reserved for future use. */ - goto unknown_op; + if (b == 0xc4) { + switch (vex2 & 0x1f) { + case 0x01: /* Implied 0f leading opcode bytes. */ + b = x86_ldub_code(env, s) | 0x100; + break; + case 0x02: /* Implied 0f 38 leading opcode bytes. */ + b = 0x138; + break; + case 0x03: /* Implied 0f 3a leading opcode bytes. */ + b = 0x13a; + break; + default: /* Reserved for future use. */ + goto unknown_op; + } + } else { + /* Unlike VEX, XOP.map_select does not overlap the + base instruction set. Prepend the map_select to + the next opcode byte. */ + b = x86_ldub_code(env, s) + (vex2 & 0x1f) * 0x100; } } s->vex_v = (~vex3 >> 3) & 0xf; @@ -8307,6 +8321,10 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) case 0x1d0 ... 0x1fe: gen_sse(env, s, b, pc_start, rex_r); break; + + case 0x800 ... 0x8ff: /* XOP opcode map 8 */ + case 0x900 ... 0x9ff: /* XOP opcode map 9 */ + case 0xa00 ... 0xaff: /* XOP opcode map 10 */ default: goto unknown_op; }