Misc changes for 2024-06-22
Subsystems (2)
The following changes since commit 223696363bb117241ad9c2facbff0c474afa4104:
Merge tag 'edgar/xilinx-queue-2024-06-17.for-upstream' of https://gitlab.com/edgar.iglesias/qemu into staging (2024-06-18 13:08:01 -0700)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to b9b51004033983589e00fb4697f620b903cfcf0e:
exec: don't use void* in pointer arithmetic in headers (2024-06-21 18:32:18 +0200)
----------------------------------------------------------------
* configure: detect --cpu=mipsisa64r6
* target/i386: decode address before going back to translate.c
* meson: allow configuring the x86-64 baseline
* meson: remove dead optimization option
* exec: small changes to allow compilation with C++ in Android emulator
----------------------------------------------------------------
Paolo Bonzini (21):
configure: detect --cpu=mipsisa64r6
target/i386: fix CC_OP dump
target/i386: use cpu_cc_dst for CC_OP_POPCNT target/i386: give CC_OP_POPCNT low bits corresponding to MO_TL target/i386: convert bit test instructions to new decoder target/i386: try not to force EFLAGS computation for CC_OP_ADOX/ADCX target/i386: decode address before going back to translate.c target/i386: convert CMPXCHG8B/CMPXCHG16B to new decoder target/i386: do not check PREFIX_LOCK in old-style decoder target/i386: list instructions still in translate.c target/i386: assert that cc_op* and pc_save are preserved target/i386: remove gen_ext_tl
Revert "host/i386: assume presence of POPCNT"
Revert "host/i386: assume presence of SSSE3"
Revert "host/i386: assume presence of SSE2"
meson: allow configuring the x86-64 baseline
meson: remove dead optimization option
block: make assertion more generic
block: do not check bdrv_file_open
block: remove separate bdrv_file_open callback
block: rename former bdrv_file_open callbacks
Roman Kiryanov (2):
exec: avoid using C++ keywords in function parameters
exec: don't use void* in pointer arithmetic in headers
configure | 2 +- meson.build | 54 +++-- host/include/i386/host/cpuinfo.h | 2 + include/block/block_int-common.h | 3 - include/exec/memory.h | 6 +- target/i386/cpu.h | 13 +- target/i386/tcg/decode-new.h | 19 +- tcg/i386/tcg-target.h | 5 +- block.c | 17 +- block/blkdebug.c | 2 +- block/blkio.c | 8 +- block/blkverify.c | 2 +- block/curl.c | 8 +- block/file-posix.c | 8 +- block/file-win32.c | 4 +- block/gluster.c | 6 +- block/iscsi.c | 4 +- block/nbd.c | 6 +- block/nfs.c | 2 +- block/null.c | 8 +- block/nvme.c | 8 +- block/rbd.c | 3 +- block/ssh.c | 6 +- block/vvfat.c | 2 +- target/i386/cpu-dump.c | 101 ++++---- target/i386/tcg/cc_helper.c | 2 +- target/i386/tcg/translate.c | 492 ++++++++------------------------------- util/bufferiszero.c | 4 +- util/cpuinfo-i386.c | 6 +- target/i386/tcg/decode-new.c.inc | 136 ++++++++--- target/i386/tcg/emit.c.inc | 249 +++++++++++++++++++- meson_options.txt | 5 +- scripts/meson-buildoptions.sh | 6 +- 33 files changed, 618 insertions(+), 581 deletions(-)
Signature · 1 line
2.45.2
[PULL 12/23] target/i386: remove gen_ext_tl
With the introduction of tcg_gen_ext_tl, most uses can be converted directly because they do not have a NULL destination. tcg_gen_ext_tl is able to drop no-ops like "tcg_gen_ext_tl(tcgv, tcgv, MO_TL)" just fine, and the only thing that gen_ext_tl was adding on top was avoiding the creation of a useless temporary. This can be done in the only place where it matters, which is gen_op_j_ecx.
--- target/i386/tcg/translate.c | 41 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 24 deletions(-)
target/i386/tcg/translate.c +17 -24
@@ -697,23 +697,16 @@ static inline TCGv gen_compute_Dshift(DisasContext *s, MemOp ot)return dshift; }; -static TCGv gen_ext_tl (TCGv dst,TCGv src,MemOp size,bool sign) -{ -if (size ==MO_TL ) { -return src; - } -if (!dst) { - dst =tcg_temp_new (); - } -tcg_gen_ext_tl (dst, src, size | (sign ?MO_SIGN :0 )); -return dst; -} -static void gen_op_j_ecx (DisasContext *s,TCGCond cond,TCGLabel *label1) { -TCGv tmp =gen_ext_tl (NULL , cpu_regs[R_ECX ], s->aflag, false); - -tcg_gen_brcondi_tl (cond, tmp,0 , label1); +TCGv lhs; +if (s->aflag ==MO_TL ) { + lhs = cpu_regs[R_ECX ]; + }else { + lhs =tcg_temp_new (); +tcg_gen_ext_tl (lhs, cpu_regs[R_ECX ], s->aflag); + } +tcg_gen_brcondi_tl (cond, lhs,0 , label1); }static inline void gen_op_jz_ecx (DisasContext *s,TCGLabel *label1)
@@ -886,16 +879,16 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) case CC_OP_SUBB ... CC_OP_SUBQ:/* (DATA_TYPE)CC_SRCT < (DATA_TYPE)CC_SRC */ size = s->cc_op -CC_OP_SUBB ; -gen_ext_tl (s->cc_srcT, s->cc_srcT, size, false); -gen_ext_tl (cpu_cc_src, cpu_cc_src, size, false); +tcg_gen_ext_tl (s->cc_srcT, s->cc_srcT, size); +tcg_gen_ext_tl (cpu_cc_src, cpu_cc_src, size);return (CCPrepare ) { .cond =TCG_COND_LTU , .reg = s->cc_srcT, .reg2 = cpu_cc_src, .use_reg2 = true }; case CC_OP_ADDB ... CC_OP_ADDQ:/* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ size = s->cc_op -CC_OP_ADDB ; -gen_ext_tl (cpu_cc_dst, cpu_cc_dst, size, false); -gen_ext_tl (cpu_cc_src, cpu_cc_src, size, false); +tcg_gen_ext_tl (cpu_cc_dst, cpu_cc_dst, size); +tcg_gen_ext_tl (cpu_cc_src, cpu_cc_src, size);return (CCPrepare ) { .cond =TCG_COND_LTU , .reg = cpu_cc_dst, .reg2 = cpu_cc_src, .use_reg2 = true };
@@ -920,7 +913,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) case CC_OP_BMILGB ... CC_OP_BMILGQ: size = s->cc_op -CC_OP_BMILGB ; -gen_ext_tl (cpu_cc_src, cpu_cc_src, size, false); +tcg_gen_ext_tl (cpu_cc_src, cpu_cc_src, size);return (CCPrepare ) { .cond =TCG_COND_EQ , .reg = cpu_cc_src };case CC_OP_ADCX :
@@ -1050,8 +1043,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg) size = s->cc_op -CC_OP_SUBB ;switch (jcc_op) {case JCC_BE : -gen_ext_tl (s->cc_srcT, s->cc_srcT, size, false); -gen_ext_tl (cpu_cc_src, cpu_cc_src, size, false); +tcg_gen_ext_tl (s->cc_srcT, s->cc_srcT, size); +tcg_gen_ext_tl (cpu_cc_src, cpu_cc_src, size); cc = (CCPrepare ) { .cond =TCG_COND_LEU , .reg = s->cc_srcT, .reg2 = cpu_cc_src, .use_reg2 = true };break ;
@@ -1061,8 +1054,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg)case JCC_LE : cond =TCG_COND_LE ; fast_jcc_l: -gen_ext_tl (s->cc_srcT, s->cc_srcT, size, true); -gen_ext_tl (cpu_cc_src, cpu_cc_src, size, true); +tcg_gen_ext_tl (s->cc_srcT, s->cc_srcT, size |MO_SIGN ); +tcg_gen_ext_tl (cpu_cc_src, cpu_cc_src, size |MO_SIGN ); cc = (CCPrepare ) { .cond = cond, .reg = s->cc_srcT, .reg2 = cpu_cc_src, .use_reg2 = true };break ;
Signature · 1 line
2.45.2
[PULL 03/23] target/i386: use cpu_cc_dst for CC_OP_POPCNT
In reply to Paolo BonziniIt is the only CCOp, among those that compute ZF from one of the cc_op_* registers, that uses cpu_cc_src. Do not make it the odd one off, instead use cpu_cc_dst like the others.
--- target/i386/cpu.h | 2 +- target/i386/tcg/cc_helper.c | 2 +- target/i386/tcg/translate.c | 4 ++-- target/i386/tcg/emit.c.inc | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
target/i386/cpu.h +1 -1
@@ -1332,7 +1332,7 @@ typedef enum {CC_OP_BMILGQ ,CC_OP_CLR ,/* Z set, all other flags clear. */ -CC_OP_POPCNT ,/* Z via CC_SRC, all other flags clear. */ +CC_OP_POPCNT ,/* Z via CC_DST, all other flags clear. */ CC_OP_NB , } CCOp;
target/i386/tcg/cc_helper.c +1 -1
@@ -107,7 +107,7 @@ target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1,case CC_OP_CLR :return CC_Z |CC_P ;case CC_OP_POPCNT : -return src1 ?0 :CC_Z ; +return dst ?0 :CC_Z ;case CC_OP_MULB :return compute_all_mulb (dst, src1);
target/i386/tcg/translate.c +2 -2
@@ -324,7 +324,7 @@ static const uint8_t cc_op_live[CC_OP_NB] = { [CC_OP_ADOX] = USES_CC_SRC | USES_CC_SRC2, [CC_OP_ADCOX] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, [CC_OP_CLR] = 0, - [CC_OP_POPCNT] = USES_CC_SRC, + [CC_OP_POPCNT] = USES_CC_DST, };static void set_cc_op_1 (DisasContext *s,CCOp op,bool dirty)
@@ -1020,7 +1020,7 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg)case CC_OP_CLR :return (CCPrepare ) { .cond =TCG_COND_ALWAYS };case CC_OP_POPCNT : -return (CCPrepare ) { .cond =TCG_COND_EQ , .reg = cpu_cc_src }; +return (CCPrepare ) { .cond =TCG_COND_EQ , .reg = cpu_cc_dst };default : {MemOp size = (s->cc_op -CC_OP_ADDB ) &3 ;
target/i386/tcg/emit.c.inc +2 -2
@@ -2804,10 +2804,10 @@ static void gen_POPA(DisasContext *s, X86DecodedInsn *decode) static void gen_POPCNT(DisasContext *s, X86DecodedInsn *decode) { - decode->cc_src = tcg_temp_new(); + decode->cc_dst = tcg_temp_new(); decode->cc_op = CC_OP_POPCNT; - tcg_gen_mov_tl(decode->cc_src, s->T0); + tcg_gen_mov_tl(decode->cc_dst, s->T0); tcg_gen_ctpop_tl(s->T0, s->T0); }
Signature · 1 line
2.45.2
[PULL 04/23] target/i386: give CC_OP_POPCNT low bits corresponding to MO_TL
In reply to Paolo BonziniHandle it like the other arithmetic cc_ops. This simplifies a bit the implementation of bit test instructions.
--- target/i386/cpu.h | 13 +++++++++++-- target/i386/tcg/translate.c | 3 +-- 2 files changed, 12 insertions(+), 4 deletions(-)
target/i386/cpu.h +11 -2
@@ -1275,6 +1275,7 @@ typedef enum {CC_OP_ADCX ,/* CC_DST = C, CC_SRC = rest. */ CC_OP_ADOX ,/* CC_SRC2 = O, CC_SRC = rest. */ CC_OP_ADCOX ,/* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ +CC_OP_CLR ,/* Z and P set, all other flags clear. */ CC_OP_MULB ,/* modify all flags, C, O = (CC_SRC != 0) */ CC_OP_MULW,
@@ -1331,8 +1332,16 @@ typedef enum {CC_OP_BMILGL ,CC_OP_BMILGQ , -CC_OP_CLR ,/* Z set, all other flags clear. */ -CC_OP_POPCNT ,/* Z via CC_DST, all other flags clear. */ +/* +* Note that only CC_OP_POPCNT (i.e. the one with MO_TL size) +* is used or implemented, because the translation needs +* to zero-extend CC_DST anyway. +*/ +CC_OP_POPCNTB__ ,/* Z via CC_DST, all other flags clear. */ +CC_OP_POPCNTW__ , +CC_OP_POPCNTL__ , +CC_OP_POPCNTQ__ , +CC_OP_POPCNT =sizeof (target_ulong) ==8 ?CC_OP_POPCNTQ__ :CC_OP_POPCNTL__ ,CC_OP_NB , } CCOp;
target/i386/tcg/translate.c +1 -2
@@ -1019,8 +1019,6 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg) .imm = CC_Z };case CC_OP_CLR :return (CCPrepare ) { .cond =TCG_COND_ALWAYS }; -case CC_OP_POPCNT : -return (CCPrepare ) { .cond =TCG_COND_EQ , .reg = cpu_cc_dst };default : {MemOp size = (s->cc_op -CC_OP_ADDB ) &3 ;
@@ -3177,6 +3175,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) case CC_OP_SHLB ... CC_OP_SHLQ: case CC_OP_SARB ... CC_OP_SARQ: case CC_OP_BMILGB ... CC_OP_BMILGQ: +case CC_OP_POPCNT :/* Z was going to be computed from the non-zero status of CC_DST. We can get that same Z value (and the new C value) by leaving CC_DST alone, setting CC_SRC, and using a CC_OP_SAR of the
Signature · 1 line
2.45.2
[PULL 07/23] target/i386: decode address before going back to translate.c
In reply to Paolo BonziniThere are now relatively few unconverted opcodes in translate.c (there are 13 of them including 8 for x87), and all of them have the same format with a mod/rm byte and no immediate. A good next step is to remove the early bail out to disas_insn_x87/disas_insn_old, instead giving these legacy translator functions the same prototype as the other gen_* functions.
To do this, the X86DecodeInsn can be passed down to the places that used to fetch address bytes from the instruction stream. To make sure that everything is done cleanly, the CPUX86State* argument is removed.
As part of the unification, the gen_lea_modrm() name is now free, so rename gen_load_ea() to gen_lea_modrm(). This is as good a name and it makes the changes to translate.c easier to review.
--- target/i386/tcg/decode-new.h | 14 ++- target/i386/tcg/translate.c | 152 +++++++++++++------------------ target/i386/tcg/decode-new.c.inc | 53 ++++++----- target/i386/tcg/emit.c.inc | 2 +- 4 files changed, 103 insertions(+), 118 deletions(-)
target/i386/tcg/decode-new.h +12 -2
@@ -264,12 +264,13 @@ typedef enum X86VEXSpecial {typedef struct X86OpEntry X86OpEntry ;typedef struct X86DecodedInsn X86DecodedInsn ; +struct DisasContext ;/* Decode function for multibyte opcodes. */ -typedef void (*X86DecodeFunc )(DisasContext *s,CPUX86State *env,X86OpEntry *entry,uint8_t *b); +typedef void (*X86DecodeFunc )(struct DisasContext *s,CPUX86State *env,X86OpEntry *entry,uint8_t *b);/* Code generation function. */ -typedef void (*X86GenFunc )(DisasContext *s,X86DecodedInsn *decode); +typedef void (*X86GenFunc )(struct DisasContext *s,X86DecodedInsn *decode);struct X86OpEntry {/* Based on the is_decode flags. */
@@ -316,6 +317,14 @@ typedef struct X86DecodedOp { }; } X86DecodedOp; +typedef struct AddressParts { +int def_seg; +int base; +int index; +int scale; +target_long disp; +}AddressParts ; +struct X86DecodedInsn {X86OpEntry e;X86DecodedOp op[3 ];
@@ -333,3 +342,4 @@ struct X86DecodedInsn {uint8_t b; }; +static void gen_lea_modrm (struct DisasContext *s,X86DecodedInsn *decode);
target/i386/tcg/translate.c +62 -90
504 lines not on this page · raw message
target/i386/tcg/decode-new.c.inc +28 -25
95 lines not on this page · raw message
target/i386/tcg/emit.c.inc +1 -1
@@ -73,7 +73,7 @@ static void gen_NM_exception(DisasContext *s) gen_exception(s, EXCP07_PREX); } -static void gen_load_ea(DisasContext *s, X86DecodedInsn *decode) +static void gen_lea_modrm(DisasContext *s, X86DecodedInsn *decode) { AddressParts *mem = &decode->mem; TCGv ea;
Signature · 1 line
2.45.2
[PULL 19/23] block: do not check bdrv_file_open
In reply to Paolo BonziniThe set of BlockDrivers that have .bdrv_file_open coincides with those that have .protocol_name and guess what---checking drv->bdrv_file_open is done to see if the driver is a protocol. So check drv->protocol_name instead.
--- block.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
block.c +5 -6
@@ -926,7 +926,6 @@ BlockDriver *bdrv_find_protocol(const char *filename,int i;GLOBAL_STATE_CODE (); -/* TODO Drivers without bdrv_file_open must be specified explicitly */ /* * XXX(hch): we really should not let host device detection
@@ -1983,7 +1982,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, open_flags =bdrv_open_flags (bs, bs->open_flags); node_name =qemu_opt_get (opts,"node-name" ); -assert (!drv->bdrv_file_open || file ==NULL ); +assert (!drv->protocol_name || file ==NULL ); ret =bdrv_open_driver (bs, drv, node_name, options, open_flags, errp);if (ret <0 ) { goto fail_opts;
@@ -2084,7 +2083,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, }/* If the user has explicitly specified the driver, this choice should * override the BDRV_O_PROTOCOL flag */ - protocol = drv->bdrv_file_open; + protocol = drv->protocol_name; }if (protocol) {
@@ -4123,7 +4122,7 @@ bdrv_open_inherit(const char *filename, const char *reference, QDict *options, }/* BDRV_O_PROTOCOL must be set iff a protocol BDS is about to be created */ -assert (!!(flags &BDRV_O_PROTOCOL ) == !!drv->bdrv_file_open); +assert (!!(flags &BDRV_O_PROTOCOL ) == !!drv->protocol_name);/* file must be NULL if a protocol BDS is about to be created * (the inverse results in an error message from bdrv_open_common()) */ assert (!(flags &BDRV_O_PROTOCOL ) || !file);
@@ -5971,7 +5970,7 @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs)return drv->bdrv_co_get_allocated_file_size (bs); } -if (drv->bdrv_file_open) { +if (drv->protocol_name) {/* * Protocol drivers default to -ENOTSUP (most of their data is * not stored in any of their children (if they even have any),
@@ -8030,7 +8029,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)* Both of these conditions are represented by generate_json_filename. */ if (primary_child_bs->exact_filename[0 ] && - primary_child_bs->drv->bdrv_file_open && + primary_child_bs->drv->protocol_name && !drv->is_filter && !generate_json_filename) {strcpy (bs->exact_filename, primary_child_bs->exact_filename);
Signature · 1 line
2.45.2
[PULL 01/23] configure: detect --cpu=mipsisa64r6
In reply to Paolo BonziniTreat it as a MIPS64 machine.
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -450,7 +450,7 @@ case "$cpu" in linux_arch=loongarch ;; - mips64*) + mips64*|mipsisa64*) cpu=mips64 host_arch=mips linux_arch=mips
Signature · 1 line
2.45.2
[PULL 11/23] target/i386: assert that cc_op* and pc_save are preserved
In reply to Paolo BonziniNow all decoding has been done before any code generation. There is no need anymore to save and restore cc_op* and pc_save but, for the time being, assert that this is indeed the case.
--- target/i386/tcg/translate.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
target/i386/tcg/translate.c +3 -9
@@ -3709,15 +3709,9 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)case 2 :/* Restore state that may affect the next instruction. */ dc->pc = dc->base.pc_next; -/* -* TODO: These save/restore can be removed after the table-based -* decoder is complete; we will be decoding the insn completely -* before any code generation that might affect these variables. -*/ - dc->cc_op_dirty = orig_cc_op_dirty; - dc->cc_op = orig_cc_op; - dc->pc_save = orig_pc_save; -/* END TODO */ +assert (dc->cc_op_dirty == orig_cc_op_dirty); +assert (dc->cc_op == orig_cc_op); +assert (dc->pc_save == orig_pc_save); dc->base.num_insns--;tcg_remove_ops_after (dc->prev_insn_end); dc->base.insn_start = dc->prev_insn_start;
Signature · 1 line
2.45.2
[PULL 05/23] target/i386: convert bit test instructions to new decoder
In reply to Paolo Bonzini--- target/i386/tcg/decode-new.h | 3 + target/i386/tcg/translate.c | 147 +----------------------------- target/i386/tcg/decode-new.c.inc | 40 ++++++--- target/i386/tcg/emit.c.inc | 149 ++++++++++++++++++++++++++++++- 4 files changed, 181 insertions(+), 158 deletions(-)
target/i386/tcg/decode-new.h +3 -0
@@ -190,6 +190,9 @@ typedef enum X86InsnSpecial {/* Always locked if it has a memory operand (XCHG) */ X86_SPECIAL_Locked, +/* Like HasLock, but also operand 2 provides bit displacement into memory. */ + X86_SPECIAL_BitTest, +/* Do not load effective address in s->A0 */ X86_SPECIAL_NoLoadEA,
target/i386/tcg/translate.c +1 -146
165 lines not on this page · raw message
target/i386/tcg/decode-new.c.inc +30 -10
@@ -205,6 +205,7 @@ #define sextT0 .special = X86_SPECIAL_SExtT0, #define zextT0 .special = X86_SPECIAL_ZExtT0, #define op0_Mw .special = X86_SPECIAL_Op0_Mw, +#define btEvGv .special = X86_SPECIAL_BitTest, #define vex1 .vex_class = 1, #define vex1_rep3 .vex_class = 1, .vex_special = X86_VEX_REPScalar,
@@ -269,6 +270,24 @@ static inline const X86OpEntry *decode_by_prefix(DisasContext *s, const X86OpEnt } } +static void decode_group8(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b) +{ + static const X86GenFunc group8_gen[8] = { + NULL, NULL, NULL, NULL, + gen_BT, gen_BTS, gen_BTR, gen_BTC, + }; + int op = (get_modrm(s, env) >> 3) & 7; + entry->gen = group8_gen[op]; + if (op == 4) { + /* prevent writeback and LOCK for BT */ + entry->op1 = entry->op0; + entry->op0 = X86_TYPE_None; + entry->s0 = X86_SIZE_None; + } else { + entry->special = X86_SPECIAL_HasLock; + } +} + static void decode_group15(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b) { static const X86OpEntry group15_reg[8] = {
@@ -1162,12 +1181,14 @@ static const X86OpEntry opcodes_0F[256] = { [0xa0] = X86_OP_ENTRYr(PUSH, FS, w), [0xa1] = X86_OP_ENTRYw(POP, FS, w), [0xa2] = X86_OP_ENTRY0(CPUID), + [0xa3] = X86_OP_ENTRYrr(BT, E,v, G,v, btEvGv), [0xa4] = X86_OP_ENTRY4(SHLD, E,v, 2op,v, G,v), [0xa5] = X86_OP_ENTRY3(SHLD, E,v, 2op,v, G,v), [0xb0] = X86_OP_ENTRY2(CMPXCHG,E,b, G,b, lock), [0xb1] = X86_OP_ENTRY2(CMPXCHG,E,v, G,v, lock), [0xb2] = X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), + [0xb3] = X86_OP_ENTRY2(BTR, E,v, G,v, btEvGv), [0xb4] = X86_OP_ENTRY3(LFS, G,v, EM,p, None, None), [0xb5] = X86_OP_ENTRY3(LGS, G,v, EM,p, None, None), [0xb6] = X86_OP_ENTRY3(MOV, G,v, E,b, None, None, zextT0), /* MOVZX */
@@ -1294,6 +1315,7 @@ static const X86OpEntry opcodes_0F[256] = { [0xa8] = X86_OP_ENTRYr(PUSH, GS, w), [0xa9] = X86_OP_ENTRYw(POP, GS, w), [0xaa] = X86_OP_ENTRY0(RSM, chk(smm) svm(RSM)), + [0xab] = X86_OP_ENTRY2(BTS, E,v, G,v, btEvGv), [0xac] = X86_OP_ENTRY4(SHRD, E,v, 2op,v, G,v), [0xad] = X86_OP_ENTRY3(SHRD, E,v, 2op,v, G,v), [0xae] = X86_OP_GROUP0(group15),
@@ -1306,6 +1328,8 @@ static const X86OpEntry opcodes_0F[256] = { [0xb8] = X86_OP_GROUP0(0FB8), /* decoded as modrm, which is visible as a difference between page fault and #UD */ [0xb9] = X86_OP_ENTRYr(UD, nop,v), /* UD1 */ + [0xba] = X86_OP_GROUP2(group8, E,v, I,b), + [0xbb] = X86_OP_ENTRY2(BTC, E,v, G,v, btEvGv), [0xbc] = X86_OP_GROUP0(0FBC), [0xbd] = X86_OP_GROUP0(0FBD), [0xbe] = X86_OP_ENTRY3(MOV, G,v, E,b, None, None, sextT0), /* MOVSX */
@@ -2424,6 +2448,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) CPUX86State *env = cpu_env(cpu); X86DecodedInsn decode; X86DecodeFunc decode_func = decode_root; + bool accept_lock = false; uint8_t cc_live, b; s->pc = s->base.pc_next;
@@ -2597,10 +2622,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) switch (b) { case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ - case 0xa3: /* bt */ - case 0xab: /* bts */ - case 0xb3: /* btr */ - case 0xba ... 0xbb: /* grp8, btc */ case 0xc7: /* grp9 */ disas_insn_old(s, cpu, b + 0x100); return;
@@ -2662,9 +2683,10 @@ static void disas_insn(DisasContext *s, CPUState *cpu) if (decode.op[0].has_ea) { s->prefix |= PREFIX_LOCK; } - decode.e.special = X86_SPECIAL_HasLock; /* fallthrough */ case X86_SPECIAL_HasLock: + case X86_SPECIAL_BitTest: + accept_lock = decode.op[0].has_ea; break; case X86_SPECIAL_Op0_Rd:
@@ -2706,10 +2728,8 @@ static void disas_insn(DisasContext *s, CPUState *cpu) break; } - if (s->prefix & PREFIX_LOCK) { - if (decode.e.special != X86_SPECIAL_HasLock || !decode.op[0].has_ea) { - goto illegal_op; - } + if ((s->prefix & PREFIX_LOCK) && !accept_lock) { + goto illegal_op; } if (!validate_vex(s, &decode)) {
@@ -2755,7 +2775,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) if (decode.e.special != X86_SPECIAL_NoLoadEA && (decode.op[0].has_ea || decode.op[1].has_ea || decode.op[2].has_ea)) { - gen_load_ea(s, &decode.mem, decode.e.vex_class == 12); + gen_load_ea(s, &decode); } if (s->prefix & PREFIX_LOCK) { gen_load(s, &decode, 2, s->T1);
target/i386/tcg/emit.c.inc +147 -2
168 lines not on this page · raw message
Signature · 1 line
2.45.2
[PULL 14/23] Revert "host/i386: assume presence of SSSE3"
In reply to Paolo BonziniThis reverts commit 433cd6d94a8256af70a5200f236dc8047c3c1468. The x86-64 instruction set can now be tuned down to x86-64 v1 or i386 Pentium Pro.
--- util/cpuinfo-i386.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
util/cpuinfo-i386.c +2 -2
@@ -38,8 +38,8 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info |= (c & bit_POPCNT ?CPUINFO_POPCNT :0 ); info |= (c & bit_PCLMUL ?CPUINFO_PCLMUL :0 ); -/* NOTE: our AES support requires SSSE3 (PSHUFB) as well. */ - info |= (c & bit_AES) ?CPUINFO_AES :0 ; +/* Our AES support requires PSHUFB as well. */ + info |= ((c & bit_AES) && (c & bit_SSSE3) ?CPUINFO_AES :0 );/* For AVX features, we must check available and usable. */ if ((c & bit_AVX) && (c & bit_OSXSAVE)) {
Signature · 1 line
2.45.2
[PULL 20/23] block: remove separate bdrv_file_open callback
In reply to Paolo Bonzinibdrv_file_open and bdrv_open are completely equivalent, they are never checked except to see which one to invoke. So merge them into a single one.
--- include/block/block_int-common.h | 3 --- block.c | 4 +--- block/blkdebug.c | 2 +- block/blkio.c | 2 +- block/blkverify.c | 2 +- block/curl.c | 8 ++++---- block/file-posix.c | 8 ++++---- block/file-win32.c | 4 ++-- block/gluster.c | 6 +++--- block/iscsi.c | 4 ++-- block/nbd.c | 6 +++--- block/nfs.c | 2 +- block/null.c | 4 ++-- block/nvme.c | 2 +- block/rbd.c | 3 ++- block/ssh.c | 2 +- block/vvfat.c | 2 +- 17 files changed, 30 insertions(+), 34 deletions(-)
include/block/block_int-common.h +0 -3
@@ -248,9 +248,6 @@ struct BlockDriver { int GRAPH_UNLOCKED_PTR (*bdrv_open)(BlockDriverState *bs,QDict *options,int flags,Error **errp); -/* Protocol drivers should implement this instead of bdrv_open */ - int GRAPH_UNLOCKED_PTR (*bdrv_file_open)( -BlockDriverState *bs,QDict *options,int flags,Error **errp);void (*bdrv_close)(BlockDriverState *bs); int coroutine_fn GRAPH_UNLOCKED_PTR (*bdrv_co_create)(
block.c +1 -3
@@ -1655,9 +1655,7 @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, bs->opaque =g_malloc0 (drv->instance_size);assert (!drv->bdrv_needs_filename || bs->filename[0 ]); -if (drv->bdrv_file_open) { - ret = drv->bdrv_file_open (bs, options, open_flags, &local_err); - }else if (drv->bdrv_open) { +if (drv->bdrv_open) { ret = drv->bdrv_open (bs, options, open_flags, &local_err); }else { ret =0 ;
block/blkdebug.c +1 -1
@@ -1073,7 +1073,7 @@ static BlockDriver bdrv_blkdebug = { .is_filter = true, .bdrv_parse_filename = blkdebug_parse_filename, - .bdrv_file_open = blkdebug_open, + .bdrv_open = blkdebug_open, .bdrv_close = blkdebug_close, .bdrv_reopen_prepare = blkdebug_reopen_prepare, .bdrv_child_perm = blkdebug_child_perm,
block/blkio.c +1 -1
@@ -1088,7 +1088,7 @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp)*/ #define BLKIO_DRIVER_COMMON \ .instance_size = sizeof(BDRVBlkioState), \ - .bdrv_file_open = blkio_file_open, \ + .bdrv_open = blkio_file_open, \ .bdrv_close = blkio_close, \ .bdrv_co_getlength = blkio_co_getlength, \ .bdrv_co_truncate = blkio_truncate, \
block/blkverify.c +1 -1
@@ -321,7 +321,7 @@ static BlockDriver bdrv_blkverify = { .instance_size = sizeof(BDRVBlkverifyState), .bdrv_parse_filename = blkverify_parse_filename, - .bdrv_file_open = blkverify_open, + .bdrv_open = blkverify_open, .bdrv_close = blkverify_close, .bdrv_child_perm = bdrv_default_perms, .bdrv_co_getlength = blkverify_co_getlength,
block/curl.c +4 -4
@@ -1034,7 +1034,7 @@ static BlockDriver bdrv_http = { .instance_size = sizeof(BDRVCURLState), .bdrv_parse_filename = curl_parse_filename, - .bdrv_file_open = curl_open, + .bdrv_open = curl_open, .bdrv_close = curl_close, .bdrv_co_getlength = curl_co_getlength,
@@ -1053,7 +1053,7 @@ static BlockDriver bdrv_https = { .instance_size = sizeof(BDRVCURLState), .bdrv_parse_filename = curl_parse_filename, - .bdrv_file_open = curl_open, + .bdrv_open = curl_open, .bdrv_close = curl_close, .bdrv_co_getlength = curl_co_getlength,
@@ -1072,7 +1072,7 @@ static BlockDriver bdrv_ftp = { .instance_size = sizeof(BDRVCURLState), .bdrv_parse_filename = curl_parse_filename, - .bdrv_file_open = curl_open, + .bdrv_open = curl_open, .bdrv_close = curl_close, .bdrv_co_getlength = curl_co_getlength,
@@ -1091,7 +1091,7 @@ static BlockDriver bdrv_ftps = { .instance_size = sizeof(BDRVCURLState), .bdrv_parse_filename = curl_parse_filename, - .bdrv_file_open = curl_open, + .bdrv_open = curl_open, .bdrv_close = curl_close, .bdrv_co_getlength = curl_co_getlength,
block/file-posix.c +4 -4
@@ -3886,7 +3886,7 @@ BlockDriver bdrv_file = { .bdrv_needs_filename = true, .bdrv_probe = NULL, /* no probe for protocols */ .bdrv_parse_filename = raw_parse_filename, - .bdrv_file_open = raw_open, + .bdrv_open = raw_open, .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort,
@@ -4257,7 +4257,7 @@ static BlockDriver bdrv_host_device = { .bdrv_needs_filename = true, .bdrv_probe_device = hdev_probe_device, .bdrv_parse_filename = hdev_parse_filename, - .bdrv_file_open = hdev_open, + .bdrv_open = hdev_open, .bdrv_close = raw_close, .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit,
@@ -4396,7 +4396,7 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_needs_filename = true, .bdrv_probe_device = cdrom_probe_device, .bdrv_parse_filename = cdrom_parse_filename, - .bdrv_file_open = cdrom_open, + .bdrv_open = cdrom_open, .bdrv_close = raw_close, .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit,
@@ -4522,7 +4522,7 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_needs_filename = true, .bdrv_probe_device = cdrom_probe_device, .bdrv_parse_filename = cdrom_parse_filename, - .bdrv_file_open = cdrom_open, + .bdrv_open = cdrom_open, .bdrv_close = raw_close, .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit,
block/file-win32.c +2 -2
@@ -746,7 +746,7 @@ BlockDriver bdrv_file = { .instance_size = sizeof(BDRVRawState), .bdrv_needs_filename = true, .bdrv_parse_filename = raw_parse_filename, - .bdrv_file_open = raw_open, + .bdrv_open = raw_open, .bdrv_refresh_limits = raw_probe_alignment, .bdrv_close = raw_close, .bdrv_co_create_opts = raw_co_create_opts,
@@ -920,7 +920,7 @@ static BlockDriver bdrv_host_device = { .bdrv_needs_filename = true, .bdrv_parse_filename = hdev_parse_filename, .bdrv_probe_device = hdev_probe_device, - .bdrv_file_open = hdev_open, + .bdrv_open = hdev_open, .bdrv_close = raw_close, .bdrv_refresh_limits = hdev_refresh_limits,
block/gluster.c +3 -3
@@ -1551,7 +1551,7 @@ static BlockDriver bdrv_gluster = { .format_name = "gluster", .protocol_name = "gluster", .instance_size = sizeof(BDRVGlusterState), - .bdrv_file_open = qemu_gluster_open, + .bdrv_open = qemu_gluster_open, .bdrv_reopen_prepare = qemu_gluster_reopen_prepare, .bdrv_reopen_commit = qemu_gluster_reopen_commit, .bdrv_reopen_abort = qemu_gluster_reopen_abort,
@@ -1580,7 +1580,7 @@ static BlockDriver bdrv_gluster_tcp = { .format_name = "gluster", .protocol_name = "gluster+tcp", .instance_size = sizeof(BDRVGlusterState), - .bdrv_file_open = qemu_gluster_open, + .bdrv_open = qemu_gluster_open, .bdrv_reopen_prepare = qemu_gluster_reopen_prepare, .bdrv_reopen_commit = qemu_gluster_reopen_commit, .bdrv_reopen_abort = qemu_gluster_reopen_abort,
@@ -1609,7 +1609,7 @@ static BlockDriver bdrv_gluster_unix = { .format_name = "gluster", .protocol_name = "gluster+unix", .instance_size = sizeof(BDRVGlusterState), - .bdrv_file_open = qemu_gluster_open, + .bdrv_open = qemu_gluster_open, .bdrv_reopen_prepare = qemu_gluster_reopen_prepare, .bdrv_reopen_commit = qemu_gluster_reopen_commit, .bdrv_reopen_abort = qemu_gluster_reopen_abort,
block/iscsi.c +2 -2
@@ -2429,7 +2429,7 @@ static BlockDriver bdrv_iscsi = { .instance_size = sizeof(IscsiLun), .bdrv_parse_filename = iscsi_parse_filename, - .bdrv_file_open = iscsi_open, + .bdrv_open = iscsi_open, .bdrv_close = iscsi_close, .bdrv_co_create_opts = bdrv_co_create_opts_simple, .create_opts = &bdrv_create_opts_simple,
@@ -2468,7 +2468,7 @@ static BlockDriver bdrv_iser = { .instance_size = sizeof(IscsiLun), .bdrv_parse_filename = iscsi_parse_filename, - .bdrv_file_open = iscsi_open, + .bdrv_open = iscsi_open, .bdrv_close = iscsi_close, .bdrv_co_create_opts = bdrv_co_create_opts_simple, .create_opts = &bdrv_create_opts_simple,
block/nbd.c +3 -3
@@ -2146,7 +2146,7 @@ static BlockDriver bdrv_nbd = { .bdrv_parse_filename = nbd_parse_filename, .bdrv_co_create_opts = bdrv_co_create_opts_simple, .create_opts = &bdrv_create_opts_simple, - .bdrv_file_open = nbd_open, + .bdrv_open = nbd_open, .bdrv_reopen_prepare = nbd_client_reopen_prepare, .bdrv_co_preadv = nbd_client_co_preadv, .bdrv_co_pwritev = nbd_client_co_pwritev,
@@ -2174,7 +2174,7 @@ static BlockDriver bdrv_nbd_tcp = { .bdrv_parse_filename = nbd_parse_filename, .bdrv_co_create_opts = bdrv_co_create_opts_simple, .create_opts = &bdrv_create_opts_simple, - .bdrv_file_open = nbd_open, + .bdrv_open = nbd_open, .bdrv_reopen_prepare = nbd_client_reopen_prepare, .bdrv_co_preadv = nbd_client_co_preadv, .bdrv_co_pwritev = nbd_client_co_pwritev,
@@ -2202,7 +2202,7 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_parse_filename = nbd_parse_filename, .bdrv_co_create_opts = bdrv_co_create_opts_simple, .create_opts = &bdrv_create_opts_simple, - .bdrv_file_open = nbd_open, + .bdrv_open = nbd_open, .bdrv_reopen_prepare = nbd_client_reopen_prepare, .bdrv_co_preadv = nbd_client_co_preadv, .bdrv_co_pwritev = nbd_client_co_pwritev,
block/nfs.c +1 -1
@@ -888,7 +888,7 @@ static BlockDriver bdrv_nfs = {#endif .bdrv_co_truncate = nfs_file_co_truncate, - .bdrv_file_open = nfs_file_open, + .bdrv_open = nfs_file_open, .bdrv_close = nfs_file_close, .bdrv_co_create = nfs_file_co_create, .bdrv_co_create_opts = nfs_file_co_create_opts,
block/null.c +2 -2
@@ -283,7 +283,7 @@ static BlockDriver bdrv_null_co = { .protocol_name = "null-co", .instance_size = sizeof(BDRVNullState), - .bdrv_file_open = null_file_open, + .bdrv_open = null_file_open, .bdrv_parse_filename = null_co_parse_filename, .bdrv_co_getlength = null_co_getlength, .bdrv_co_get_allocated_file_size = null_co_get_allocated_file_size,
@@ -304,7 +304,7 @@ static BlockDriver bdrv_null_aio = { .protocol_name = "null-aio", .instance_size = sizeof(BDRVNullState), - .bdrv_file_open = null_file_open, + .bdrv_open = null_file_open, .bdrv_parse_filename = null_aio_parse_filename, .bdrv_co_getlength = null_co_getlength, .bdrv_co_get_allocated_file_size = null_co_get_allocated_file_size,
block/nvme.c +1 -1
@@ -1630,7 +1630,7 @@ static BlockDriver bdrv_nvme = { .create_opts = &bdrv_create_opts_simple, .bdrv_parse_filename = nvme_parse_filename, - .bdrv_file_open = nvme_file_open, + .bdrv_open = nvme_file_open, .bdrv_close = nvme_close, .bdrv_co_getlength = nvme_co_getlength, .bdrv_probe_blocksizes = nvme_probe_blocksizes,
block/rbd.c +2 -1
@@ -1815,8 +1815,9 @@ static const char *const qemu_rbd_strong_runtime_opts[] = {static BlockDriver bdrv_rbd = { .format_name ="rbd" , .instance_size =sizeof (BDRVRBDState), + .bdrv_parse_filename = qemu_rbd_parse_filename, - .bdrv_file_open = qemu_rbd_open, + .bdrv_open = qemu_rbd_open, .bdrv_close = qemu_rbd_close, .bdrv_reopen_prepare = qemu_rbd_reopen_prepare, .bdrv_co_create = qemu_rbd_co_create,
block/ssh.c +1 -1
@@ -1362,7 +1362,7 @@ static BlockDriver bdrv_ssh = { .protocol_name = "ssh", .instance_size = sizeof(BDRVSSHState), .bdrv_parse_filename = ssh_parse_filename, - .bdrv_file_open = ssh_file_open, + .bdrv_open = ssh_file_open, .bdrv_co_create = ssh_co_create, .bdrv_co_create_opts = ssh_co_create_opts, .bdrv_close = ssh_close,
block/vvfat.c +1 -1
@@ -3258,7 +3258,7 @@ static BlockDriver bdrv_vvfat = { .instance_size = sizeof(BDRVVVFATState), .bdrv_parse_filename = vvfat_parse_filename, - .bdrv_file_open = vvfat_open, + .bdrv_open = vvfat_open, .bdrv_refresh_limits = vvfat_refresh_limits, .bdrv_close = vvfat_close, .bdrv_child_perm = vvfat_child_perm,
Signature · 1 line
2.45.2
[PULL 13/23] Revert "host/i386: assume presence of POPCNT"
In reply to Paolo BonziniThis reverts commit 45ccdbcb24baf99667997fac5cf60318e5e7db51. The x86-64 instruction set can now be tuned down to x86-64 v1 or i386 Pentium Pro.
--- host/include/i386/host/cpuinfo.h | 1 + tcg/i386/tcg-target.h | 5 +++-- util/cpuinfo-i386.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
host/include/i386/host/cpuinfo.h +1 -0
@@ -11,6 +11,7 @@#define CPUINFO_ALWAYS (1u << 0)/* so cpuinfo is nonzero */ #define CPUINFO_MOVBE (1u << 2)#define CPUINFO_LZCNT (1u << 3) +#define CPUINFO_POPCNT (1u << 4)#define CPUINFO_BMI1 (1u << 5)#define CPUINFO_BMI2 (1u << 6)#define CPUINFO_AVX1 (1u << 9)
tcg/i386/tcg-target.h +3 -2
@@ -111,6 +111,7 @@ typedef enum {#endif #define have_bmi1 (cpuinfo & CPUINFO_BMI1) +#define have_popcnt (cpuinfo & CPUINFO_POPCNT)#define have_avx1 (cpuinfo & CPUINFO_AVX1)#define have_avx2 (cpuinfo & CPUINFO_AVX2)#define have_movbe (cpuinfo & CPUINFO_MOVBE)
@@ -142,7 +143,7 @@ typedef enum {#define TCG_TARGET_HAS_nor_i32 0#define TCG_TARGET_HAS_clz_i32 1#define TCG_TARGET_HAS_ctz_i32 1 -#define TCG_TARGET_HAS_ctpop_i32 1 +#define TCG_TARGET_HAS_ctpop_i32 have_popcnt#define TCG_TARGET_HAS_deposit_i32 1#define TCG_TARGET_HAS_extract_i32 1#define TCG_TARGET_HAS_sextract_i32 1
@@ -177,7 +178,7 @@ typedef enum {#define TCG_TARGET_HAS_nor_i64 0#define TCG_TARGET_HAS_clz_i64 1#define TCG_TARGET_HAS_ctz_i64 1 -#define TCG_TARGET_HAS_ctpop_i64 1 +#define TCG_TARGET_HAS_ctpop_i64 have_popcnt#define TCG_TARGET_HAS_deposit_i64 1#define TCG_TARGET_HAS_extract_i64 1#define TCG_TARGET_HAS_sextract_i64 0
util/cpuinfo-i386.c +1 -0
@@ -35,6 +35,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)__cpuid (1 , a, b, c, d); info |= (c & bit_MOVBE ?CPUINFO_MOVBE :0 ); + info |= (c & bit_POPCNT ?CPUINFO_POPCNT :0 ); info |= (c & bit_PCLMUL ?CPUINFO_PCLMUL :0 );/* NOTE: our AES support requires SSSE3 (PSHUFB) as well. */
Signature · 1 line
2.45.2
[PULL 06/23] target/i386: try not to force EFLAGS computation for CC_OP_ADOX/ADCX
In reply to Paolo BonziniWhen computing the "other" flag (CF for CC_OP_ADOX, OF for CC_OP_ADCX), take into account that it is already in the right position of cpu_cc_src, just like for CC_OP_EFLAGS. There is no need to call gen_compute_eflags().
--- target/i386/tcg/translate.c | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/tcg/translate.c +4 -0
@@ -928,6 +928,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) .no_setcond = true };case CC_OP_EFLAGS : +case CC_OP_ADOX : case CC_OP_SARB ... CC_OP_SARQ:/* CC_SRC & 1 */ return (CCPrepare ) { .cond =TCG_COND_TSTNE ,
@@ -994,6 +995,9 @@ static CCPrepare gen_prepare_eflags_o(DisasContext *s, TCGv reg)return (CCPrepare ) { .cond =TCG_COND_NE , .reg = cpu_cc_src };default :gen_compute_eflags (s); +/* fallthrough */ +case CC_OP_EFLAGS : +case CC_OP_ADCX :return (CCPrepare ) { .cond =TCG_COND_TSTNE , .reg = cpu_cc_src, .imm =CC_O }; }
Signature · 1 line
2.45.2
[PULL 10/23] target/i386: list instructions still in translate.c
In reply to Paolo BonziniGroup them so that it is easier to figure out which two-byte opcodes to tackle together.
--- target/i386/tcg/decode-new.c.inc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
target/i386/tcg/decode-new.c.inc +31 -0
@@ -129,6 +129,37 @@ * * (^) these are the two cases in which Intel and AMD disagree on the * primary exception class + * + * Instructions still in translate.c + * --------------------------------- + * Generation of TCG opcodes for almost all instructions is in emit.c.inc; + * this file interprets the prefixes and opcode bytes down to individual + * instruction mnemonics. There is only a handful of opcodes still using + * a switch statement to decode modrm bits 3-5 and prefixes after decoding + * is complete; these are relics of the older x86 decoder and their code + * generation is performed in translate.c. + * + * These unconverted opcodes also perform their own effective address + * generation using the gen_lea_modrm() function. + * + * There is nothing particularly complicated about them; simply, they don't + * need any nasty hacks in the decoder, and they shouldn't get in the way + * of the implementation of new x86 instructions, so they are left alone + * for the time being. + * + * x87: + * 0xD8 - 0xDF + * + * privileged/system: + * 0x0F 0x00 group 6 (SLDT, STR, LLDT, LTR, VERR, VERW) + * 0x0F 0x01 group 7 (SGDT, SIDT, LGDT, LIDT, SMSW, LMSW, INVLPG, + * MONITOR, MWAIT, CLAC, STAC, XGETBV, XSETBV, + * SWAPGS, RDTSCP) + * 0x0F 0xC7 (reg operand) group 9 (RDRAND, RDSEED, RDPID) + * + * MPX: + * 0x0F 0x1A BNDLDX, BNDMOV, BNDCL, BNDCU + * 0x0F 0x1B BNDSTX, BNDMOV, BNDMK, BNDCN */ #define X86_OP_NONE { 0 },
Signature · 1 line
2.45.2
[PULL 17/23] meson: remove dead optimization option
In reply to Paolo Bonzini--- meson.build | 13 ------------- meson_options.txt | 2 -- scripts/meson-buildoptions.sh | 3 --- 3 files changed, 18 deletions(-)
meson.build +0 -13
@@ -2874,18 +2874,6 @@ config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \ int main(int argc, char *argv[]) { return bar(argv[argc - 1]); } '''), error_message: 'AVX2 not available').allowed()) -config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \ - .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512F') \ - .require(cc.links(''' - #include <cpuid.h> - #include <immintrin.h> - static int __attribute__((target("avx512f"))) bar(void *a) { - __m512i x = *(__m512i *)a; - return _mm512_test_epi64_mask(x, x); - } - int main(int argc, char *argv[]) { return bar(argv[argc - 1]); } - '''), error_message: 'AVX512F not available').allowed()) - config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \ .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \ .require(cc.links('''
@@ -4283,7 +4271,6 @@ summary_info += {'mutex debugging': get_option('debug_mutex')} summary_info += {'memory allocator': get_option('malloc')} summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')} summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')} -summary_info += {'avx512f optimization': config_host_data.get('CONFIG_AVX512F_OPT')} summary_info += {'gcov': get_option('b_coverage')} summary_info += {'thread sanitizer': get_option('tsan')} summary_info += {'CFI support': get_option('cfi')}
meson_options.txt +0 -2
@@ -119,8 +119,6 @@ option('membarrier', type: 'feature', value: 'disabled', option('avx2', type: 'feature', value: 'auto', description: 'AVX2 optimizations') -option('avx512f', type: 'feature', value: 'disabled', - description: 'AVX512F optimizations') option('avx512bw', type: 'feature', value: 'auto', description: 'AVX512BW optimizations') option('keyring', type: 'feature', value: 'auto',
scripts/meson-buildoptions.sh +0 -3
@@ -95,7 +95,6 @@ meson_options_help() { printf "%s\n" ' auth-pam PAM access control' printf "%s\n" ' avx2 AVX2 optimizations' printf "%s\n" ' avx512bw AVX512BW optimizations' - printf "%s\n" ' avx512f AVX512F optimizations' printf "%s\n" ' blkio libblkio block device driver' printf "%s\n" ' bochs bochs image format support' printf "%s\n" ' bpf eBPF support'
@@ -240,8 +239,6 @@ _meson_option_parse() { --disable-avx2) printf "%s" -Davx2=disabled ;; --enable-avx512bw) printf "%s" -Davx512bw=enabled ;; --disable-avx512bw) printf "%s" -Davx512bw=disabled ;; - --enable-avx512f) printf "%s" -Davx512f=enabled ;; - --disable-avx512f) printf "%s" -Davx512f=disabled ;; --enable-gcov) printf "%s" -Db_coverage=true ;; --disable-gcov) printf "%s" -Db_coverage=false ;; --enable-lto) printf "%s" -Db_lto=true ;;
Signature · 1 line
2.45.2
[PULL 16/23] meson: allow configuring the x86-64 baseline
In reply to Paolo BonziniAdd a Meson option to configure which x86-64 instruction set to use. QEMU will now default to x86-64-v1 + cmpxchg16b for 64-bit builds (that corresponds to a Pentium 4 for 32-bit builds).
The baseline can be tuned down to Pentium Pro for 32-bit builds (with -Dx86_version=0), or up as desired.
--- meson.build | 41 ++++++++++++++++++++++++++++------- meson_options.txt | 3 +++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 39 insertions(+), 8 deletions(-)
meson.build +33 -8
@@ -336,15 +336,40 @@ if host_arch == 'i386' and not cc.links(''' qemu_common_flags = ['-march=i486'] + qemu_common_flags endif -# Assume x86-64-v2 (minus CMPXCHG16B for 32-bit code) -if host_arch == 'i386' - qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags -endif +# Pick x86-64 baseline version if host_arch in ['i386', 'x86_64'] - qemu_common_flags = ['-mpopcnt', '-msse4.2'] + qemu_common_flags -endif -if host_arch == 'x86_64' - qemu_common_flags = ['-mcx16'] + qemu_common_flags + if get_option('x86_version') == '0' and host_arch == 'x86_64' + error('x86_64-v1 required for x86-64 hosts') + endif + + # add flags for individual instruction set extensions + if get_option('x86_version') >= '1' + if host_arch == 'i386' + qemu_common_flags = ['-mfpmath=sse'] + qemu_common_flags + else + # present on basically all processors but technically not part of + # x86-64-v1, so only include -mneeded for x86-64 version 2 and above + qemu_common_flags = ['-mcx16'] + qemu_common_flags + endif + endif + if get_option('x86_version') >= '2' + qemu_common_flags = ['-mpopcnt'] + qemu_common_flags + qemu_common_flags = cc.get_supported_arguments('-mneeded') + qemu_common_flags + endif + if get_option('x86_version') >= '3' + qemu_common_flags = ['-mmovbe', '-mabm', '-mbmi1', '-mbmi2', '-mfma', '-mf16c'] + qemu_common_flags + endif + + # add required vector instruction set (each level implies those below) + if get_option('x86_version') == '1' + qemu_common_flags = ['-msse2'] + qemu_common_flags + elif get_option('x86_version') == '2' + qemu_common_flags = ['-msse4.2'] + qemu_common_flags + elif get_option('x86_version') == '3' + qemu_common_flags = ['-mavx2'] + qemu_common_flags + elif get_option('x86_version') == '4' + qemu_common_flags = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl'] + qemu_common_flags + endif endif if get_option('prefer_static')
meson_options.txt +3 -0
@@ -370,3 +370,6 @@ option('qemu_ga_version', type: 'string', value: '', option('hexagon_idef_parser', type : 'boolean', value : true, description: 'use idef-parser to automatically generate TCG code for the Hexagon frontend') + +option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1', + description: 'tweak required x86_64 architecture version beyond compiler default')
scripts/meson-buildoptions.sh +3 -0
@@ -82,6 +82,8 @@ meson_options_help() { printf "%s\n" ' --with-suffix=VALUE Suffix for QEMU data/modules/config directories' printf "%s\n" ' (can be empty) [qemu]' printf "%s\n" ' --with-trace-file=VALUE Trace file prefix for simple backend [trace]' + printf "%s\n" ' --x86-version=CHOICE tweak required x86_64 architecture version beyond' + printf "%s\n" ' compiler default [1] (choices: 0/1/2/3)' printf "%s\n" '' printf "%s\n" 'Optional features, enabled with --enable-FEATURE and' printf "%s\n" 'disabled with --disable-FEATURE, default is enabled if available'
@@ -552,6 +554,7 @@ _meson_option_parse() { --disable-werror) printf "%s" -Dwerror=false ;; --enable-whpx) printf "%s" -Dwhpx=enabled ;; --disable-whpx) printf "%s" -Dwhpx=disabled ;; + --x86-version=*) quote_sh "-Dx86_version=$2" ;; --enable-xen) printf "%s" -Dxen=enabled ;; --disable-xen) printf "%s" -Dxen=disabled ;; --enable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=enabled ;;
Signature · 1 line
2.45.2
[PULL 15/23] Revert "host/i386: assume presence of SSE2"
In reply to Paolo BonziniThis reverts commit b18236897ca15c3db1506d8edb9a191dfe51429c. The x86-64 instruction set can now be tuned down to x86-64 v1 or i386 Pentium Pro.
--- host/include/i386/host/cpuinfo.h | 1 + util/bufferiszero.c | 4 ++-- util/cpuinfo-i386.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)
host/include/i386/host/cpuinfo.h +1 -0
@@ -14,6 +14,7 @@#define CPUINFO_POPCNT (1u << 4)#define CPUINFO_BMI1 (1u << 5)#define CPUINFO_BMI2 (1u << 6) +#define CPUINFO_SSE2 (1u << 7)#define CPUINFO_AVX1 (1u << 9)#define CPUINFO_AVX2 (1u << 10)#define CPUINFO_AVX512F (1u << 11)
util/bufferiszero.c +2 -2
@@ -188,14 +188,14 @@ static biz_accel_fn const accel_table[] = {static unsigned best_accel (void ) { -#ifdef CONFIG_AVX2_OPT unsigned info =cpuinfo_init (); +#ifdef CONFIG_AVX2_OPT if (info &CPUINFO_AVX2 ) {return 2 ; }#endif -return 1 ; +return info &CPUINFO_SSE2 ?1 :0 ; }#elif defined(__aarch64__) && defined(__ARM_NEON)
util/cpuinfo-i386.c +1 -0
@@ -34,6 +34,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)if (max >=1 ) {__cpuid (1 , a, b, c, d); + info |= (d & bit_SSE2 ?CPUINFO_SSE2 :0 ); info |= (c & bit_MOVBE ?CPUINFO_MOVBE :0 ); info |= (c & bit_POPCNT ?CPUINFO_POPCNT :0 ); info |= (c & bit_PCLMUL ?CPUINFO_PCLMUL :0 );
Signature · 1 line
2.45.2
Re: [PULL 15/23] Revert "host/i386: assume presence of SSE2"
Quoted 32 lines · Paolo Bonzini
This reverts commit
b18236897ca15c3db1506d8edb9a191dfe51429c. The x86-64 instruction set can now be tuned down to x86-64 v1 or i386 Pentium Pro.Signed-off-by Paolo Bonzini <[email protected]>--- host/include/i386/host/cpuinfo.h | 1 + util/bufferiszero.c | 4 ++-- util/cpuinfo-i386.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)host/include/i386/host/cpuinfo.h +1
-0@@ -14,6 +14,7 @@#define CPUINFO_POPCNT (1u << 4)#define CPUINFO_BMI1 (1u << 5)#define CPUINFO_BMI2 (1u << 6) +#define CPUINFO_SSE2 (1u << 7)#define CPUINFO_AVX1 (1u << 9)#define CPUINFO_AVX2 (1u << 10)#define CPUINFO_AVX512F (1u << 11)util/bufferiszero.c +0
-1@@ -188,14 +188,14 @@ static biz_accel_fn const accel_table[] = {static unsigned best_accel (void ) { -#ifdef CONFIG_AVX2_OPT
util/bufferiszero.c static biz_accel_fn const accel_table[] = { · line 199
Quoted 10 lines
util/bufferiszero.c +2
-1unsigned info =cpuinfo_init (); +#ifdef CONFIG_AVX2_OPT if (info &CPUINFO_AVX2 ) {return 2 ; }#endif -return 1 ; +return info &CPUINFO_SSE2 ?1 :0 ; }
Merge conflict with master here -- bufferiszero.c has been split. This hunk now goes in host/include/i386/host/bufferiszero.c.inc.
r~
[PULL 02/23] target/i386: fix CC_OP dump
In reply to Paolo BonziniPOPCNT was missing, and the entries were all out of order after ADCX/ADOX/ADCOX were moved close to EFLAGS. Just use designated initializers.
--- target/i386/cpu-dump.c | 101 +++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 50 deletions(-)
target/i386/cpu-dump.c +51 -50
@@ -28,69 +28,70 @@/* x86 debug */ static const char *cc_op_str[CC_OP_NB ] = { -"DYNAMIC" , -"EFLAGS" , + [CC_OP_DYNAMIC ] ="DYNAMIC" , -"MULB" , -"MULW" , -"MULL" , -"MULQ" , + [CC_OP_EFLAGS ] ="EFLAGS" , + [CC_OP_ADCX ] ="ADCX" , + [CC_OP_ADOX ] ="ADOX" , + [CC_OP_ADCOX ] ="ADCOX" , -"ADDB" , -"ADDW" , -"ADDL" , -"ADDQ" , + [CC_OP_MULB ] ="MULB" , + [CC_OP_MULW ] ="MULW" , + [CC_OP_MULL ] ="MULL" , + [CC_OP_MULQ ] ="MULQ" , -"ADCB" , -"ADCW" , -"ADCL" , -"ADCQ" , + [CC_OP_ADDB ] ="ADDB" , + [CC_OP_ADDW ] ="ADDW" , + [CC_OP_ADDL ] ="ADDL" , + [CC_OP_ADDQ ] ="ADDQ" , -"SUBB" , -"SUBW" , -"SUBL" , -"SUBQ" , + [CC_OP_ADCB ] ="ADCB" , + [CC_OP_ADCW ] ="ADCW" , + [CC_OP_ADCL ] ="ADCL" , + [CC_OP_ADCQ ] ="ADCQ" , -"SBBB" , -"SBBW" , -"SBBL" , -"SBBQ" , + [CC_OP_SUBB ] ="SUBB" , + [CC_OP_SUBW ] ="SUBW" , + [CC_OP_SUBL ] ="SUBL" , + [CC_OP_SUBQ ] ="SUBQ" , -"LOGICB" , -"LOGICW" , -"LOGICL" , -"LOGICQ" , + [CC_OP_SBBB ] ="SBBB" , + [CC_OP_SBBW ] ="SBBW" , + [CC_OP_SBBL ] ="SBBL" , + [CC_OP_SBBQ ] ="SBBQ" , -"INCB" , -"INCW" , -"INCL" , -"INCQ" , + [CC_OP_LOGICB ] ="LOGICB" , + [CC_OP_LOGICW ] ="LOGICW" , + [CC_OP_LOGICL ] ="LOGICL" , + [CC_OP_LOGICQ ] ="LOGICQ" , -"DECB" , -"DECW" , -"DECL" , -"DECQ" , + [CC_OP_INCB ] ="INCB" , + [CC_OP_INCW ] ="INCW" , + [CC_OP_INCL ] ="INCL" , + [CC_OP_INCQ ] ="INCQ" , -"SHLB" , -"SHLW" , -"SHLL" , -"SHLQ" , + [CC_OP_DECB ] ="DECB" , + [CC_OP_DECW ] ="DECW" , + [CC_OP_DECL ] ="DECL" , + [CC_OP_DECQ ] ="DECQ" , -"SARB" , -"SARW" , -"SARL" , -"SARQ" , + [CC_OP_SHLB ] ="SHLB" , + [CC_OP_SHLW ] ="SHLW" , + [CC_OP_SHLL ] ="SHLL" , + [CC_OP_SHLQ ] ="SHLQ" , -"BMILGB" , -"BMILGW" , -"BMILGL" , -"BMILGQ" , + [CC_OP_SARB ] ="SARB" , + [CC_OP_SARW ] ="SARW" , + [CC_OP_SARL ] ="SARL" , + [CC_OP_SARQ ] ="SARQ" , -"ADCX" , -"ADOX" , -"ADCOX" , + [CC_OP_BMILGB ] ="BMILGB" , + [CC_OP_BMILGW ] ="BMILGW" , + [CC_OP_BMILGL ] ="BMILGL" , + [CC_OP_BMILGQ ] ="BMILGQ" , -"CLR" , + [CC_OP_POPCNT ] ="POPCNT" , + [CC_OP_CLR ] ="CLR" , }; static void
Signature · 1 line
2.45.2
[PULL 09/23] target/i386: do not check PREFIX_LOCK in old-style decoder
In reply to Paolo BonziniIt is already checked before getting there.
--- target/i386/tcg/translate.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
target/i386/tcg/translate.c +8 -18
@@ -2878,7 +2878,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)switch ((modrm >>3 ) &7 ) {case 7 :if (mod !=3 || - (s->prefix & (PREFIX_LOCK |PREFIX_REPNZ ))) { + (s->prefix &PREFIX_REPNZ )) { goto illegal_op; }if (s->prefix &PREFIX_REPZ ) {
@@ -2898,7 +2898,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)case 6 :/* RDRAND */ if (mod !=3 || - (s->prefix & (PREFIX_LOCK |PREFIX_REPZ |PREFIX_REPNZ )) || + (s->prefix & (PREFIX_REPZ |PREFIX_REPNZ )) || !(s->cpuid_ext_features &CPUID_EXT_RDRAND )) { goto illegal_op; }
@@ -3058,8 +3058,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)case 0xd0 :/* xgetbv */ if ((s->cpuid_ext_features &CPUID_EXT_XSAVE ) ==0 - || (s->prefix & (PREFIX_LOCK |PREFIX_DATA - |PREFIX_REPZ |PREFIX_REPNZ ))) { + || (s->prefix & (PREFIX_DATA |PREFIX_REPZ |PREFIX_REPNZ ))) { goto illegal_op; }tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_ECX ]);
@@ -3069,8 +3068,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)case 0xd1 :/* xsetbv */ if ((s->cpuid_ext_features &CPUID_EXT_XSAVE ) ==0 - || (s->prefix & (PREFIX_LOCK |PREFIX_DATA - |PREFIX_REPZ |PREFIX_REPNZ ))) { + || (s->prefix & (PREFIX_DATA |PREFIX_REPZ |PREFIX_REPNZ ))) { goto illegal_op; }gen_svm_check_intercept (s,SVM_EXIT_XSETBV );
@@ -3237,8 +3235,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)gen_st_modrm (s, decode, ot);break ;case 0xee :/* rdpkru */ -if (s->prefix & (PREFIX_LOCK |PREFIX_DATA - |PREFIX_REPZ |PREFIX_REPNZ )) { +if (s->prefix & (PREFIX_DATA |PREFIX_REPZ |PREFIX_REPNZ )) { goto illegal_op; }tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_ECX ]);
@@ -3246,8 +3243,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)tcg_gen_extr_i64_tl (cpu_regs[R_EAX ], cpu_regs[R_EDX ], s->tmp1_i64);break ;case 0xef :/* wrpkru */ -if (s->prefix & (PREFIX_LOCK |PREFIX_DATA - |PREFIX_REPZ |PREFIX_REPNZ )) { +if (s->prefix & (PREFIX_DATA |PREFIX_REPZ |PREFIX_REPNZ )) { goto illegal_op; } tcg_gen_concat_tl_i64(s->tmp1_i64, cpu_regs[R_EAX],
@@ -3323,7 +3319,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)if (prefixes &PREFIX_REPZ ) {/* bndcl */ if (reg >=4 - || (prefixes &PREFIX_LOCK ) || s->aflag ==MO_16 ) { goto illegal_op; }
@@ -3331,7 +3326,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode) }else if (prefixes &PREFIX_REPNZ ) {/* bndcu */ if (reg >=4 - || (prefixes &PREFIX_LOCK ) || s->aflag ==MO_16 ) { goto illegal_op; }
@@ -3345,7 +3339,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode) }if (mod ==3 ) {int reg2 = (modrm &7 ) |REX_B (s); -if (reg2 >=4 || (prefixes &PREFIX_LOCK )) { +if (reg2 >=4 ) { goto illegal_op; }if (s->flags &HF_MPX_IU_MASK ) {
@@ -3374,7 +3368,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)/* bndldx */ AddressParts a = decode->mem;if (reg >=4 - || (prefixes &PREFIX_LOCK ) || s->aflag ==MO_16 || a.base <-1 ) { goto illegal_op;
@@ -3410,7 +3403,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)if (mod !=3 && (prefixes &PREFIX_REPZ )) {/* bndmk */ if (reg >=4 - || (prefixes &PREFIX_LOCK ) || s->aflag ==MO_16 ) { goto illegal_op; }
@@ -3438,7 +3430,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode) }else if (prefixes &PREFIX_REPNZ ) {/* bndcn */ if (reg >=4 - || (prefixes &PREFIX_LOCK ) || s->aflag ==MO_16 ) { goto illegal_op; }
@@ -3450,7 +3441,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode) }if (mod ==3 ) {int reg2 = (modrm &7 ) |REX_B (s); -if (reg2 >=4 || (prefixes &PREFIX_LOCK )) { +if (reg2 >=4 ) { goto illegal_op; }if (s->flags &HF_MPX_IU_MASK ) {
@@ -3477,7 +3468,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode)/* bndstx */ AddressParts a = decode->mem;if (reg >=4 - || (prefixes &PREFIX_LOCK ) || s->aflag ==MO_16 || a.base <-1 ) { goto illegal_op;
Signature · 1 line
2.45.2
[PULL 21/23] block: rename former bdrv_file_open callbacks
In reply to Paolo BonziniSince there is no bdrv_file_open callback anymore, rename the implementations so that they end with "_open" instead of "_file_open". NFS is the exception because all the functions are named nfs_file_*.
--- block/blkio.c | 8 ++++---- block/null.c | 8 ++++---- block/nvme.c | 8 ++++---- block/ssh.c | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-)
block/blkio.c +4 -4
@@ -713,7 +713,7 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,* for example will fail. * * In order to open the device read-only, we are using the `read-only` -* property of the libblkio driver in blkio_file_open(). +* property of the libblkio driver in blkio_open(). */ fd =qemu_open (path,O_RDWR ,NULL );if (fd <0 ) {
@@ -791,8 +791,8 @@ static int blkio_virtio_blk_connect(BlockDriverState *bs, QDict *options,return 0 ; } -static int blkio_file_open (BlockDriverState *bs,QDict *options,int flags, -Error **errp) +static int blkio_open (BlockDriverState *bs,QDict *options,int flags, +Error **errp) {const char *blkio_driver = bs->drv->protocol_name;BDRVBlkioState *s = bs->opaque;
@@ -1088,7 +1088,7 @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp)*/ #define BLKIO_DRIVER_COMMON \ .instance_size = sizeof(BDRVBlkioState), \ - .bdrv_open = blkio_file_open, \ + .bdrv_open = blkio_open, \ .bdrv_close = blkio_close, \ .bdrv_co_getlength = blkio_co_getlength, \ .bdrv_co_truncate = blkio_truncate, \
block/null.c +4 -4
@@ -77,8 +77,8 @@ static void null_aio_parse_filename(const char *filename, QDict *options, } } -static int null_file_open (BlockDriverState *bs,QDict *options,int flags, -Error **errp) +static int null_open (BlockDriverState *bs,QDict *options,int flags, +Error **errp) {QemuOpts *opts;BDRVNullState *s = bs->opaque;
@@ -283,7 +283,7 @@ static BlockDriver bdrv_null_co = { .protocol_name = "null-co", .instance_size = sizeof(BDRVNullState), - .bdrv_open = null_file_open, + .bdrv_open = null_open, .bdrv_parse_filename = null_co_parse_filename, .bdrv_co_getlength = null_co_getlength, .bdrv_co_get_allocated_file_size = null_co_get_allocated_file_size,
@@ -304,7 +304,7 @@ static BlockDriver bdrv_null_aio = { .protocol_name = "null-aio", .instance_size = sizeof(BDRVNullState), - .bdrv_open = null_file_open, + .bdrv_open = null_open, .bdrv_parse_filename = null_aio_parse_filename, .bdrv_co_getlength = null_co_getlength, .bdrv_co_get_allocated_file_size = null_co_get_allocated_file_size,
block/nvme.c +4 -4
@@ -889,7 +889,7 @@ out:qemu_vfio_pci_unmap_bar (s->vfio,0 , (void *)regs,0 ,sizeof (NvmeBar)); } -/* Cleaning up is done in nvme_file_open() upon error. */ +/* Cleaning up is done in nvme_open() upon error. */ return ret; }
@@ -967,8 +967,8 @@ static void nvme_close(BlockDriverState *bs)g_free (s->device); } -static int nvme_file_open (BlockDriverState *bs,QDict *options,int flags, -Error **errp) +static int nvme_open (BlockDriverState *bs,QDict *options,int flags, +Error **errp) {const char *device;QemuOpts *opts;
@@ -1630,7 +1630,7 @@ static BlockDriver bdrv_nvme = { .create_opts = &bdrv_create_opts_simple, .bdrv_parse_filename = nvme_parse_filename, - .bdrv_open = nvme_file_open, + .bdrv_open = nvme_open, .bdrv_close = nvme_close, .bdrv_co_getlength = nvme_co_getlength, .bdrv_probe_blocksizes = nvme_probe_blocksizes,
block/ssh.c +3 -3
@@ -837,8 +837,8 @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts,return ret; } -static int ssh_file_open (BlockDriverState *bs,QDict *options,int bdrv_flags, -Error **errp) +static int ssh_open (BlockDriverState *bs,QDict *options,int bdrv_flags, +Error **errp) {BDRVSSHState *s = bs->opaque;BlockdevOptionsSsh *opts;
@@ -1362,7 +1362,7 @@ static BlockDriver bdrv_ssh = { .protocol_name = "ssh", .instance_size = sizeof(BDRVSSHState), .bdrv_parse_filename = ssh_parse_filename, - .bdrv_open = ssh_file_open, + .bdrv_open = ssh_open, .bdrv_co_create = ssh_co_create, .bdrv_co_create_opts = ssh_co_create_opts, .bdrv_close = ssh_close,
Signature · 1 line
2.45.2
[PULL 08/23] target/i386: convert CMPXCHG8B/CMPXCHG16B to new decoder
In reply to Paolo BonziniThis moves the last LOCK-enabled instructions to the new decoder. It is now possible to assume that PREFIX_LOCK gen_multi0F is called only after checking that LOCK was not specified.
The gen_cmpxchg8b and gen_cmpxchg16b functions even have the correct prototype already; the only thing that needs to be done is removing the gen_lea_modrm() call.
--- target/i386/tcg/decode-new.h | 2 + target/i386/tcg/translate.c | 121 +------------------------------ target/i386/tcg/decode-new.c.inc | 34 ++++++--- target/i386/tcg/emit.c.inc | 96 ++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 129 deletions(-)
target/i386/tcg/decode-new.h +2 -0
@@ -114,6 +114,8 @@ typedef enum X86CPUIDFeature {X86_FEAT_CLWB ,X86_FEAT_CMOV ,X86_FEAT_CMPCCXADD , +X86_FEAT_CX8 , +X86_FEAT_CX16 ,X86_FEAT_F16C ,X86_FEAT_FMA , X86_FEAT_FSGSBASE,
target/i386/tcg/translate.c +2 -119
135 lines not on this page · raw message
target/i386/tcg/decode-new.c.inc +24 -10
@@ -288,6 +288,25 @@ static void decode_group8(DisasContext *s, CPUX86State *env, X86OpEntry *entry, } } +static void decode_group9(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b) +{ + static const X86OpEntry group9_reg = + X86_OP_ENTRY0(multi0F); /* unconverted */ + static const X86OpEntry cmpxchg8b = + X86_OP_ENTRY1(CMPXCHG8B, M,q, lock p_00 cpuid(CX8)); + static const X86OpEntry cmpxchg16b = + X86_OP_ENTRY1(CMPXCHG16B, M,dq, lock p_00 cpuid(CX16)); + + int modrm = get_modrm(s, env); + int op = (modrm >> 3) & 7; + + if ((modrm >> 6) == 3) { + *entry = group9_reg; + } else if (op == 1) { + *entry = REX_W(s) ? cmpxchg16b : cmpxchg8b; + } +} + static void decode_group15(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b) { static const X86OpEntry group15_reg[8] = {
@@ -1203,7 +1222,7 @@ static const X86OpEntry opcodes_0F[256] = { [0xc4] = X86_OP_ENTRY4(PINSRW, V,dq,H,dq,E,w, vex5 mmx p_00_66), [0xc5] = X86_OP_ENTRY3(PEXTRW, G,d, U,dq,I,b, vex5 mmx p_00_66), [0xc6] = X86_OP_ENTRY4(VSHUF, V,x, H,x, W,x, vex4 p_00_66), - [0xc7] = X86_OP_ENTRY1(multi0F, nop,v, nolea), /* unconverted */ + [0xc7] = X86_OP_GROUP0(group9), [0xd0] = X86_OP_ENTRY3(VADDSUB, V,x, H,x, W,x, vex2 cpuid(SSE3) p_66_f2), [0xd1] = X86_OP_ENTRY3(PSRLW_r, V,x, H,x, W,x, vex4 mmx avx2_256 p_00_66),
@@ -2241,8 +2260,12 @@ static bool has_cpuid_feature(DisasContext *s, X86CPUIDFeature cpuid) return (s->cpuid_features & CPUID_CMOV); case X86_FEAT_CLFLUSH: return (s->cpuid_features & CPUID_CLFLUSH); + case X86_FEAT_CX8: + return (s->cpuid_features & CPUID_CX8); case X86_FEAT_FXSR: return (s->cpuid_features & CPUID_FXSR); + case X86_FEAT_CX16: + return (s->cpuid_ext_features & CPUID_EXT_CX16); case X86_FEAT_F16C: return (s->cpuid_ext_features & CPUID_EXT_F16C); case X86_FEAT_FMA:
@@ -2722,15 +2745,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) break; } - /* - * hack for old decoder: 0F C7 has both instructions that accept LOCK - * and instructions that don't, but also needs X86_SPECIAL_NoLoadEA. - * Keep this here until CMPXCHG8B/CMPXCHG16B is separated from the - * other unconverted opcodes. - */ - if (decode.e.gen == gen_multi0F) { - accept_lock = true; - } if ((s->prefix & PREFIX_LOCK) && !accept_lock) { goto illegal_op; }
target/i386/tcg/emit.c.inc +96 -0
102 lines not on this page · raw message
Signature · 1 line
2.45.2
[PULL 18/23] block: make assertion more generic
In reply to Paolo Bonzini.bdrv_needs_filename is only set for drivers that also set bdrv_file_open, i.e. protocol drivers.
So we can make the assertion always, it will always pass for those drivers that use bdrv_open.
--- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block.c +1 -1
@@ -1655,8 +1655,8 @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, bs->drv = drv; bs->opaque =g_malloc0 (drv->instance_size); +assert (!drv->bdrv_needs_filename || bs->filename[0 ]);if (drv->bdrv_file_open) { -assert (!drv->bdrv_needs_filename || bs->filename[0 ]); ret = drv->bdrv_file_open (bs, options, open_flags, &local_err); }else if (drv->bdrv_open) { ret = drv->bdrv_open (bs, options, open_flags, &local_err);
Signature · 1 line
2.45.2
[PULL 23/23] exec: don't use void* in pointer arithmetic in headers
In reply to Paolo BonziniFrom: Roman Kiryanov <[email protected]>
void* pointer arithmetic is a GCC extentension which could not be available in other build tools (e.g. C++). This changes removes this assumption.
--- include/exec/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/exec/memory.h +1 -1
@@ -2796,7 +2796,7 @@ MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,#include "exec/memory_ldst_phys.h.inc" struct MemoryRegionCache { -void *ptr; +uint8_t *ptr;hwaddr xlat;hwaddr len;FlatView *fv;
Signature · 1 line
2.45.2
[PULL 22/23] exec: avoid using C++ keywords in function parameters
In reply to Paolo BonziniFrom: Roman Kiryanov <[email protected]>
to use the QEMU headers with a C++ compiler.
--- include/exec/memory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/exec/memory.h +2 -2
@@ -945,7 +945,7 @@ struct MemoryListener {* the current transaction. */ void (*log_start)(MemoryListener *listener,MemoryRegionSection *section, -int old,int new); +int old_val,int new_val);/** * @log_stop:
@@ -964,7 +964,7 @@ struct MemoryListener {* the current transaction. */ void (*log_stop)(MemoryListener *listener,MemoryRegionSection *section, -int old,int new); +int old_val,int new_val);/** * @log_sync:
Signature · 1 line
2.45.2