Skip to content

RFC target/i386/tcg: implement APX

Paolo Bonzini qemu-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest18 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18target/i386/tcg: move check bits out of validate_vextarget/i386/tcg/decode-new.c.inc+9 -180 replies
2/18target/i386/tcg: add APX support to XSAVE/XRSTORtarget/i386/cpu.h target/i386/helper.c target/i386/tcg/fpu_helper.c +2 more+83 -110 replies
3/18target/i386/tcg: treat VEX as disabling high-byte registerstarget/i386/tcg/translate.c+1 -10 replies
4/18target/i386/tcg: add definition for REX2 prefixtarget/i386/tcg/translate.c+2 -10 replies
5/18target/i386/tcg: mark XSAVE* as not allowing REX2target/i386/tcg/decode-new.c.inc target/i386/tcg/decode-new.h+13 -110 replies
6/18target/i386/tcg: decode REX2 prefixtarget/i386/tcg/decode-new.c.inc target/i386/tcg/translate.c+126 -100 replies
7/18target/i386/tcg: implement JMPABS instructiontarget/i386/tcg/decode-new.c.inc target/i386/tcg/decode-new.h+7 -00 replies
8/18target/i386/tcg: fetch modrm earlytarget/i386/tcg/decode-new.c.inc+50 -150 replies
9/18target/i386/tcg: move VEX validation earlytarget/i386/tcg/decode-new.c.inc+30 -240 replies
10/18target/i386/tcg: extend VEX.vvvv parsing for APXtarget/i386/tcg/decode-new.c.inc target/i386/tcg/translate.c+26 -130 replies
11/18target/i386/tcg: decode EVEX prefixtarget/i386/tcg/decode-new.c.inc target/i386/tcg/translate.c+81 -70 replies
12/18target/i386/tcg: add ZU writebacktarget/i386/tcg/decode-new.c.inc target/i386/tcg/decode-new.h target/i386/tcg/emit.c.inc+9 -00 replies
13/18target/i386/tcg: add decode functionality for APXtarget/i386/tcg/decode-new.c.inc target/i386/tcg/decode-new.h target/i386/tcg/translate.c+181 -80 replies
14/18target/i386/tcg: implement CCMP/CTESTtarget/i386/cpu.h target/i386/tcg/cc_helper.c target/i386/tcg/cc_helper_template.h.inc +3 more+238 -140 replies
15/18target/i386/tcg: undo IMUL memory load optimizationtarget/i386/tcg/decode-new.c.inc+1 -50 replies
16/18target/i386/tcg: decode APX instructionstarget/i386/helper.h target/i386/tcg/decode-new.c.inc target/i386/tcg/decode-new.h +2 more+320 -980 replies
17/18target/i386/tcg: mark APX as supportedconfigs/targets/x86_64-bsd-user.mak configs/targets/x86_64-linux-user.mak target/i386/cpu.c+15 -40 replies
18/18target/i386/tcg: optimize CCMPtarget/i386/tcg/emit.c.inc+56 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/18] target/i386/tcg: implement APX

This series implements APX support. This is little more than some Christmas time hacking, and I have tested it for now only on user mode emulation. The main reason to do this is actually to have some initial infrastructure for EVEX, without requiring all the complexity of AVX512. It also forces some changes that (hopefully) make QEMU's decoder align a bit more with what Intel processors actually do. These (patches 1, 4, 8, 9 in particular) could be extracted and committed separately, though at this point this would be something for 11.1 anyway.

There are relatively few *new* instructions (CCMP/CTEST, CFCMOV, PUSH2/POP2), all of them trivial except for CCMP/CTEST. Therefore, most of the new code is for decoding. The new data destination feature comes almost for free thanks to the existing support for BMI instructions, and variants such as no flags update and zero-upper are quite easy as well. For CCMP/CTEST, I tried to make them reasonably efficient, also thanks to the changes to AF/CF/OF computation that came over the past year, but that takes quite a few lines of code.

Don't expect any performance gains. APX binaries do produce about 1% fewer TCG ops, but they map to about 1% *more* assembly instructions, at least for x86-on-x86: that's because while the optimizer could already produce roughly the same ops as NDD or NF instructions, the new PUSH2/POP2 instructions include a stack alignment check that isn't there in non-APX code. I don't think it's worth wasting a precious HF_ bit for it, at least not until for 10 years or so.

Other than testing system emulation, the main decision to take is whether to treat VEX and EVEX maps as an extension of the regular maps, or just bite the bullet, copy them over to a new array and define them from scratch. There are some annoying differences already in APX (accepted prefixes and opcodes moved to a different spot) and there would be even more with AVX512, for example mask register instructions use opcodes in VEX map 1 that overlap with two-byte 0F opcodes.

I don't think I will have much time to work on this for a few months, since I did it just out of my own interest, but I thought I'd throw it out there for review.

Paolo

Paolo Bonzini (18):
target/i386/tcg: move check bits out of validate_vex target/i386/tcg: add APX support to XSAVE/XRSTOR target/i386/tcg: treat VEX as disabling high-byte registers target/i386/tcg: add definition for REX2 prefix target/i386/tcg: mark XSAVE* as not allowing REX2 target/i386/tcg: decode REX2 prefix target/i386/tcg: implement JMPABS instruction target/i386/tcg: fetch modrm early target/i386/tcg: move VEX validation early target/i386/tcg: extend VEX.vvvv parsing for APX target/i386/tcg: decode EVEX prefix target/i386/tcg: add ZU writeback target/i386/tcg: add decode functionality for APX target/i386/tcg: implement CCMP/CTEST target/i386/tcg: undo IMUL memory load optimization target/i386/tcg: decode APX instructions target/i386/tcg: mark APX as supported target/i386/tcg: optimize CCMP

 configs/targets/x86_64-bsd-user.mak      |   2 +-
 configs/targets/x86_64-linux-user.mak    |   2 +-
 target/i386/cpu.h                        |   8 +
 target/i386/helper.h                     |   1 +
 target/i386/tcg/decode-new.h             |  20 +
 target/i386/tcg/tcg-cpu.h                |  16 +-
 target/i386/tcg/cc_helper_template.h.inc |  11 +
 target/i386/cpu.c                        |  15 +-
 target/i386/helper.c                     |  11 +
 target/i386/tcg/cc_helper.c              |  10 +
 target/i386/tcg/excp_helper.c            |   5 +
 target/i386/tcg/fpu_helper.c             |  59 +-
 target/i386/tcg/tcg-cpu.c                |   5 +-
 target/i386/tcg/translate.c              | 106 ++-
 target/i386/tcg/decode-new.c.inc         | 937 ++++++++++++++++++-----
 target/i386/tcg/emit.c.inc               | 243 +++++-
 16 files changed, 1226 insertions(+), 225 deletions(-)
Signature · 1 line
2.52.0