target-i386: add PCLMULQDQ and AES-NI instructions
v4 cover target-i386: add PCLMULQDQ and AES-NI instructions
This patch series adds the PCLMULQDQ and AES-NI instructions to the x86 emulation. Along with the SSE4.1 and SSE4.2 series, this brings the instructions emulation to the level of a Westmere CPU.
It has been tested with the valgrind testsuite and with the kernel autotest.
Changes v1 -> v2:
- Patch 3: Declare all constant tables as static.
Changes v2 -> v3:
- Use constant tables from aes.c.
- Fix AES instructions when source and destination registers are the same.
Changes v3 -> v4:
- Update dissassembler code to support these instructions.
Aurelien Jarno (7):
disas/i386.c: disassemble pclmulqdq instruction
target-i386: add pclmulqdq instruction
target-i386: enable PCLMULQDQ on Westmere CPU disas/i386.c: disassemble aes-ni instructions
aes: move aes.h from include/block to include/qemu
aes: make Td[0-5] and Te[0-5] tables non static
target-i386: add AES-NI instructions
block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qcow2.h | 2 +- disas/i386.c | 84 ++++++- include/block/aes.h | 26 --- include/qemu/aes.h | 45 ++++ target-i386/cpu.c | 19 +- target-i386/fpu_helper.c | 1 + target-i386/ops_sse.h | 111 +++++++++ target-i386/ops_sse_header.h | 11 + target-i386/translate.c | 10 + util/aes.c | 506 +++++++++++++++++++++--------------------- 12 files changed, 517 insertions(+), 302 deletions(-) delete mode 100644 include/block/aes.h create mode 100644 include/qemu/aes.h
Signature · 1 line
1.7.10.4
PATCH v4 1/7 disas/i386.c: disassemble pclmulqdq instruction
--- disas/i386.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
disas/i386.c +11 -2
@@ -664,6 +664,7 @@ fetch_data(struct disassemble_info *info, bfd_byte *addr)#define PREGRP95 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 95 } }#define PREGRP96 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 96 } }#define PREGRP97 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 97 } } +#define PREGRP98 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 98 } }#define X86_64_0 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 0 } }
@@ -1503,7 +1504,7 @@ static const unsigned char threebyte_0x3a_uses_DATA_prefix[256] = {/* 10 */ 0 ,0 ,0 ,0 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 1f */ /* 20 */ 1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 2f */ /* 30 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 3f */ -/* 40 */ 1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 4f */ +/* 40 */ 1 ,1 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 4f */ /* 50 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 5f */ /* 60 */ 1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* 6f */ /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
@@ -2710,6 +2711,14 @@ static const struct dis386 prefix_user_table[][4] = { { "punpckldq",{ MX, EMq } }, { "(bad)", { XX } }, }, + +/* PREGRP98 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "pclmulqdq", { XM, EXx, Ib } }, + { "(bad)", { XX } }, + }, };static const struct dis386 x86_64_table[][2 ] = {
@@ -3102,7 +3111,7 @@ static const struct dis386 three_byte_table[][256] = { { PREGRP84 }, { PREGRP85 }, { "(bad)", { XX } }, - { "(bad)", { XX } }, + { PREGRP98 }, { "(bad)", { XX } }, { "(bad)", { XX } }, { "(bad)", { XX } },
Signature · 1 line
1.7.10.4
PATCH v4 2/7 target-i386: add pclmulqdq instruction
In reply to Aurelien Jarno--- target-i386/cpu.c | 19 +++++++++---------- target-i386/ops_sse.h | 24 ++++++++++++++++++++++++ target-i386/ops_sse_header.h | 5 +++++ target-i386/translate.c | 3 +++ 4 files changed, 41 insertions(+), 10 deletions(-)
target-i386/cpu.c +9 -10
@@ -387,17 +387,16 @@ typedef struct x86_def_t {CPUID_PSE36 (needed for Solaris) */ /* missing: CPUID_VME, CPUID_DTS, CPUID_SS, CPUID_HT, CPUID_TM, CPUID_PBE */ -#define TCG_EXT_FEATURES (CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | \ - CPUID_EXT_SSSE3 | CPUID_EXT_CX16 | CPUID_EXT_SSE41 | \ - CPUID_EXT_SSE42 | CPUID_EXT_POPCNT | CPUID_EXT_MOVBE | \ - CPUID_EXT_HYPERVISOR) +#define TCG_EXT_FEATURES (CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | \ + CPUID_EXT_MONITOR | CPUID_EXT_SSSE3 | CPUID_EXT_CX16 | \ + CPUID_EXT_SSE41 | CPUID_EXT_SSE42 | CPUID_EXT_POPCNT | \ + CPUID_EXT_MOVBE | CPUID_EXT_HYPERVISOR)/* missing: -CPUID_EXT_PCLMULQDQ, CPUID_EXT_DTES64, CPUID_EXT_DSCPL, -CPUID_EXT_VMX, CPUID_EXT_SMX, CPUID_EXT_EST, CPUID_EXT_TM2, -CPUID_EXT_CID, CPUID_EXT_FMA, CPUID_EXT_XTPR, CPUID_EXT_PDCM, -CPUID_EXT_PCID, CPUID_EXT_DCA, CPUID_EXT_X2APIC, -CPUID_EXT_TSC_DEADLINE_TIMER, CPUID_EXT_AES, CPUID_EXT_XSAVE, -CPUID_EXT_OSXSAVE, CPUID_EXT_AVX, CPUID_EXT_F16C, +CPUID_EXT_DTES64, CPUID_EXT_DSCPL, CPUID_EXT_VMX, CPUID_EXT_SMX, +CPUID_EXT_EST, CPUID_EXT_TM2, CPUID_EXT_CID, CPUID_EXT_FMA, +CPUID_EXT_XTPR, CPUID_EXT_PDCM, CPUID_EXT_PCID, CPUID_EXT_DCA, +CPUID_EXT_X2APIC, CPUID_EXT_TSC_DEADLINE_TIMER, CPUID_EXT_AES, +CPUID_EXT_XSAVE, CPUID_EXT_OSXSAVE, CPUID_EXT_AVX, CPUID_EXT_F16C, CPUID_EXT_RDRAND */ #define TCG_EXT2_FEATURES ((TCG_FEATURES & CPUID_EXT2_AMD_ALIASES) | \ CPUID_EXT2_NX | CPUID_EXT2_MMXEXT | CPUID_EXT2_RDTSCP | \
target-i386/ops_sse.h +24 -0
@@ -2179,6 +2179,30 @@ target_ulong helper_popcnt(CPUX86State *env, target_ulong n, uint32_t type)return POPCOUNT (n,5 );#endif } + +void glue (helper_pclmulqdq ,SUFFIX )(CPUX86State *env,Reg *d,Reg *s, +uint32_t ctrl) +{ +uint64_t ah, al, b, resh, resl; + + ah =0 ; + al = d->Q ((ctrl &1 ) !=0 ); + b = s->Q ((ctrl &16 ) !=0 ); + resh = resl =0 ; + +while (b) { +if (b &1 ) { + resl ^= al; + resh ^= ah; + } + ah = (ah <<1 ) | (al >>63 ); + al <<=1 ; + b >>=1 ; + } + + d->Q (0 ) = resl; + d->Q (1 ) = resh; +}#endif #undef SHIFT
target-i386/ops_sse_header.h +5 -0
@@ -336,6 +336,11 @@ DEF_HELPER_3(crc32, tl, i32, tl, i32) DEF_HELPER_3(popcnt, tl, env, tl, i32)#endif +/* AES-NI op helpers */ +#if SHIFT ==1 +DEF_HELPER_4(glue(pclmulqdq, SUFFIX), void, env, Reg, Reg, i32) +#endif +#undef SHIFT#undef Reg#undef SUFFIX
target-i386/translate.c +3 -0
@@ -3147,6 +3147,8 @@ struct SSEOpHelper_eppi {#define SSE41_OP (x) { { NULL, gen_helper_ ## x ## _xmm }, CPUID_EXT_SSE41 }#define SSE42_OP (x) { { NULL, gen_helper_ ## x ## _xmm }, CPUID_EXT_SSE42 }#define SSE41_SPECIAL { { NULL, SSE_SPECIAL }, CPUID_EXT_SSE41 } +#define PCLMULQDQ_OP (x) { { NULL, gen_helper_ ## x ## _xmm }, \ + CPUID_EXT_PCLMULQDQ }static const struct SSEOpHelper_epp sse_op_table6[256 ] = { [0x00 ] =SSSE3_OP (pshufb),
@@ -3216,6 +3218,7 @@ static const struct SSEOpHelper_eppi sse_op_table7[256] = { [0x40] = SSE41_OP(dpps), [0x41] = SSE41_OP(dppd), [0x42] = SSE41_OP(mpsadbw), + [0x44] = PCLMULQDQ_OP(pclmulqdq), [0x60] = SSE42_OP(pcmpestrm), [0x61] = SSE42_OP(pcmpestri), [0x62] = SSE42_OP(pcmpistrm),
Signature · 1 line
1.7.10.4
PATCH v4 3/7 target-i386: enable PCLMULQDQ on Westmere CPU
In reply to Aurelien JarnoThe PCLMULQDQ instruction has been introduced on the Westmere CPU.
--- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-i386/cpu.c +1 -1
@@ -687,7 +687,7 @@ static x86_def_t builtin_x86_defs[] = { CPUID_DE | CPUID_FP87, .ext_features =CPUID_EXT_AES |CPUID_EXT_POPCNT |CPUID_EXT_SSE42 |CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | - CPUID_EXT_SSE3, + CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, .ext2_features = CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .ext3_features = CPUID_EXT3_LAHF_LM, .xlevel = 0x8000000A,
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v4 3/7] target-i386: enable PCLMULQDQ on Westmere CPU
Quoted 14 lines · Aurelien Jarno
The PCLMULQDQ instruction has been introduced on the Westmere CPU.
Reviewed-by Richard Henderson <[email protected]>Reviewed-by Edgar E. Iglesias <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>--- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-i386/cpu.c +0
-0
target-i386/cpu.c static x86_def_t builtin_x86_defs[] = { · line 690
Quoted 5 lines
target-i386/cpu.c +1
-1@@ -687,7 +687,7 @@ static x86_def_t builtin_x86_defs[] = { CPUID_DE | CPUID_FP87, .ext_features =CPUID_EXT_AES |CPUID_EXT_POPCNT |CPUID_EXT_SSE42 |CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | - CPUID_EXT_SSE3, + CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
I have just noticed that this patch entered v1.5.0 without any code to keep pc-1.4 and older machine-types compatible. I will try to send a patch in time to get this fixed on QEMU v1.6.0.
Quoted 7 lines
target-i386/cpu.c +0
-0.ext2_features = CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, .ext3_features = CPUID_EXT3_LAHF_LM, .xlevel = 0x8000000A,Signature · 1 line
1.7.10.4
Signature · 1 line
Eduardo
PATCH v4 4/7 disas/i386.c: disassemble aes-ni instructions
In reply to Aurelien Jarno--- disas/i386.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 6 deletions(-)
disas/i386.c +61 -6
@@ -665,6 +665,12 @@ fetch_data(struct disassemble_info *info, bfd_byte *addr)#define PREGRP96 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 96 } }#define PREGRP97 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 97 } }#define PREGRP98 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 98 } } +#define PREGRP99 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 99 } } +#define PREGRP100 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 100 } } +#define PREGRP101 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 101 } } +#define PREGRP102 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 102 } } +#define PREGRP103 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 103 } } +#define PREGRP104 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 104 } }#define X86_64_0 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 0 } }
@@ -2719,6 +2725,55 @@ static const struct dis386 prefix_user_table[][4] = { { "pclmulqdq", { XM, EXx, Ib } }, { "(bad)", { XX } }, }, + +/* PREGRP99 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "aesimc", { XM, EXx } }, + { "(bad)", { XX } }, + }, + +/* PREGRP100 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "aesenc", { XM, EXx } }, + { "(bad)", { XX } }, + }, + +/* PREGRP101 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "aesenclast", { XM, EXx } }, + { "(bad)", { XX } }, + }, + +/* PREGRP102 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "aesdec", { XM, EXx } }, + { "(bad)", { XX } }, + }, + +/* PREGRP103 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "aesdeclast", { XM, EXx } }, + { "(bad)", { XX } }, + }, + +/* PREGRP104 */ + { + { "(bad)", { XX } }, + { "(bad)", { XX } }, + { "aeskeygenassist", { XM, EXx, Ib } }, + { "(bad)", { XX } }, + }, + };static const struct dis386 x86_64_table[][2 ] = {
@@ -2990,11 +3045,11 @@ static const struct dis386 three_byte_table[][256] = { { "(bad)", { XX } }, { "(bad)", { XX } }, { "(bad)", { XX } }, - { "(bad)", { XX } }, - { "(bad)", { XX } }, - { "(bad)", { XX } }, - { "(bad)", { XX } }, - { "(bad)", { XX } }, + { PREGRP99 }, + { PREGRP100 }, + { PREGRP101 }, + { PREGRP102 }, + { PREGRP103 },/* e0 */ { "(bad)", { XX } }, { "(bad)", { XX } },
@@ -3285,7 +3340,7 @@ static const struct dis386 three_byte_table[][256] = { { "(bad)", { XX } }, { "(bad)", { XX } }, { "(bad)", { XX } }, - { "(bad)", { XX } }, + { PREGRP104 },/* e0 */ { "(bad)", { XX } }, { "(bad)", { XX } },
Signature · 1 line
1.7.10.4
PATCH v4 5/7 aes: move aes.h from include/block to include/qemu
In reply to Aurelien JarnoMove aes.h from include/block to include/qemu to show it can be reused by other subsystems.
--- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qcow2.h | 2 +- include/block/aes.h | 26 -------------------------- include/qemu/aes.h | 26 ++++++++++++++++++++++++++ util/aes.c | 2 +- 6 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 include/block/aes.h create mode 100644 include/qemu/aes.h
block/qcow.c +1 -1
@@ -25,7 +25,7 @@#include "block/block_int.h" #include "qemu/module.h" #include <zlib.h> -#include "block/aes.h" +#include "qemu/aes.h" #include "migration/migration.h" /**************************************************************/
block/qcow2.c +1 -1
@@ -25,7 +25,7 @@#include "block/block_int.h" #include "qemu/module.h" #include <zlib.h> -#include "block/aes.h" +#include "qemu/aes.h" #include "block/qcow2.h" #include "qemu/error-report.h" #include "qapi/qmp/qerror.h"
block/qcow2.h +1 -1
@@ -25,7 +25,7 @@#ifndef BLOCK_QCOW2_H #define BLOCK_QCOW2_H -#include "block/aes.h" +#include "qemu/aes.h" #include "block/coroutine.h" //#define DEBUG_ALLOC
include/block/aes.h deleted +0 -26
@@ -1,26 +0,0 @@ -#ifndef QEMU_AES_H -#define QEMU_AES_H - -#define AES_MAXNR 14 -#define AES_BLOCK_SIZE 16 - -struct aes_key_st { -uint32_t rd_key[4 *(AES_MAXNR +1 )]; -int rounds; -}; -typedef struct aes_key_st AES_KEY ; - -int AES_set_encrypt_key (const unsigned char *userKey,const int bits, -AES_KEY *key); -int AES_set_decrypt_key (const unsigned char *userKey,const int bits, -AES_KEY *key); - -void AES_encrypt (const unsigned char *in,unsigned char *out, -const AES_KEY *key); -void AES_decrypt (const unsigned char *in,unsigned char *out, -const AES_KEY *key); -void AES_cbc_encrypt (const unsigned char *in,unsigned char *out, -const unsigned long length,const AES_KEY *key, -unsigned char *ivec,const int enc); - -#endif
include/qemu/aes.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef QEMU_AES_H +#define QEMU_AES_H + +#define AES_MAXNR 14 +#define AES_BLOCK_SIZE 16 + +struct aes_key_st { +uint32_t rd_key[4 *(AES_MAXNR +1 )]; +int rounds; +}; +typedef struct aes_key_st AES_KEY ; + +int AES_set_encrypt_key (const unsigned char *userKey,const int bits, +AES_KEY *key); +int AES_set_decrypt_key (const unsigned char *userKey,const int bits, +AES_KEY *key); + +void AES_encrypt (const unsigned char *in,unsigned char *out, +const AES_KEY *key); +void AES_decrypt (const unsigned char *in,unsigned char *out, +const AES_KEY *key); +void AES_cbc_encrypt (const unsigned char *in,unsigned char *out, +const unsigned long length,const AES_KEY *key, +unsigned char *ivec,const int enc); + +#endif
util/aes.c +1 -1
@@ -28,7 +28,7 @@* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "qemu-common.h" -#include "block/aes.h" +#include "qemu/aes.h" #ifndef NDEBUG #define NDEBUG
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v4 5/7] aes: move aes.h from include/block to include/qemu
Quoted 8 lines · Aurelien Jarno
Move
aes.hfrominclude/blocktoinclude/qemuto show it can be reused by other subsystems.Cc Kevin Wolf <[email protected]>Cc Stefan Hajnoczi <[email protected]>Reviewed-by Edgar E. Iglesias <[email protected]>Reviewed-by Richard Henderson <[email protected]>Signed-off-by Aurelien Jarno <[email protected]>
Quoted 10 lines
--- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qcow2.h | 2 +- include/block/aes.h | 26 -------------------------- include/qemu/aes.h | 26 ++++++++++++++++++++++++++ util/aes.c | 2 +- 6 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 include/block/aes.h create mode 100644 include/qemu/aes.h
PATCH v4 6/7 aes: make Td[0-5] and Te[0-5] tables non static
In reply to Aurelien JarnoRemove static attribute to Td[0-5] and Te[0-5] tables so that they can be used outside of aes.c. Change their type from u32 to uint32_t, to keep the u32 udef local to aes.c. Prefix them with AES_ so that they do not conflict with other symbols.
--- include/qemu/aes.h | 19 ++ util/aes.c | 504 ++++++++++++++++++++++++++-------------------------- 2 files changed, 271 insertions(+), 252 deletions(-)
Note: while renaming Td/Te tables, I replaced tabs with spaces, but kept the remaining code style to keep the unrolled loops readable.
include/qemu/aes.h +19 -0
@@ -23,4 +23,23 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char *ivec, const int enc); +/* +AES_Te0[x] = S [x].[02, 01, 01, 03]; +AES_Te1[x] = S [x].[03, 02, 01, 01]; +AES_Te2[x] = S [x].[01, 03, 02, 01]; +AES_Te3[x] = S [x].[01, 01, 03, 02]; +AES_Te4[x] = S [x].[01, 01, 01, 01]; + +AES_Td0[x] = Si[x].[0e, 09, 0d, 0b]; +AES_Td1[x] = Si[x].[0b, 0e, 09, 0d]; +AES_Td2[x] = Si[x].[0d, 0b, 0e, 09]; +AES_Td3[x] = Si[x].[09, 0d, 0b, 0e]; +AES_Td4[x] = Si[x].[01, 01, 01, 01]; +*/ + +extern const uint32_t AES_Te0[256 ], AES_Te1[256 ], AES_Te2[256 ], + AES_Te3[256 ], AES_Te4[256 ]; +extern const uint32_t AES_Td0[256 ], AES_Td1[256 ], AES_Td2[256 ], + AES_Td3[256 ], AES_Td4[256 ]; +#endif
util/aes.c +252 -252
718 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v4 7/7 target-i386: add AES-NI instructions
In reply to Aurelien Jarno--- disas/i386.c | 4 +- target-i386/cpu.c | 6 +-- target-i386/fpu_helper.c | 1 + target-i386/ops_sse.h | 87 ++++++++++++++++++++++++++++++++++++++++++ target-i386/ops_sse_header.h | 6 +++ target-i386/translate.c | 7 ++++ 6 files changed, 106 insertions(+), 5 deletions(-)
disas/i386.c +2 -2
@@ -1447,7 +1447,7 @@ static const unsigned char threebyte_0x38_uses_DATA_prefix[256] = {/* a0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* af */ /* b0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* bf */ /* c0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* cf */ -/* d0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* df */ +/* d0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,/* df */ /* e0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* ef */ /* f0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* ff */ /* ------------------------------- */
@@ -1519,7 +1519,7 @@ static const unsigned char threebyte_0x3a_uses_DATA_prefix[256] = {/* a0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* af */ /* b0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* bf */ /* c0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* cf */ -/* d0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* df */ +/* d0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,/* df */ /* e0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* ef */ /* f0 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* ff */ /* ------------------------------- */
target-i386/cpu.c +3 -3
@@ -390,13 +390,13 @@ typedef struct x86_def_t {#define TCG_EXT_FEATURES (CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | \ CPUID_EXT_MONITOR | CPUID_EXT_SSSE3 | CPUID_EXT_CX16 | \ CPUID_EXT_SSE41 | CPUID_EXT_SSE42 | CPUID_EXT_POPCNT | \ - CPUID_EXT_MOVBE | CPUID_EXT_HYPERVISOR) + CPUID_EXT_MOVBE | CPUID_EXT_AES | CPUID_EXT_HYPERVISOR)/* missing: CPUID_EXT_DTES64, CPUID_EXT_DSCPL, CPUID_EXT_VMX, CPUID_EXT_SMX, CPUID_EXT_EST, CPUID_EXT_TM2, CPUID_EXT_CID, CPUID_EXT_FMA, CPUID_EXT_XTPR, CPUID_EXT_PDCM, CPUID_EXT_PCID, CPUID_EXT_DCA, -CPUID_EXT_X2APIC, CPUID_EXT_TSC_DEADLINE_TIMER, CPUID_EXT_AES, -CPUID_EXT_XSAVE, CPUID_EXT_OSXSAVE, CPUID_EXT_AVX, CPUID_EXT_F16C, +CPUID_EXT_X2APIC, CPUID_EXT_TSC_DEADLINE_TIMER, CPUID_EXT_XSAVE, +CPUID_EXT_OSXSAVE, CPUID_EXT_AVX, CPUID_EXT_F16C, CPUID_EXT_RDRAND */ #define TCG_EXT2_FEATURES ((TCG_FEATURES & CPUID_EXT2_AMD_ALIASES) | \ CPUID_EXT2_NX | CPUID_EXT2_MMXEXT | CPUID_EXT2_RDTSCP | \
target-i386/fpu_helper.c +1 -0
@@ -20,6 +20,7 @@#include <math.h> #include "cpu.h" #include "helper.h" +#include "qemu/aes.h" #include "qemu/host-utils.h" #if !defined(CONFIG_USER_ONLY )
target-i386/ops_sse.h +87 -0
93 lines not on this page · raw message
target-i386/ops_sse_header.h +6 -0
@@ -338,6 +338,12 @@ DEF_HELPER_3(popcnt, tl, env, tl, i32)/* AES-NI op helpers */ #if SHIFT ==1 +DEF_HELPER_3(glue(aesdec, SUFFIX), void, env, Reg, Reg) +DEF_HELPER_3(glue(aesdeclast, SUFFIX), void, env, Reg, Reg) +DEF_HELPER_3(glue(aesenc, SUFFIX), void, env, Reg, Reg) +DEF_HELPER_3(glue(aesenclast, SUFFIX), void, env, Reg, Reg) +DEF_HELPER_3(glue(aesimc, SUFFIX), void, env, Reg, Reg) +DEF_HELPER_4(glue(aeskeygenassist, SUFFIX), void, env, Reg, Reg, i32) DEF_HELPER_4(glue(pclmulqdq, SUFFIX), void, env, Reg, Reg, i32)#endif
target-i386/translate.c +7 -0
@@ -3149,6 +3149,7 @@ struct SSEOpHelper_eppi {#define SSE41_SPECIAL { { NULL, SSE_SPECIAL }, CPUID_EXT_SSE41 }#define PCLMULQDQ_OP (x) { { NULL, gen_helper_ ## x ## _xmm }, \ CPUID_EXT_PCLMULQDQ } +#define AESNI_OP (x) { { NULL, gen_helper_ ## x ## _xmm }, CPUID_EXT_AES }static const struct SSEOpHelper_epp sse_op_table6[256 ] = { [0x00 ] =SSSE3_OP (pshufb),
@@ -3197,6 +3198,11 @@ static const struct SSEOpHelper_epp sse_op_table6[256] = { [0x3f] = SSE41_OP(pmaxud), [0x40] = SSE41_OP(pmulld), [0x41] = SSE41_OP(phminposuw), + [0xdb] = AESNI_OP(aesimc), + [0xdc] = AESNI_OP(aesenc), + [0xdd] = AESNI_OP(aesenclast), + [0xde] = AESNI_OP(aesdec), + [0xdf] = AESNI_OP(aesdeclast), };static const struct SSEOpHelper_eppi sse_op_table7[256 ] = {
@@ -3223,6 +3229,7 @@ static const struct SSEOpHelper_eppi sse_op_table7[256] = { [0x61] = SSE42_OP(pcmpestri), [0x62] = SSE42_OP(pcmpistrm), [0x63] = SSE42_OP(pcmpistri), + [0xdf] = AESNI_OP(aeskeygenassist), }; static void gen_sse(CPUX86State *env, DisasContext *s, int b,
Signature · 1 line
1.7.10.4
Quoted 2 lines · Aurelien Jarno
Changes v3 -> v4:
- Update dissassembler code to support these instructions.
r~