Misc bugfix patches for 2021-06-04
Subsystems (2)
The following changes since commit 5a95f5ce3cd5842cc8f61a91ecd4fb4e8d10104f:
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-fpu-20210603' into staging (2021-06-04 10:04:11 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 49e987695a1873a769a823604f9065aa88e00c55:
vl: plug -object back into -readconfig (2021-06-04 13:50:04 +0200)
----------------------------------------------------------------
* OpenBSD cleanup (Brad)
* fixes for the i386 accel/cpu refactoring (Claudio)
* unmap test for emulated SCSI (Kit)
* fix for iscsi module (myself)
* fix for -readconfig of objects (myself)
* fixes for x86 16-bit task switching (myself)
* fix for x86 MOV from/to CR8 (Richard)
----------------------------------------------------------------
Brad Smith (1):
oslib-posix: Remove OpenBSD workaround for fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure
Claudio Fontana (2):
i386: reorder call to cpu_exec_realizefn
i386: run accel_cpu_instance_init as post_init
Kit Westneat (1):
tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test
Paolo Bonzini (8):
meson: allow optional dependencies for block modules
iscsi: link libm into the module
target/i386: tcg: fix segment register offsets for 16-bit TSS target/i386: tcg: fix loading of registers from 16-bit TSS target/i386: tcg: fix switching from 16-bit to 32-bit tasks or vice versa
qemu-config: parse configuration files to a QDict
vl: plumb keyval-based options into -readconfig
vl: plug -object back into -readconfig
Richard Henderson (1):
target/i386: Fix decode of cr8
block/meson.build | 18 +++---- include/block/qdict.h | 2 - include/qapi/qmp/qdict.h | 3 ++ include/qemu/config-file.h | 7 ++- meson.build | 4 +- softmmu/vl.c | 105 +++++++++++++++++++++++++++++------------ target/i386/cpu.c | 89 ++++++++++++++++++++++------------ target/i386/kvm/kvm-cpu.c | 12 ++++- target/i386/tcg/seg_helper.c | 31 ++++++------ target/i386/tcg/translate.c | 1 + tests/qtest/virtio-scsi-test.c | 51 ++++++++++++++++++++ util/oslib-posix.c | 11 ----- util/qemu-config.c | 98 ++++++++++++++++++++++++++------------ 13 files changed, 298 insertions(+), 134 deletions(-)
Signature · 1 line
2.31.1
[PULL 02/13] iscsi: link libm into the module
Depending on the configuration of QEMU, some binaries might not need libm at all. In that case libiscsi, which uses exp(), will fail to load. Link it in the module explicitly.
--- block/meson.build | 2 +- meson.build | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
block/meson.build +1 -1
@@ -73,7 +73,7 @@ modsrc = [] foreach m : [ [curl, 'curl', files('curl.c')], [glusterfs, 'gluster', files('gluster.c')], - [libiscsi, 'iscsi', files('iscsi.c')], + [libiscsi, 'iscsi', [files('iscsi.c'), libm]], [libnfs, 'nfs', files('nfs.c')], [libssh, 'ssh', files('ssh.c')], [rbd, 'rbd', files('rbd.c')],
meson.build +2 -2
@@ -163,7 +163,7 @@ if targetos != 'linux' and get_option('multiprocess').enabled() endif multiprocess_allowed = targetos == 'linux' and not get_option('multiprocess').disabled() -m = cc.find_library('m', required: false) +libm = cc.find_library('m', required: false) util = cc.find_library('util', required: false) winmm = [] socket = []
@@ -1899,7 +1899,7 @@ util_ss.add_all(trace_ss) util_ss = util_ss.apply(config_all, strict: false) libqemuutil = static_library('qemuutil', sources: util_ss.sources() + stub_ss.sources() + genh, - dependencies: [util_ss.dependencies(), m, glib, socket, malloc, pixman]) + dependencies: [util_ss.dependencies(), libm, glib, socket, malloc, pixman]) qemuutil = declare_dependency(link_with: libqemuutil, sources: genh + version_res)
Signature · 1 line
2.31.1
[PULL 03/13] oslib-posix: Remove OpenBSD workaround for fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure
In reply to Paolo BonziniFrom: Brad Smith <[email protected]>
OpenBSD prior to 6.3 required a workaround to utilize fcntl(F_SETFL) on memory devices.
Since modern verions of OpenBSD that are only officialy supported and buildable on do not have this issue I am garbage collecting this workaround.
Message-Id: <[email protected]>
--- util/oslib-posix.c | 11 ----------- 1 file changed, 11 deletions(-)
util/oslib-posix.c +0 -11
@@ -273,17 +273,6 @@ int qemu_try_set_nonblock(int fd)return -errno; }if (fcntl (fd,F_SETFL , f |O_NONBLOCK ) ==-1 ) { -#ifdef __OpenBSD__ -/* -* Previous to OpenBSD 6.3, fcntl(F_SETFL) is not permitted on -* memory devices and sets errno to ENODEV. -* It's OK if we fail to set O_NONBLOCK on devices like /dev/null, -* because they will never block anyway. -*/ -if (errno ==ENODEV ) { -return 0 ; - } -#endif return -errno; }return 0 ;
Signature · 1 line
2.31.1
[PULL 01/13] meson: allow optional dependencies for block modules
In reply to Paolo BonziniRight now all dependencies for block modules are passed to module_ss.add(when: ...), so they are mandatory. In the next patch we will need to add a libm dependency to a module, but libm does not exist on all systems. So, modify the creation of module_ss and modsrc so that dependencies can also be passed to module_ss.add(if_true: ...).
While touching the array, remove the useless dependency of the curl module on glib. glib is always linked in QEMU and in fact all other block modules also need it, but they don't have to specify it.
--- block/meson.build | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
block/meson.build +9 -9
@@ -71,19 +71,19 @@ block_modules = {} modsrc = [] foreach m : [ - [curl, 'curl', [curl, glib], 'curl.c'], - [glusterfs, 'gluster', glusterfs, 'gluster.c'], - [libiscsi, 'iscsi', libiscsi, 'iscsi.c'], - [libnfs, 'nfs', libnfs, 'nfs.c'], - [libssh, 'ssh', libssh, 'ssh.c'], - [rbd, 'rbd', rbd, 'rbd.c'], + [curl, 'curl', files('curl.c')], + [glusterfs, 'gluster', files('gluster.c')], + [libiscsi, 'iscsi', files('iscsi.c')], + [libnfs, 'nfs', files('nfs.c')], + [libssh, 'ssh', files('ssh.c')], + [rbd, 'rbd', files('rbd.c')], ] if m[0].found() + module_ss = ss.source_set() + module_ss.add(when: m[0], if_true: m[2]) if enable_modules - modsrc += files(m[3]) + modsrc += module_ss.all_sources() endif - module_ss = ss.source_set() - module_ss.add(when: m[2], if_true: files(m[3])) block_modules += {m[1] : module_ss} endif endforeach
Signature · 1 line
2.31.1
[PULL 04/13] target/i386: tcg: fix segment register offsets for 16-bit TSS
In reply to Paolo BonziniThe TSS offsets in the manuals have only 2-byte slots for the segment registers. QEMU incorrectly uses 4-byte slots, so that SS overlaps the LDT selector.
Resolves: #382
--- target/i386/tcg/seg_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/tcg/seg_helper.c +2 -2
@@ -281,7 +281,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector, retaddr) | 0xffff0000; }for (i =0 ; i <4 ; i++) { - new_segs[i] =cpu_lduw_kernel_ra (env, tss_base + (0x22 + i *4 ), + new_segs[i] =cpu_lduw_kernel_ra (env, tss_base + (0x22 + i *2 ), retaddr); } new_ldt =cpu_lduw_kernel_ra (env, tss_base +0x2a , retaddr);
@@ -349,7 +349,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector,cpu_stw_kernel_ra (env, env->tr.base + (0x12 +6 *2 ), env->regs[R_ESI ], retaddr);cpu_stw_kernel_ra (env, env->tr.base + (0x12 +7 *2 ), env->regs[R_EDI ], retaddr);for (i =0 ; i <4 ; i++) { -cpu_stw_kernel_ra (env, env->tr.base + (0x22 + i *4 ), +cpu_stw_kernel_ra (env, env->tr.base + (0x22 + i *2 ), env->segs[i].selector, retaddr); } }
Signature · 1 line
2.31.1
[PULL 08/13] tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test
In reply to Paolo BonziniFrom: Kit Westneat <[email protected]>
Add test for issue #345
Message-Id: <[email protected]>
--- tests/qtest/virtio-scsi-test.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
tests/qtest/virtio-scsi-test.c +51 -0
@@ -200,6 +200,42 @@ static void test_unaligned_write_same(void *obj, void *data,qvirtio_scsi_pci_free (vs); } +/* Test UNMAP with a large LBA, issue #345 */ +static void test_unmap_large_lba (void *obj,void *data, +QGuestAllocator *t_alloc) +{ +QVirtioSCSI *scsi = obj; +QVirtioSCSIQueues *vs; +const uint8_t unmap[VIRTIO_SCSI_CDB_SIZE ] = { +0x42 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x18 ,0x00 + }; + +/* +* Default null-co device size is 2**30 +* LBA 0x7fff is ~ 1/8 into device, with 4k blocks +* if check_lba_range incorrectly using 512 bytes, will trigger sense error +*/ +uint8_t unmap_params[0x18 ] = { +0x00 ,0x16 ,/* unmap data length */ +0x00 ,0x10 ,/* unmap block descriptor data length */ +0x00 ,0x00 ,0x00 ,0x00 ,/* reserved */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x7f ,0xff ,/* LBA */ +0x00 ,0x00 ,0x03 ,0xff ,/* sector count */ +0x00 ,0x00 ,0x00 ,0x00 ,/* reserved */ + }; +struct virtio_scsi_cmd_resp resp; + + alloc = t_alloc; + vs =qvirtio_scsi_init (scsi->vdev); + +virtio_scsi_do_command (vs, unmap,NULL ,0 , unmap_params, +sizeof (unmap_params), &resp); + g_assert_cmphex(resp.response, ==, 0); + g_assert_cmphex(resp.status, !=, CHECK_CONDITION); + +qvirtio_scsi_pci_free (vs); +} +static void test_write_to_cdrom (void *obj,void *data,QGuestAllocator *t_alloc) {
@@ -293,6 +329,17 @@ static void *virtio_scsi_setup(GString *cmd_line, void *arg)return arg; } +static void *virtio_scsi_setup_4k (GString *cmd_line,void *arg) +{ +g_string_append (cmd_line, +" -drive file=blkdebug::null-co://," +"file.image.read-zeroes=on," +"if=none,id=dr1,format=raw " +"-device scsi-hd,drive=dr1,lun=0,scsi-id=1" +",logical_block_size=4k,physical_block_size=4k" ); +return arg; +} +static void *virtio_scsi_setup_cd (GString *cmd_line,void *arg) { g_string_append(cmd_line,
@@ -323,6 +370,10 @@ static void register_virtio_scsi_test(void)qos_add_test ("unaligned-write-same" ,"virtio-scsi" , test_unaligned_write_same, &opts); + opts.before = virtio_scsi_setup_4k; +qos_add_test ("large-lba-unmap" ,"virtio-scsi" , + test_unmap_large_lba, &opts); + opts.before = virtio_scsi_setup_cd;qos_add_test ("write-to-cdrom" ,"virtio-scsi" , test_write_to_cdrom, &opts);
Signature · 1 line
2.31.1
[PULL 10/13] i386: run accel_cpu_instance_init as post_init
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
This fixes host and max cpu initialization, by running the accel cpu initialization only after all instance init functions are called for all X86 cpu subclasses.
The bug this is fixing is related to the "max" and "host" i386 cpu subclasses, which set cpu->max_features, which is then used at cpu realization time.
In order to properly split the accel-specific max features code that needs to be executed at cpu instance initialization time,
we cannot call the accel cpu initialization at the end of the x86 base class initialization, or we will have no way to specialize "max features" cpu behavior, overriding the "max" cpu class defaults, and checking for the "max features" flag itself.
This patch moves the accel-specific cpu instance initialization to after all x86 cpu instance code has been executed, including subclasses,
so that proper initialization of cpu "host" and "max" can be restored.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
target/i386/cpu.c +7 -3
@@ -6401,6 +6401,11 @@ static void x86_cpu_register_feature_bit_props(X86CPUClass *xcc,x86_cpu_register_bit_prop (xcc, name, w, bitnr); } +static void x86_cpu_post_initfn (Object *obj) +{ +accel_cpu_instance_init (CPU (obj)); +} +static void x86_cpu_initfn (Object *obj) {X86CPU *cpu =X86_CPU (obj);
@@ -6452,9 +6457,6 @@ static void x86_cpu_initfn(Object *obj)if (xcc->model) {x86_cpu_load_model (cpu, xcc->model); } - -/* if required, do accelerator-specific cpu initializations */ -accel_cpu_instance_init (CPU (obj)); }static int64_t x86_cpu_get_arch_id (CPUState *cs)
@@ -6799,6 +6801,8 @@ static const TypeInfo x86_cpu_type_info = { .parent = TYPE_CPU, .instance_size = sizeof(X86CPU), .instance_init = x86_cpu_initfn, + .instance_post_init = x86_cpu_post_initfn, + .abstract = true, .class_size = sizeof(X86CPUClass), .class_init = x86_cpu_common_class_init,
Signature · 1 line
2.31.1
[PULL 11/13] qemu-config: parse configuration files to a QDict
In reply to Paolo BonziniChange the parser to put the values into a QDict and pass them to a callback. qemu_config_parse's QemuOpts creation is itself turned into a callback function.
This is useful for -readconfig to support keyval-based options; getting a QDict from the parser removes a roundtrip from QDict to QemuOpts and then back to QDict.
Unfortunately there is a disadvantage in that semantic errors will point to the last line of the group, because the entries of the QDict do not have a location attached.
Message-Id: <[email protected]>
--- include/qemu/config-file.h | 7 ++- softmmu/vl.c | 4 +- util/qemu-config.c | 98 ++++++++++++++++++++++++++------------ 3 files changed, 76 insertions(+), 33 deletions(-)
include/qemu/config-file.h +6 -1
@@ -1,6 +1,8 @@#ifndef QEMU_CONFIG_FILE_H #define QEMU_CONFIG_FILE_H +typedef void QEMUConfigCB (const char *group,QDict *qdict,void *opaque,Error **errp); +void qemu_load_module_for_opts (const char *group);QemuOptsList *qemu_find_opts (const char *group);QemuOptsList *qemu_find_opts_err (const char *group,Error **errp);
@@ -14,7 +16,10 @@ void qemu_config_write(FILE *fp);int qemu_config_parse (FILE *fp,QemuOptsList **lists,const char *fname,Error **errp); -int qemu_read_config_file (const char *filename,Error **errp); +/* A default callback for qemu_read_config_file(). */ +void qemu_config_do_parse (const char *group,QDict *qdict,void *opaque,Error **errp); + +int qemu_read_config_file (const char *filename,QEMUConfigCB *f,Error **errp);/* Parse QDict options as a replacement for a config file (allowing multiple enumerated (0..(n-1)) configuration "sections") */
softmmu/vl.c +2 -2
@@ -2133,7 +2133,7 @@ static void qemu_read_default_config_file(Error **errp)int ret; g_autofree char *file = get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf"); - ret =qemu_read_config_file (file, errp); + ret =qemu_read_config_file (file, qemu_config_do_parse, errp);if (ret <0 ) {if (ret == -ENOENT ) {error_free (*errp);
@@ -3399,7 +3399,7 @@ void qemu_init(int argc, char **argv, char **envp)qemu_plugin_opt_parse (optarg, &plugin_list);break ;case QEMU_OPTION_readconfig: -qemu_read_config_file (optarg, &error_fatal); +qemu_read_config_file (optarg, qemu_config_do_parse, &error_fatal);break ;case QEMU_OPTION_spice: olist =qemu_find_opts_err ("spice" ,NULL );
util/qemu-config.c +68 -30
150 lines not on this page · raw message
Signature · 1 line
2.31.1
[PULL 05/13] target/i386: tcg: fix loading of registers from 16-bit TSS
In reply to Paolo BonziniAccording to the manual, the high 16-bit of the registers are preserved when switching to a 16-bit task. Implement this in switch_tss_ra.
--- target/i386/tcg/seg_helper.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
target/i386/tcg/seg_helper.c +11 -14
@@ -277,8 +277,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector, new_eip =cpu_lduw_kernel_ra (env, tss_base +0x0e , retaddr); new_eflags =cpu_lduw_kernel_ra (env, tss_base +0x10 , retaddr);for (i =0 ; i <8 ; i++) { - new_regs[i] =cpu_lduw_kernel_ra (env, tss_base + (0x12 + i *2 ), - retaddr) |0xffff0000 ; + new_regs[i] =cpu_lduw_kernel_ra (env, tss_base + (0x12 + i *2 ), retaddr); }for (i =0 ; i <4 ; i++) { new_segs[i] = cpu_lduw_kernel_ra(env, tss_base + (0x22 + i * 2),
@@ -391,19 +390,17 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector, env->eip = new_eip; eflags_mask =TF_MASK |AC_MASK |ID_MASK |IF_MASK |IOPL_MASK |VM_MASK |RF_MASK |NT_MASK ; -if (!(type &8 )) { - eflags_mask &=0xffff ; +if (type &8 ) { +cpu_load_eflags (env, new_eflags, eflags_mask); +for (i =0 ; i <8 ; i++) { + env->regs[i] = new_regs[i]; + } + }else { +cpu_load_eflags (env, new_eflags, eflags_mask &0xffff ); +for (i =0 ; i <8 ; i++) { + env->regs[i] = (env->regs[i] &0xffff0000 ) | new_regs[i]; + } } -cpu_load_eflags (env, new_eflags, eflags_mask); -/* XXX: what to do in 16 bit case? */ - env->regs[R_EAX ] = new_regs[0 ]; - env->regs[R_ECX ] = new_regs[1 ]; - env->regs[R_EDX ] = new_regs[2 ]; - env->regs[R_EBX ] = new_regs[3 ]; - env->regs[R_ESP ] = new_regs[4 ]; - env->regs[R_EBP ] = new_regs[5 ]; - env->regs[R_ESI ] = new_regs[6 ]; - env->regs[R_EDI ] = new_regs[7 ];if (new_eflags &VM_MASK ) {for (i =0 ; i <6 ; i++) {load_seg_vm (env, i, new_segs[i]);
Signature · 1 line
2.31.1
[PULL 13/13] vl: plug -object back into -readconfig
In reply to Paolo BonziniCommit bc2f4fcb1d ("qom: move user_creatable_add_opts logic to vl.c and QAPIfy it", 2021-03-19) switched the creation of objects from qemu_opts_foreach to a bespoke QTAILQ in preparation for supporting JSON syntax in -object.
Unfortunately in doing so it lost support for [object] stanzas in configuration files and also for "-set object.ID.KEY=VAL". The latter is hard to re-establish and probably best solved by deprecating -set. This patch uses the infrastructure introduced by the previous two patches in order to parse QOM objects correctly from configuration files.
Message-Id: <[email protected]>
--- softmmu/vl.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
softmmu/vl.c +18 -6
@@ -1722,9 +1722,15 @@ static void object_option_foreach_add(bool (*type_opt_predicate)(const char *)) } } +static void object_option_add_visitor (Visitor *v) +{ +ObjectOption *opt =g_new0 (ObjectOption,1 ); +visit_type_ObjectOptions (v,NULL , &opt->opts, &error_fatal); +QTAILQ_INSERT_TAIL (&object_opts, opt, next); +} +static void object_option_parse (const char *optarg) { -ObjectOption *opt;QemuOpts *opts;const char *type;Visitor *v;
@@ -1752,11 +1758,8 @@ static void object_option_parse(const char *optarg) v =opts_visitor_new (opts); } - opt =g_new0 (ObjectOption,1 ); -visit_type_ObjectOptions (v,NULL , &opt->opts, &error_fatal); +object_option_add_visitor (v);visit_free (v); - -QTAILQ_INSERT_TAIL (&object_opts, opt, next); }/*
@@ -2134,13 +2137,22 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)*/ static bool is_qemuopts_group (const char *group) { +if (g_str_equal (group,"object" )) { +return false; + }return true; }static void qemu_record_config_group (const char *group,QDict *dict,bool from_json,Error **errp) { -abort (); +if (g_str_equal (group,"object" )) { +Visitor *v =qobject_input_visitor_new_keyval (QOBJECT (dict)); +object_option_add_visitor (v); +visit_free (v); + }else { +abort (); + } }/*
Signature · 1 line
2.31.1
[PULL 12/13] vl: plumb keyval-based options into -readconfig
In reply to Paolo BonziniLet -readconfig support parsing command line options into QDict or QemuOpts. This will be used to add back support for objects in -readconfig.
Message-Id: <[email protected]>
--- include/block/qdict.h | 2 - include/qapi/qmp/qdict.h | 3 ++ softmmu/vl.c | 83 ++++++++++++++++++++++++++++------------ 3 files changed, 62 insertions(+), 26 deletions(-)
include/block/qdict.h +0 -2
@@ -20,8 +20,6 @@ void qdict_join(QDict *dest, QDict *src, bool overwrite);void qdict_extract_subqdict (QDict *src,QDict **dst,const char *start);void qdict_array_split (QDict *src,QList **dst);int qdict_array_entries (QDict *src,const char *subqdict); -QObject *qdict_crumple (const QDict *src,Error **errp); -void qdict_flatten (QDict *qdict); typedef struct QDictRenames { const char *from;
include/qapi/qmp/qdict.h +3 -0
@@ -64,4 +64,7 @@ const char *qdict_get_try_str(const QDict *qdict, const char *key);QDict *qdict_clone_shallow (const QDict *src); +QObject *qdict_crumple (const QDict *src,Error **errp); +void qdict_flatten (QDict *qdict); +#endif /* QDICT_H */
softmmu/vl.c +59 -24
129 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PULL 12/13] vl: plumb keyval-based options into -readconfig
Quoted 11 lines · Paolo Bonzini
Let -readconfig support parsing command line options into QDict or QemuOpts. This will be used to add back support for objects in -readconfig.
Cc Markus Armbruster <[email protected]>Reviewed-by Kevin Wolf <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>
Hi; Coverity suspects a resource leak in this code (CID 1457455):
Quoted 4 lines
softmmu/vl.c +4
-0+/* +* Parse non-QemuOpts config file groups, pass the rest to +* qemu_config_do_parse. +*/
softmmu/vl.c static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) · line 2159
Quoted 10 lines
softmmu/vl.c +10
-0+static void qemu_parse_config_group (const char *group,QDict *qdict, +void *opaque,Error **errp) +{ +QObject *crumpled; +if (is_qemuopts_group (group)) { +qemu_config_do_parse (group, qdict, opaque, errp); +return ; + } + + crumpled =qdict_crumple (qdict, errp);
It thinks qdict_crumple() allocates memory...
softmmu/vl.c static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) · line 2165
Quoted 6 lines
softmmu/vl.c +6
-0+if (!crumpled) { +return ; + } +if (qobject_type (crumpled) !=QTYPE_QDICT ) { +assert (qobject_type (crumpled) ==QTYPE_QLIST ); +error_setg (errp,"Lists cannot be at top level of a configuration section" );
...but here we return without freeing/derefing it or keeping track of the pointer anywhere...
softmmu/vl.c static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) · line 2168
Quoted 3 lines
softmmu/vl.c +3
-0+return ; + } +qemu_record_config_group (group,qobject_to (QDict, crumpled), false, errp);
...and here it thinks that qemu_record_config_group does not free or keep a pointer to 'crumpled', though in this case I suspect it is wrong.
More general question: where should I look to find documentation on what functions take 'ownership' of a reference-counted object? I often find when trying to analyse Coverity reports like these that I am just as confused as it is about whether a function really has taken ownership of something or whether the caller kept ownership and needed to deref it...
thanks
-- PMM
[PULL 06/13] target/i386: tcg: fix switching from 16-bit to 32-bit tasks or vice versa
In reply to Paolo BonziniThe format of the task state segment is governed by bit 3 in the descriptor type field. On a task switch, the format for saving is given by the current value of TR's type field, while the format for loading is given by the new descriptor.
--- target/i386/tcg/seg_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/tcg/seg_helper.c +1 -1
@@ -319,7 +319,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_selector, }/* save the current state in the old TSS */ -if (type &8 ) { +if (old_type &8 ) {/* 32 bit */ cpu_stl_kernel_ra (env, env->tr.base +0x20 , next_eip, retaddr);cpu_stl_kernel_ra (env, env->tr.base +0x24 , old_eflags, retaddr);
Signature · 1 line
2.31.1
[PULL 07/13] target/i386: Fix decode of cr8
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
A recent cleanup did not recognize that there are two ways to encode cr8: one via the LOCK and the other via REX.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/380
Message-Id: <[email protected]>
--- target/i386/tcg/translate.c | 1 + 1 file changed, 1 insertion(+)
target/i386/tcg/translate.c +1 -0
@@ -8091,6 +8091,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)case 2 :case 3 :case 4 : +case 8 :break ;default : goto unknown_op;
Signature · 1 line
2.31.1
[PULL 09/13] i386: reorder call to cpu_exec_realizefn
In reply to Paolo BonziniFrom: Claudio Fontana <[email protected]>
i386 realizefn code is sensitive to ordering, and recent commits aimed at refactoring it, splitting accelerator-specific code, broke assumptions which need to be fixed.
We need to:
* process hyper-v enlightements first, as they assume features not to be expanded
* only then, expand features
* after expanding features, attempt to check them and modify them in the accel-specific realizefn code called by cpu_exec_realizefn().
* after the framework has been called via cpu_exec_realizefn, the code can check for what has or hasn't been set by accel-specific code, or extend its results, ie:
- check and evenually set code_urev default
- modify cpu->mwait after potentially being set from host CPUID.
- finally check for phys_bits assuming all user and accel-specific adjustments have already been taken into account.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 79 +++++++++++++++++++++++++-------------- target/i386/kvm/kvm-cpu.c | 12 +++++- 2 files changed, 61 insertions(+), 30 deletions(-)
target/i386/cpu.c +51 -28
@@ -6089,39 +6089,17 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)Error *local_err =NULL ;static bool ht_warned; -/* Process Hyper-V enlightenments */ -x86_cpu_hyperv_realize (cpu); - -cpu_exec_realizefn (cs, &local_err); -if (local_err !=NULL ) { -error_propagate (errp, local_err); -return ; - } - -if (xcc->host_cpuid_required && !accel_uses_host_cpuid ()) { - g_autofree char *name = x86_cpu_class_get_model_name(xcc); -error_setg (&local_err,"CPU model '%s' requires KVM or HVF" , name); - goto out; - } - -if (cpu->ucode_rev ==0 ) { -/* The default is the same as KVM's. */ -if (IS_AMD_CPU (env)) { - cpu->ucode_rev =0x01000065 ; - }else { - cpu->ucode_rev =0x100000000ULL ; - } - } - -/* mwait extended info: needed for Core compatibility */ -/* We always wake on interrupt even if host does not have the capability */ - cpu->mwait.ecx |=CPUID_MWAIT_EMX |CPUID_MWAIT_IBE ; -if (cpu->apic_id ==UNASSIGNED_APIC_ID ) {error_setg (errp,"apic-id property was not initialized properly" );return ; } +/* +* Process Hyper-V enlightenments. +* Note: this currently has to happen before the expansion of CPU features. +*/ +x86_cpu_hyperv_realize (cpu); +x86_cpu_expand_features (cpu, &local_err);if (local_err) { goto out;
@@ -6146,11 +6124,56 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) & CPUID_EXT2_AMD_ALIASES); } +/* +* note: the call to the framework needs to happen after feature expansion, +* but before the checks/modifications to ucode_rev, mwait, phys_bits. +* These may be set by the accel-specific code, +* and the results are subsequently checked / assumed in this function. +*/ +cpu_exec_realizefn (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + } + +if (xcc->host_cpuid_required && !accel_uses_host_cpuid ()) { + g_autofree char *name = x86_cpu_class_get_model_name(xcc); +error_setg (&local_err,"CPU model '%s' requires KVM or HVF" , name); + goto out; + } + +if (cpu->ucode_rev ==0 ) { +/* +* The default is the same as KVM's. Note that this check +* needs to happen after the evenual setting of ucode_rev in +* accel-specific code in cpu_exec_realizefn. +*/ +if (IS_AMD_CPU (env)) { + cpu->ucode_rev =0x01000065 ; + }else { + cpu->ucode_rev =0x100000000ULL ; + } + } + +/* +* mwait extended info: needed for Core compatibility +* We always wake on interrupt even if host does not have the capability. +* +* requires the accel-specific code in cpu_exec_realizefn to +* have already acquired the CPUID data into cpu->mwait. +*/ + cpu->mwait.ecx |=CPUID_MWAIT_EMX |CPUID_MWAIT_IBE ; +/* For 64bit systems think about the number of physical bits to present. * ideally this should be the same as the host; anything other than matching * the host can cause incorrect guest behaviour. * QEMU used to pick the magic value of 40 bits that corresponds to * consumer AMD devices but nothing else. +* +* Note that this code assumes features expansion has already been done +* (as it checks for CPUID_EXT2_LM), and also assumes that potential +* phys_bits adjustments to match the host have been already done in +* accel-specific code in cpu_exec_realizefn. */ if (env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_LM ) { if (cpu->phys_bits &&
target/i386/kvm/kvm-cpu.c +10 -2
@@ -26,10 +26,18 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)/* * The realize order is important, since x86_cpu_realize() checks if * nothing else has been set by the user (or by accelerators) in -* cpu->ucode_rev and cpu->phys_bits. +* cpu->ucode_rev and cpu->phys_bits, and updates the CPUID results in +* mwait.ecx. +* This accel realization code also assumes cpu features are already expanded. * * realize order: -* kvm_cpu -> host_cpu -> x86_cpu +* +* x86_cpu_realize(): +* -> x86_cpu_expand_features() +* -> cpu_exec_realizefn(): +* -> accel_cpu_realizefn() +* kvm_cpu_realizefn() -> host_cpu_realizefn() +* -> check/update ucode_rev, phys_bits, mwait */ if (cpu->max_features) {if (enable_cpu_pm &&kvm_has_waitpkg ()) {
Signature · 1 line
2.31.1
Peter Maydell
AppliedQuoted 13 lines · Paolo Bonzini
The following changes since commit
5a95f5ce3cd5842cc8f61a91ecd4fb4e8d10104f:Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-fpu-20210603' into staging (2021-06-04 10:04:11 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
49e987695a1873a769a823604f9065aa88e00c55:vl: plug -object back into -readconfig (2021-06-04 13:50:04 +0200)
Quoted 9 lines
----------------------------------------------------------------
* OpenBSD cleanup (Brad)
* fixes for the i386 accel/cpu refactoring (Claudio)
* unmap test for emulated SCSI (Kit)
* fix for iscsi module (myself)
* fix for -readconfig of objects (myself)
* fixes for x86 16-bit task switching (myself)
* fix for x86 MOV from/to CR8 (Richard)
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.
-- PMM