Misc patches (buildsys, i386, fuzzing) for 2021-01-29
Subsystems (2)
The following changes since commit 0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6:
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2021-01-28 12:30:30 +0000)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 6c52f4644c9c8a18b8495e169e539632a897f135:
accel/kvm/kvm-all: Fix wrong return code handling in dirty log code (2021-01-29 10:38:38 +0100)
----------------------------------------------------------------
* Fuzzing improvements (Qiuhao, Alexander)
* i386: Fix BMI decoding for instructions with the 0x66 prefix (David)
* slirp update (Marc-André)
* initial attempt at fixing event_notifier emulation (Maxim)
* i386: PKS emulation, fix for "qemu-system-i386 -cpu host" (myself)
* meson: RBD test fixes (myself)
* meson: TCI warnings (Philippe)
* Leaner build for --disable-guest-agent, --disable-system and --disable-tools (Philippe, Stefan)
* --enable-tcg-interpreter fix (Richard)
* i386: SVM feature bits (Wei)
* HVF bugfix (Alex)
* KVM bugfix (Thomas)
----------------------------------------------------------------
Alexander Bulekov (7):
fuzz: ignore address_space_map is_write flag
fuzz: refine the ide/ahci fuzzer configs docs/fuzz: fix pre-meson path
fuzz: log the arguments used to initialize QEMU
fuzz: enable dynamic args for generic-fuzz configs docs/fuzz: add some information about OSS-Fuzz
fuzz: add virtio-9p configurations for fuzzing
Alexander Graf (1):
hvf: Fetch cr4 before evaluating CPUID(1)
David Greenaway (1):
target/i386: Fix decoding of certain BMI instructions
Igor Mammedov (1):
machine: add missing doc for memory-backend option
Marc-André Lureau (2):
slirp: update to git master
build-sys: make libslirp a meson subproject
Maxim Levitsky (2):
virtio-scsi: don't uninitialize queues that we didn't initialize
event_notifier: handle initialization failure better
Paolo Bonzini (4):
target/i386: do not set LM for 32-bit emulation "-cpu host/max"
meson: accept either shared or static libraries if --disable-static
meson: honor --enable-rbd if cc.links test fails target/i86: implement PKS
Philippe Mathieu-Daudé (13):
configure: Improve TCI feature description
meson: Explicit TCG backend used
meson: Warn when TCI is selected but TCG backend is available tests/meson: Only build softfloat objects if TCG is selected pc-bios/meson: Only install EDK2 blob firmwares with system emulation
meson: Restrict block subsystem processing
meson: Merge trace_events_subdirs array
meson: Restrict some trace event directories to user/system emulation
meson: Restrict emulation code
qapi/meson: Restrict qdev code to system-mode emulation qapi/meson: Remove QMP from user-mode emulation qapi/meson: Restrict system-mode specific modules qapi/meson: Restrict UI module to system emulation and tools
Qiuhao Li (1):
fuzz: fix wrong index in clear_bits
Richard Henderson (1):
configure: Fix --enable-tcg-interpreter
Stefan Reiter (1):
docs: don't install corresponding man page if guest agent is disabled
Thomas Huth (1):
accel/kvm/kvm-all: Fix wrong return code handling in dirty log code
Wei Huang (1):
x86/cpu: Populate SVM CPUID feature bits
.gitmodules | 4 +- MAINTAINERS | 1 + accel/kvm/kvm-all.c | 21 ++- backends/hostmem.c | 10 ++ configure | 9 +- docs/devel/build-system.rst | 2 +- docs/devel/fuzzing.rst | 35 +++- docs/meson.build | 6 +- hw/scsi/virtio-scsi-dataplane.c | 8 +- include/exec/memory.h | 8 +- include/exec/memory_ldst_cached.h.inc | 6 +- include/qemu/event_notifier.h | 1 + memory_ldst.c.inc | 8 +- meson.build | 277 ++++++++++++++----------------- meson_options.txt | 2 +- pc-bios/meson.build | 1 + qapi/meson.build | 34 ++-- qemu-options.hx | 26 ++- scripts/oss-fuzz/minimize_qtest_trace.py | 2 +- slirp | 2 +- softmmu/memory.c | 5 +- softmmu/physmem.c | 4 +- stubs/meson.build | 2 + stubs/qdev.c | 23 +++ target/i386/cpu.c | 15 +- target/i386/cpu.h | 29 ++-- target/i386/helper.c | 3 + target/i386/hvf/hvf.c | 4 + target/i386/machine.c | 24 ++- target/i386/tcg/excp_helper.c | 32 ++-- target/i386/tcg/misc_helper.c | 14 ++ target/i386/tcg/translate.c | 2 +- tests/meson.build | 11 +- tests/qtest/fuzz/fuzz.c | 11 +- tests/qtest/fuzz/generic_fuzz.c | 19 ++- tests/qtest/fuzz/generic_fuzz_configs.h | 41 ++++- util/event_notifier-posix.c | 16 ++ 37 files changed, 468 insertions(+), 250 deletions(-) create mode 100644 stubs/qdev.c
Signature · 1 line
2.29.2
[PULL 14/36] docs: don't install corresponding man page if guest agent is disabled
From: Stefan Reiter <[email protected]>
No sense outputting the qemu-ga and qemu-ga-ref man pages when the guest agent binary itself is disabled. This mirrors behaviour from before the meson switch.
Message-Id: <[email protected]>
--- docs/meson.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
docs/meson.build +4 -2
@@ -46,9 +46,11 @@ if build_docs meson.source_root() / 'docs/sphinx/qmp_lexer.py', qapi_gen_depends ] + have_ga = have_tools and config_host.has_key('CONFIG_GUEST_AGENT') + man_pages = { - 'qemu-ga.8': (have_tools ? 'man8' : ''), - 'qemu-ga-ref.7': 'man7', + 'qemu-ga.8': (have_ga ? 'man8' : ''), + 'qemu-ga-ref.7': (have_ga ? 'man7' : ''), 'qemu-qmp-ref.7': 'man7', 'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''), 'qemu-img.1': (have_tools ? 'man1' : ''),
Signature · 1 line
2.29.2
[PULL 23/36] slirp: update to git master
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
git cherry-diff:
Commits on bacb71f1c3ed5f40e393afd8be81bedfba13a401 branch that is not on 8f43a99191afb47ca3f3c6972f6306209f367ece branch
+ 1021b0dc38d39f1dc95a296fe3e05a24a087cdc6 disable_dns option
+ 0f94ceec752592e4ac632a24e3c64a97dd09bf4c limit vnameserver_addr to port 53
+ b57bafa852ef16b133907a13678ec69e9531f177 libslirp.h: fix SlirpConfig v3 documentation
+ 1abf18b2b5edb462797629ed47ad4515a195686e Update CHANGELOG
+ ff4ecf9b6c6542b24b4ac6ea178be9d44e159f79 Release v4.3.0
+ 21f1d933050a40d62612c6274c32de60b811d9ea changelog: post-release
+ 376187c4b14c795763d472214812826eebe7e9c2 Release v4.3.1
+ 73336e08902a7e826f7d960453df037380266186 changelog: post-release
+ 5c1c9d43be61571608e9b14615045b67b830daf5 udp, udp6, icmp: handle TTL value
+ 73ed49ab71998d4288e71e954ef6214b70f23d79 icmp, icmp6: Add icmp_forward_error and icmp6_forward_error
+ 7a4840a57ec7dbc37cca1ab96f058a9610b26950 udp, udp6, icmp, icmp6: Enable forwarding errors on Linux
+ e9b2bc19ae652a2907f247e621b2e4773bdd2aab TCPIPHDR_DELTA: Fix potential negative value
+ 39f9a363eec082f04513413046321abd04163148 .gitlab-ci: add a Coverity stage
+ 1b0093b973cfa0dc041522e5d4e6f576b2df642e sosendoob: better document what urgc is used for
+ 5b9ad89ebbb8afa50162c9156fabd5fc56291088 Add G_GNUC_PRINTF to local function slirp_vsnprintf
+ 8a808aa493980e212b4d5f5465330905c8294e59 meson: remove meson-dist script
+ 0b669b5fbe4d3c25a682a67f1059d8633c963b3d meson: support compiling as subproject
+ 9f82a47b81f2864422b82c1e40e51a2ed9c6ac32 Add DNS resolving for iOS
+ c0eac03e8ce1b9a743231f2fe21e7cb579fc9339 Remove the QEMU-special make build-system
+ 1bfd4d9368f9fa2e4f0731e1266bec05bbc83a80 socket: consume empty packets
+ 92413be68914f8cae2f5bad4bf3ab8491dcbc5d7 Release v4.4.0
+ 07e8cfac69766081871ab620d9f16a630543d302 changelog: post-release
+ 4c4e035813313d02b63fdeb920d56fb2fdc0a5b1 Remove some needless (void)casts
+ eee9db9d115d91aa82f33685c4e76d656db92976 fork_exec_child_setup: improve signal handling
+ 216f434a018b3af182a4f31bbe5a00daee170343 Fix unused variables
Message-Id: <[email protected]>
--- slirp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
slirp +1 -1
@@ -1 +1 @@ -Subproject commit 8f43a99191afb47ca3f3c6972f6306209f367ece +Subproject commit 5dce846e3ee82d93462bc637bb0db2fd49f0fc5a
Signature · 1 line
2.29.2
[PULL 25/36] tests/meson: Only build softfloat objects if TCG is selected
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- tests/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tests/meson.build +3 -1
@@ -276,7 +276,9 @@ test('decodetree', sh, workdir: meson.current_source_dir() / 'decode', suite: 'decodetree') -subdir('fp') +if 'CONFIG_TCG' in config_all + subdir('fp') +endif if not get_option('tcg').disabled() if 'CONFIG_PLUGIN' in config_host
Signature · 1 line
2.29.2
[PULL 30/36] meson: Restrict emulation code
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- meson.build | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
meson.build +7 -5
@@ -1784,16 +1784,18 @@ libqemuutil = static_library('qemuutil', qemuutil = declare_dependency(link_with: libqemuutil, sources: genh + version_res) -decodetree = generator(find_program('scripts/decodetree.py'), - output: 'decode-@[email protected]', - arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@']) +if have_system or have_user + decodetree = generator(find_program('scripts/decodetree.py'), + output: 'decode-@[email protected]', + arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@']) + subdir('libdecnumber') + subdir('target') +endif subdir('audio') subdir('io') subdir('chardev') subdir('fsdev') -subdir('libdecnumber') -subdir('target') subdir('dump') if have_block
Signature · 1 line
2.29.2
[PULL 03/36] docs/fuzz: fix pre-meson path
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
Message-Id: <[email protected]>
--- docs/devel/fuzzing.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
docs/devel/fuzzing.rst +2 -3
@@ -119,7 +119,7 @@ Adding a new fuzzer Coverage over virtual devices can be improved by adding additional fuzzers. Fuzzers are kept in ``tests/qtest/fuzz/`` and should be added to -``tests/qtest/fuzz/Makefile.include`` +``tests/qtest/fuzz/meson.build`` Fuzzers can rely on both qtest and libqos to communicate with virtual devices.
@@ -128,8 +128,7 @@ Fuzzers can rely on both qtest and libqos to communicate with virtual devices. 2. Write the fuzzing code using the libqtest/libqos API. See existing fuzzers for reference. -3. Register the fuzzer in ``tests/fuzz/Makefile.include`` by appending the - corresponding object to fuzz-obj-y +3. Add the fuzzer to ``tests/qtest/fuzz/meson.build``. Fuzzers can be more-or-less thought of as special qtest programs which can modify the qtest commands and/or qtest command arguments based on inputs
Signature · 1 line
2.29.2
[PULL 06/36] docs/fuzz: add some information about OSS-Fuzz
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
Message-Id: <[email protected]>
--- docs/devel/fuzzing.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
docs/devel/fuzzing.rst +30 -0
@@ -180,6 +180,36 @@ To ensure that these env variables have been configured correctly, we can use:: The output should contain a complete list of matched MemoryRegions. +OSS-Fuzz +-------- +QEMU is continuously fuzzed on `OSS-Fuzz` __(https://github.com/google/oss-fuzz). +By default, the OSS-Fuzz build will try to fuzz every fuzz-target. Since the +generic-fuzz target requires additional information provided in environment +variables, we pre-define some generic-fuzz configs in +``tests/qtest/fuzz/generic_fuzz_configs.h``. Each config must specify: + +- ``.name``: To identify the fuzzer config + +- ``.args`` OR ``.argfunc``: A string or pointer to a function returning a + string. These strings are used to specify the ``QEMU_FUZZ_ARGS`` + environment variable. ``argfunc`` is useful when the config relies on e.g. + a dynamically created temp directory, or a free tcp/udp port. + +- ``.objects``: A string that specifies the ``QEMU_FUZZ_OBJECTS`` environment + variable. + +To fuzz additional devices/device configuration on OSS-Fuzz, send patches for +either a new device-specific fuzzer or a new generic-fuzz config. + +Build details: + +- The Dockerfile that sets up the environment for building QEMU's + fuzzers on OSS-Fuzz can be fund in the OSS-Fuzz repository + __(https://github.com/google/oss-fuzz/blob/master/projects/qemu/Dockerfile) + +- The script responsible for building the fuzzers can be found in the + QEMU source tree at ``scripts/oss-fuzz/build.sh`` + Implementation Details / Fuzzer Lifecycle -----------------------------------------
Signature · 1 line
2.29.2
[PULL 10/36] meson: accept either shared or static libraries if --disable-static
In reply to Paolo BonziniMeson's "static" argument to cc.find_library is a tri-state. By default Meson *prefers* a shared library, which basically means using -l to look for it; instead, "static: false" *requires* a shared library. Of course, "static: true" requires a static library, which is all good for --enable-static builds.
For --disable-static, "static: false" is rarely desirable; it does not match what the configure script used to do and the test is more complex (and harder to debug if it fails, which was reported by Peter Lieven for librbd).
--- docs/devel/build-system.rst | 2 +- meson.build | 79 +++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 39 deletions(-)
docs/devel/build-system.rst +1 -1
@@ -100,7 +100,7 @@ In meson.build:: # Detect dependency sdl_image = dependency('SDL2_image', required: get_option('sdl_image'), method: 'pkg-config', - static: enable_static) + kwargs: static_kwargs) # Create config-host.h (if applicable) config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
meson.build +41 -38
293 lines not on this page · raw message
Signature · 1 line
2.29.2
[PULL 26/36] pc-bios/meson: Only install EDK2 blob firmwares with system emulation
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- pc-bios/meson.build | 1 + 1 file changed, 1 insertion(+)
pc-bios/meson.build +1 -0
@@ -12,6 +12,7 @@ if install_edk2_blobs foreach f : fds custom_target(f, + build_by_default: have_system, output: f, input: '@[email protected]'.format(f), capture: true,
Signature · 1 line
2.29.2
[PULL 01/36] fuzz: ignore address_space_map is_write flag
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
We passed an is_write flag to the fuzz_dma_read_cb function to differentiate between the mapped DMA regions that need to be populated with fuzzed data, and those that don't. We simply passed through the address_space_map is_write parameter. The goal was to cut down on unnecessarily populating mapped DMA regions, when they are not read from.
Unfortunately, nothing precludes code from reading from regions mapped with is_write=true. For example, see:
https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg04729.html
This patch removes the is_write parameter to fuzz_dma_read_cb. As a result, we will fill all mapped DMA regions with fuzzed data, ignoring the specified transfer direction.
Message-Id: <[email protected]>
--- include/exec/memory.h | 8 +++----- include/exec/memory_ldst_cached.h.inc | 6 +++--- memory_ldst.c.inc | 8 ++++---- softmmu/memory.c | 5 ++--- softmmu/physmem.c | 4 ++-- tests/qtest/fuzz/generic_fuzz.c | 9 +++------ 6 files changed, 17 insertions(+), 23 deletions(-)
include/exec/memory.h +3 -5
@@ -45,13 +45,11 @@ DECLARE_OBJ_CHECKERS(IOMMUMemoryRegion, IOMMUMemoryRegionClass,#ifdef CONFIG_FUZZ void fuzz_dma_read_cb (size_t addr,size_t len, -MemoryRegion *mr, -bool is_write); +MemoryRegion *mr);#else static inline void fuzz_dma_read_cb (size_t addr,size_t len, -MemoryRegion *mr, -bool is_write) +MemoryRegion *mr) {/* Do Nothing */ }
@@ -2504,7 +2502,7 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr, void *buf, hwaddr len) {assert (addr < cache->len && len <= cache->len - addr); -fuzz_dma_read_cb (cache->xlat + addr, len, cache->mrs.mr, false); +fuzz_dma_read_cb (cache->xlat + addr, len, cache->mrs.mr);if (likely (cache->ptr)) {memcpy (buf, cache->ptr + addr, len);return MEMTX_OK ;
include/exec/memory_ldst_cached.h.inc +3 -3
@@ -28,7 +28,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(l)(MemoryRegionCache *cache, hwaddr addr, MemTxAttrs attrs, MemTxResult *result) { assert(addr < cache->len && 4 <= cache->len - addr); - fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr, false); + fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr); if (likely(cache->ptr)) { return LD_P(l)(cache->ptr + addr); } else {
@@ -40,7 +40,7 @@ static inline uint64_t ADDRESS_SPACE_LD_CACHED(q)(MemoryRegionCache *cache, hwaddr addr, MemTxAttrs attrs, MemTxResult *result) { assert(addr < cache->len && 8 <= cache->len - addr); - fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr, false); + fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr); if (likely(cache->ptr)) { return LD_P(q)(cache->ptr + addr); } else {
@@ -52,7 +52,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(uw)(MemoryRegionCache *cache, hwaddr addr, MemTxAttrs attrs, MemTxResult *result) { assert(addr < cache->len && 2 <= cache->len - addr); - fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr, false); + fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr); if (likely(cache->ptr)) { return LD_P(uw)(cache->ptr + addr); } else {
memory_ldst.c.inc +4 -4
@@ -42,7 +42,7 @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, MO_32 | devend_memop(endian), attrs); } else { /* RAM case */ - fuzz_dma_read_cb(addr, 4, mr, false); + fuzz_dma_read_cb(addr, 4, mr); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN:
@@ -111,7 +111,7 @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, MO_64 | devend_memop(endian), attrs); } else { /* RAM case */ - fuzz_dma_read_cb(addr, 8, mr, false); + fuzz_dma_read_cb(addr, 8, mr); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN:
@@ -177,7 +177,7 @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, r = memory_region_dispatch_read(mr, addr1, &val, MO_8, attrs); } else { /* RAM case */ - fuzz_dma_read_cb(addr, 1, mr, false); + fuzz_dma_read_cb(addr, 1, mr); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); val = ldub_p(ptr); r = MEMTX_OK;
@@ -215,7 +215,7 @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, MO_16 | devend_memop(endian), attrs); } else { /* RAM case */ - fuzz_dma_read_cb(addr, 2, mr, false); + fuzz_dma_read_cb(addr, 2, mr); ptr = qemu_map_ram_ptr(mr->ram_block, addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN:
softmmu/memory.c +2 -3
@@ -1440,7 +1440,7 @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr,unsigned size =memop_size (op);MemTxResult r; -fuzz_dma_read_cb (addr, size, mr, false); +fuzz_dma_read_cb (addr, size, mr);if (!memory_region_access_valid (mr, addr, size, false, attrs)) { *pval =unassigned_mem_read (mr, addr, size);return MEMTX_DECODE_ERROR ;
@@ -3282,8 +3282,7 @@ void memory_region_init_rom_device(MemoryRegion *mr,#ifdef CONFIG_FUZZ void __attribute__((weak))fuzz_dma_read_cb (size_t addr,size_t len, -MemoryRegion *mr, -bool is_write) +MemoryRegion *mr) { }#endif
softmmu/physmem.c +2 -2
@@ -2824,7 +2824,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,stn_he_p (buf, l, val); }else {/* RAM case */ -fuzz_dma_read_cb (addr, len, mr, false); +fuzz_dma_read_cb (addr, len, mr); ram_ptr =qemu_ram_ptr_length (mr->ram_block, addr1, &l, false);memcpy (buf, ram_ptr, l); }
@@ -3185,7 +3185,7 @@ void *address_space_map(AddressSpace *as,memory_region_ref (mr); *plen =flatview_extend_translation (fv, addr, len, mr, xlat, l, is_write, attrs); -fuzz_dma_read_cb (addr, *plen, mr, is_write); +fuzz_dma_read_cb (addr, *plen, mr); ptr =qemu_ram_ptr_length (mr->ram_block, xlat, plen, true);return ptr;
tests/qtest/fuzz/generic_fuzz.c +3 -6
@@ -175,7 +175,7 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)* generic_fuzz(), avoiding potential race-conditions, which we don't have * a good way for reproducing right now. */ -void fuzz_dma_read_cb (size_t addr,size_t len,MemoryRegion *mr,bool is_write) +void fuzz_dma_read_cb (size_t addr,size_t len,MemoryRegion *mr) {/* Are we in the generic-fuzzer or are we using another fuzz-target? */ if (!qts_global) {
@@ -187,14 +187,11 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr, bool is_write)* - We have no DMA patterns defined * - The length of the DMA read request is zero * - The DMA read is hitting an MR other than the machine's main RAM -* - The DMA request is not a read (what happens for a address_space_map -* with is_write=True? Can the device use the same pointer to do reads?) * - The DMA request hits past the bounds of our RAM */ if (dma_patterns->len ==0 || len ==0 || mr != current_machine->ram - || is_write || addr > current_machine->ram_size) {return ; }
@@ -213,12 +210,12 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr, bool is_write) double_fetch = true;if (addr < region.addr && avoid_double_fetches) { -fuzz_dma_read_cb (addr, region.addr - addr, mr, is_write); +fuzz_dma_read_cb (addr, region.addr - addr, mr); }if (addr + len > region.addr + region.size && avoid_double_fetches) {fuzz_dma_read_cb (region.addr + region.size, - addr + len - (region.addr + region.size), mr, is_write); + addr + len - (region.addr + region.size), mr); }return ; }
Signature · 1 line
2.29.2
[PULL 05/36] fuzz: enable dynamic args for generic-fuzz configs
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
For some device configurations, it is useful to configure some resources, and adjust QEMU arguments at runtime, prior to fuzzing. This patch adds an "argfunc" to generic the generic_fuzz_config. When specified, it is responsible for configuring the resources and returning a string containing the corresponding QEMU arguments. This can be useful for targets that rely on e.g.:
* a temporary qcow2 image
* a temporary directory
* an unused TCP port used to bind the VNC server
Message-Id: <[email protected]>
--- tests/qtest/fuzz/generic_fuzz.c | 10 +++++++++- tests/qtest/fuzz/generic_fuzz_configs.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)
tests/qtest/fuzz/generic_fuzz.c +9 -1
@@ -933,12 +933,20 @@ static GString *generic_fuzz_cmdline(FuzzTarget *t)static GString *generic_fuzz_predefined_config_cmdline (FuzzTarget *t) { +gchar *args;const generic_fuzz_config *config;g_assert (t->opaque); config = t->opaque;setenv ("QEMU_AVOID_DOUBLE_FETCH" ,"1" ,1 ); -setenv ("QEMU_FUZZ_ARGS" , config->args,1 ); +if (config->argfunc) { + args = config->argfunc (); +setenv ("QEMU_FUZZ_ARGS" , args,1 ); +g_free (args); + }else { +g_assert_nonnull (config->args); +setenv ("QEMU_FUZZ_ARGS" , config->args,1 ); + }setenv ("QEMU_FUZZ_OBJECTS" , config->objects,1 );return generic_fuzz_cmdline (t); }
tests/qtest/fuzz/generic_fuzz_configs.h +1 -0
@@ -16,6 +16,7 @@typedef struct generic_fuzz_config {const char *name, *args, *objects; +gchar * (*argfunc)(void );/* Result must be freeable by g_free() */ }generic_fuzz_config ;const generic_fuzz_config predefined_configs[] = {
Signature · 1 line
2.29.2
[PULL 27/36] meson: Restrict block subsystem processing
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Avoid generating module_block.h and block-gen.c if we are not going to use them.
Message-Id: <[email protected]>
--- meson.build | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-)
meson.build +25 -23
@@ -1794,29 +1794,31 @@ subdir('libdecnumber') subdir('target') subdir('dump') -block_ss.add(files( - 'block.c', - 'blockjob.c', - 'job.c', - 'qemu-io-cmds.c', -)) -block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c')) - -subdir('nbd') -subdir('scsi') -subdir('block') - -blockdev_ss.add(files( - 'blockdev.c', - 'blockdev-nbd.c', - 'iothread.c', - 'job-qmp.c', -), gnutls) - -# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon, -# os-win32.c does not -blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c')) -softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')]) +if have_block + block_ss.add(files( + 'block.c', + 'blockjob.c', + 'job.c', + 'qemu-io-cmds.c', + )) + block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c')) + + subdir('nbd') + subdir('scsi') + subdir('block') + + blockdev_ss.add(files( + 'blockdev.c', + 'blockdev-nbd.c', + 'iothread.c', + 'job-qmp.c', + ), gnutls) + + # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon, + # os-win32.c does not + blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c')) + softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')]) +endif common_ss.add(files('cpus-common.c'))
Signature · 1 line
2.29.2
[PULL 02/36] fuzz: refine the ide/ahci fuzzer configs
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
Disks work differently depending on the x86 machine type (SATA vs PATA). Additionally, we should fuzz the atapi code paths, which might contain vulnerabilities such as CVE-2020-29443. This patch adds hard-disk and cdrom generic-fuzzer configs for both the pc (PATA) and q35 (SATA) machine types.
Message-Id: <[email protected]>
--- tests/qtest/fuzz/generic_fuzz_configs.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
tests/qtest/fuzz/generic_fuzz_configs.h +19 -1
@@ -85,10 +85,28 @@ const generic_fuzz_config predefined_configs[] = { .objects = "intel-hda", },{ .name = "ide-hd", + .args = "-machine pc -nodefaults " + "-drive file=null-co://,if=none,format=raw,id=disk0 " + "-device ide-hd,drive=disk0", + .objects = "*ide*", + },{ + .name = "ide-atapi", + .args = "-machine pc -nodefaults " + "-drive file=null-co://,if=none,format=raw,id=disk0 " + "-device ide-cd,drive=disk0", + .objects = "*ide*", + },{ + .name = "ahci-hd", .args = "-machine q35 -nodefaults " "-drive file=null-co://,if=none,format=raw,id=disk0 " "-device ide-hd,drive=disk0", - .objects = "ahci*", + .objects = "*ahci*", + },{ + .name = "ahci-atapi", + .args = "-machine q35 -nodefaults " + "-drive file=null-co://,if=none,format=raw,id=disk0 " + "-device ide-cd,drive=disk0", + .objects = "*ahci*", },{ .name = "floppy", .args = "-machine pc -nodefaults -device floppy,id=floppy0 "
Signature · 1 line
2.29.2
[PULL 09/36] machine: add missing doc for memory-backend option
In reply to Paolo BonziniFrom: Igor Mammedov <[email protected]>
Add documentation for '-machine memory-backend' CLI option and how to use it.
And document that x-use-canonical-path-for-ramblock-id,
is considered to be stable to make sure it won't go away by accident.
x- was intended for unstable/iternal properties, and not supposed to be stable option. However it's too late to rename (drop x-) it as it would mean that users will have to mantain both x-use-canonical-path-for-ramblock-id (for QEMU 5.0-5.2) versions and prefix-less for later versions.
Message-Id: <[email protected]>
--- backends/hostmem.c | 10 ++++++++++ qemu-options.hx | 26 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-)
backends/hostmem.c +10 -0
@@ -498,6 +498,16 @@ host_memory_backend_class_init(ObjectClass *oc, void *data) host_memory_backend_get_share, host_memory_backend_set_share);object_class_property_set_description (oc,"share" ,"Mark the memory as private to QEMU or shared" ); +/* +* Do not delete/rename option. This option must be considered stable +* (as if it didn't have the 'x-' prefix including deprecation period) as +* long as 4.0 and older machine types exists. +* Option will be used by upper layers to override (disable) canonical path +* for ramblock-id set by compat properties on old machine types ( <= 4.0), +* to keep migration working when backend is used for main RAM with +* -machine memory-backend= option (main RAM historically used prefix-less +* ramblock-id). +*/ object_class_property_add_bool (oc,"x-use-canonical-path-for-ramblock-id" , host_memory_backend_get_use_canonical_path, host_memory_backend_set_use_canonical_path);
qemu-options.hx +25 -1
@@ -35,7 +35,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " suppress-vmdesc=on|off disables self-describing migration (default=off)\n" " nvdimm=on|off controls NVDIMM support (default=off)\n" " memory-encryption=@var{} memory encryption object to use (default=none)\n" - " hmat=on|off controls ACPI HMAT support (default=off)\n", + " hmat=on|off controls ACPI HMAT support (default=off)\n" + " memory-backend='backend-id' specifies explicitly provided backend for main RAM (default=none)\n", QEMU_ARCH_ALL) SRST ``-machine [type=]name[,prop=value[,...]]``
@@ -96,6 +97,29 @@ SRST ``hmat=on|off`` Enables or disables ACPI Heterogeneous Memory Attribute Table (HMAT) support. The default is off. + + ``memory-backend='id'`` + An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. + Allows to use a memory backend as main RAM. + + For example: + :: + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on + -machine memory-backend=pc.ram + -m 512M + + Migration compatibility note: + a) as backend id one shall use value of 'default-ram-id', advertised by + machine type (available via ``query-machines`` QMP command), if migration + to/from old QEMU (<5.0) is expected. + b) for machine types 4.0 and older, user shall + use ``x-use-canonical-path-for-ramblock-id=off`` backend option + if migration to/from old QEMU (<5.0) is expected. + For example: + :: + -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off + -machine memory-backend=pc.ram + -m 512M ERST HXCOMM Deprecated by -machine
Signature · 1 line
2.29.2
[PULL 28/36] meson: Merge trace_events_subdirs array
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
The trace_events_subdirs array is split in two different locations, merge it as one.
Message-Id: <[email protected]>
--- meson.build | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
meson.build +13 -15
@@ -1661,7 +1661,20 @@ trace_events_subdirs = [ 'accel/kvm', 'accel/tcg', 'crypto', + 'hw/core', + 'qapi', + 'qom', 'monitor', + 'target/arm', + 'target/hppa', + 'target/i386', + 'target/i386/kvm', + 'target/mips', + 'target/ppc', + 'target/riscv', + 'target/s390x', + 'target/sparc', + 'util', ] if have_user trace_events_subdirs += [ 'linux-user' ]
@@ -1734,21 +1747,6 @@ if have_system 'ui', ] endif -trace_events_subdirs += [ - 'hw/core', - 'qapi', - 'qom', - 'target/arm', - 'target/hppa', - 'target/i386', - 'target/i386/kvm', - 'target/mips', - 'target/ppc', - 'target/riscv', - 'target/s390x', - 'target/sparc', - 'util', -] vhost_user = not_found if 'CONFIG_VHOST_USER' in config_host
Signature · 1 line
2.29.2
[PULL 04/36] fuzz: log the arguments used to initialize QEMU
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
This is useful for building reproducers. Instead checking the code or the QEMU_FUZZ_ARGS, the arguments are at the top of the crash log.
Message-Id: <[email protected]>
--- tests/qtest/fuzz/fuzz.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tests/qtest/fuzz/fuzz.c +10 -1
@@ -159,6 +159,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)char *target_name;const char *bindir;char *datadir; +GString *cmd_line; +gchar *pretty_cmd_line;bool serialize = false;/* Initialize qgraph and modules */
@@ -217,7 +219,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) }/* Run QEMU's softmmu main with the fuzz-target dependent arguments */ -GString *cmd_line = fuzz_target->get_init_cmdline (fuzz_target); + cmd_line = fuzz_target->get_init_cmdline (fuzz_target);g_string_append_printf (cmd_line," %s -qtest /dev/null " ,getenv ("QTEST_LOG" ) ?"" :"-qtest-log none" );
@@ -226,6 +228,13 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)wordexp (cmd_line->str, &result,0 );g_string_free (cmd_line, true); +if (getenv ("QTEST_LOG" )) { + pretty_cmd_line =g_strjoinv (" " , result.we_wordv +1 ); +printf ("Starting %s with Arguments: %s\n" , + result.we_wordv[0 ], pretty_cmd_line); +g_free (pretty_cmd_line); + } +qemu_init (result.we_wordc, result.we_wordv,NULL );/* re-enable the rcu atfork, which was previously disabled in qemu_init */
Signature · 1 line
2.29.2
[PULL 12/36] x86/cpu: Populate SVM CPUID feature bits
In reply to Paolo BonziniFrom: Wei Huang <[email protected]>
Newer AMD CPUs will add CPUID_0x8000000A_EDX[28] bit, which indicates that SVM instructions (VMRUN/VMSAVE/VMLOAD) will trigger #VMEXIT before CPU checking their EAX against reserved memory regions. This change will allow the hypervisor to avoid intercepting #GP and emulating SVM instructions. KVM turns on this CPUID bit for nested VMs. In order to support it, let us populate this bit, along with other SVM feature bits, in FEAT_SVM.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 6 +++--- target/i386/cpu.h | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-)
target/i386/cpu.c +3 -3
@@ -926,11 +926,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {"npt" ,"lbrv" ,"svm-lock" ,"nrip-save" ,"tsc-scale" ,"vmcb-clean" ,"flushbyasid" ,"decodeassists" ,NULL ,NULL ,"pause-filter" ,NULL , -"pfthreshold" ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL , +"pfthreshold" ,"avic" ,NULL ,"v-vmsave-vmload" , +"vgif" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , + "svme-addr-chk", NULL, NULL, NULL, }, .cpuid = { .eax = 0x8000000A, .reg = R_EDX, }, .tcg_features = TCG_SVM_FEATURES,
target/i386/cpu.h +14 -10
@@ -670,16 +670,20 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];#define CPUID_EXT3_PERFCORE (1U << 23)#define CPUID_EXT3_PERFNB (1U << 24) -#define CPUID_SVM_NPT (1U << 0) -#define CPUID_SVM_LBRV (1U << 1) -#define CPUID_SVM_SVMLOCK (1U << 2) -#define CPUID_SVM_NRIPSAVE (1U << 3) -#define CPUID_SVM_TSCSCALE (1U << 4) -#define CPUID_SVM_VMCBCLEAN (1U << 5) -#define CPUID_SVM_FLUSHASID (1U << 6) -#define CPUID_SVM_DECODEASSIST (1U << 7) -#define CPUID_SVM_PAUSEFILTER (1U << 10) -#define CPUID_SVM_PFTHRESHOLD (1U << 12) +#define CPUID_SVM_NPT (1U << 0) +#define CPUID_SVM_LBRV (1U << 1) +#define CPUID_SVM_SVMLOCK (1U << 2) +#define CPUID_SVM_NRIPSAVE (1U << 3) +#define CPUID_SVM_TSCSCALE (1U << 4) +#define CPUID_SVM_VMCBCLEAN (1U << 5) +#define CPUID_SVM_FLUSHASID (1U << 6) +#define CPUID_SVM_DECODEASSIST (1U << 7) +#define CPUID_SVM_PAUSEFILTER (1U << 10) +#define CPUID_SVM_PFTHRESHOLD (1U << 12) +#define CPUID_SVM_AVIC (1U << 13) +#define CPUID_SVM_V_VMSAVE_VMLOAD (1U << 15) +#define CPUID_SVM_VGIF (1U << 16) +#define CPUID_SVM_SVME_ADDR_CHK (1U << 28)/* Support RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */ #define CPUID_7_0_EBX_FSGSBASE (1U << 0)
Signature · 1 line
2.29.2
[PULL 31/36] qapi/meson: Restrict qdev code to system-mode emulation
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Beside a CPU device, user-mode emulation doesn't access anything else from qdev subsystem.
Tools don't need anything from qdev.
Message-Id: <[email protected]>
--- MAINTAINERS | 1 + qapi/meson.build | 6 +++++- stubs/meson.build | 2 ++ stubs/qdev.c | 23 +++++++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 stubs/qdev.c
MAINTAINERS +1 -0
@@ -2523,6 +2523,7 @@ F: qapi/qom.json F: qapi/qdev.json F: scripts/coccinelle/qom-parent-type.cocci F: softmmu/qdev-monitor.c +F: stubs/qdev.c F: qom/ F: tests/check-qom-interface.c F: tests/check-qom-proplist.c
qapi/meson.build +5 -1
@@ -35,7 +35,6 @@ qapi_all_modules = [ 'misc-target', 'net', 'pragma', - 'qdev', 'pci', 'qom', 'rdma',
@@ -49,6 +48,11 @@ qapi_all_modules = [ 'ui', 'yank', ] +if have_system + qapi_all_modules += [ + 'qdev', + ] +endif qapi_storage_daemon_modules = [ 'block-core',
stubs/meson.build +2 -0
@@ -53,4 +53,6 @@ endif if have_system stub_ss.add(files('semihost.c')) stub_ss.add(files('xen-hw-stub.c')) +else + stub_ss.add(files('qdev.c')) endif
stubs/qdev.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* QOM stubs +* +* Copyright (c) 2021 Red Hat, Inc. +* +* Author: +* Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "qapi/qapi-events-qdev.h" + +void qapi_event_send_device_deleted (bool has_device, +const char *device, +const char *path) +{ +/* Nothing to do. */ +}
Signature · 1 line
2.29.2
[PULL 07/36] fuzz: add virtio-9p configurations for fuzzing
In reply to Paolo BonziniFrom: Alexander Bulekov <[email protected]>
virtio-9p devices are often used to expose a virtual-filesystem to the guest. There have been some bugs reported in this device, such as CVE-2018-19364, and CVE-2021-20181. We should fuzz this device
This patch adds two virtio-9p configurations:
* One with the widely used -fsdev local driver. This driver leaks some state in the form of files/directories created in the shared dir.
* One with the synth driver. While it is not used in the real world, this driver won't leak leak state between fuzz inputs.
Message-Id: <[email protected]>
--- tests/qtest/fuzz/generic_fuzz_configs.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/qtest/fuzz/generic_fuzz_configs.h +20 -0
@@ -19,6 +19,16 @@ typedef struct generic_fuzz_config { gchar* (*argfunc)(void);/* Result must be freeable by g_free() */ } generic_fuzz_config; +static inline gchar *generic_fuzzer_virtio_9p_args (void ){ +char tmpdir[] ="/tmp/qemu-fuzz.XXXXXX" ; +g_assert_nonnull (mkdtemp (tmpdir)); + +return g_strdup_printf ("-machine q35 -nodefaults " +"-device virtio-9p,fsdev=hshare,mount_tag=hshare " +"-fsdev local,id=hshare,path=%s,security_model=mapped-xattr," +"writeout=immediate,fmode=0600,dmode=0700" , tmpdir); +} +const generic_fuzz_config predefined_configs[] = { { .name ="virtio-net-pci-slirp" ,
@@ -60,6 +70,16 @@ const generic_fuzz_config predefined_configs[] = { .name = "virtio-mouse", .args = "-machine q35 -nodefaults -device virtio-mouse", .objects = "virtio*", + },{ + .name = "virtio-9p", + .argfunc = generic_fuzzer_virtio_9p_args, + .objects = "virtio*", + },{ + .name = "virtio-9p-synth", + .args = "-machine q35 -nodefaults " + "-device virtio-9p,fsdev=hshare,mount_tag=hshare " + "-fsdev synth,id=hshare", + .objects = "virtio*", },{ .name = "e1000", .args = "-M q35 -nodefaults "
Signature · 1 line
2.29.2
[PULL 15/36] virtio-scsi: don't uninitialize queues that we didn't initialize
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Count number of queues that we initialized and only deinitialize these that we initialized successfully.
Message-Id: <[email protected]>
--- hw/scsi/virtio-scsi-dataplane.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/scsi/virtio-scsi-dataplane.c +7 -1
@@ -126,6 +126,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) {int i;int rc; +int vq_init_count =0 ;BusState *qbus =qdev_get_parent_bus (DEVICE (vdev));VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus);VirtIOSCSICommon *vs =VIRTIO_SCSI_COMMON (vdev);
@@ -153,17 +154,22 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)if (rc) { goto fail_vrings; } + + vq_init_count++; rc =virtio_scsi_vring_init (s, vs->event_vq,1 , virtio_scsi_data_plane_handle_event);if (rc) { goto fail_vrings; } + + vq_init_count++;for (i =0 ; i < vs->conf.num_queues; i++) { rc =virtio_scsi_vring_init (s, vs->cmd_vqs[i], i +2 , virtio_scsi_data_plane_handle_cmd);if (rc) { goto fail_vrings; } + vq_init_count++; } s->dataplane_starting = false;
@@ -174,7 +180,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) fail_vrings:aio_wait_bh_oneshot (s->ctx, virtio_scsi_dataplane_stop_bh, s);aio_context_release (s->ctx); -for (i =0 ; i < vs->conf.num_queues +2 ; i++) { +for (i =0 ; i < vq_init_count; i++) {virtio_bus_set_host_notifier (VIRTIO_BUS (qbus), i, false);virtio_bus_cleanup_host_notifier (VIRTIO_BUS (qbus), i); }
Signature · 1 line
2.29.2
[PULL 08/36] target/i386: do not set LM for 32-bit emulation "-cpu host/max"
In reply to Paolo Bonzini32-bit targets by definition do not support long mode; therefore, the bit must be masked in the features supported by the accelerator.
As a side effect, this avoids setting up the 0x80000008 CPUID leaf for
qemu-system-i386 -cpu host
which since commit 5a140b255d ("x86/cpu: Use max host physical address if -cpu max option is applied") would have printed this error:
qemu-system-i386: phys-bits should be between 32 and 36 (but is 48)
--- target/i386/cpu.c | 5 +++++ 1 file changed, 5 insertions(+)
target/i386/cpu.c +5 -0
@@ -5081,6 +5081,11 @@ static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, }else {return ~0 ; } +#ifndef TARGET_X86_64 +if (w ==FEAT_8000_0001_EDX ) { + r &= ~CPUID_EXT2_LM ; + } +#endif if (migratable_only) { r &=x86_cpu_get_migratable_flags (w); }
Signature · 1 line
2.29.2
[PULL 16/36] event_notifier: handle initialization failure better
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Add 'initialized' field and use it to avoid touching event notifiers which are either not initialized or if their initialization failed.
This is somewhat a hack, but it seems the less intrusive way to make virtio code deal with event notifiers that failed initialization.
Message-Id: <[email protected]>
--- include/qemu/event_notifier.h | 1 + util/event_notifier-posix.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
include/qemu/event_notifier.h +1 -0
@@ -24,6 +24,7 @@ struct EventNotifier {#else int rfd;int wfd; +bool initialized;#endif };
util/event_notifier-posix.c +16 -0
@@ -29,6 +29,7 @@ void event_notifier_init_fd(EventNotifier *e, int fd) { e->rfd = fd; e->wfd = fd; + e->initialized = true; }#endif
@@ -68,6 +69,7 @@ int event_notifier_init(EventNotifier *e, int active)if (active) {event_notifier_set (e); } + e->initialized = true;return 0 ; fail:
@@ -78,12 +80,18 @@ fail:void event_notifier_cleanup (EventNotifier *e) { +if (!e->initialized) { +return ; + } +if (e->rfd != e->wfd) {close (e->rfd); } + e->rfd =-1 ;close (e->wfd); e->wfd =-1 ; + e->initialized = false; }int event_notifier_get_fd (const EventNotifier *e)
@@ -96,6 +104,10 @@ int event_notifier_set(EventNotifier *e)static const uint64_t value =1 ;ssize_t ret; +if (!e->initialized) { +return -1 ; + } +do { ret =write (e->wfd, &value,sizeof (value)); }while (ret <0 && errno ==EINTR );
@@ -113,6 +125,10 @@ int event_notifier_test_and_clear(EventNotifier *e)ssize_t len;char buffer[512 ]; +if (!e->initialized) { +return 0 ; + } +/* Drain the notify pipe. For eventfd, only 8 bytes will be read. */ value =0 ; do {
Signature · 1 line
2.29.2
[PULL 11/36] meson: honor --enable-rbd if cc.links test fails
In reply to Paolo BonziniIf the link test failed, compilation proceeded with RBD disabled, even if --enable-rbd was used on the configure command line. Fix that.
--- meson.build | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
meson.build +15 -9
@@ -690,15 +690,21 @@ if not get_option('rbd').auto() or have_block librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'], required: get_option('rbd'), kwargs: static_kwargs) - if librados.found() and librbd.found() and cc.links(''' - #include <stdio.h> - #include <rbd/librbd.h> - int main(void) { - rados_t cluster; - rados_create(&cluster, NULL); - return 0; - }''', dependencies: [librbd, librados]) - rbd = declare_dependency(dependencies: [librbd, librados]) + if librados.found() and librbd.found() + if cc.links(''' + #include <stdio.h> + #include <rbd/librbd.h> + int main(void) { + rados_t cluster; + rados_create(&cluster, NULL); + return 0; + }''', dependencies: [librbd, librados]) + rbd = declare_dependency(dependencies: [librbd, librados]) + elif get_option('rbd').enabled() + error('could not link librados') + else + warning('could not link librados, disabling') + endif endif endif
Signature · 1 line
2.29.2
[PULL 18/36] target/i86: implement PKS
In reply to Paolo BonziniProtection Keys for Supervisor-mode pages is a simple extension of the PKU feature that QEMU already implements. For supervisor-mode pages, protection key restrictions come from a new MSR. The MSR has no XSAVE state associated to it.
PKS is only respected in long mode. However, in principle it is possible to set the MSR even outside long mode, and in fact even the XSAVE state for PKRU could be set outside long mode using XRSTOR. So do not limit the migration subsections for PKRU and PKRS to long mode.
--- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 5 +++++ target/i386/helper.c | 3 +++ target/i386/machine.c | 24 ++++++++++++++++++++---- target/i386/tcg/excp_helper.c | 32 ++++++++++++++++++++------------ target/i386/tcg/misc_helper.c | 14 ++++++++++++++ 6 files changed, 64 insertions(+), 18 deletions(-)
target/i386/cpu.c +2 -2
@@ -667,7 +667,7 @@ static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,CPUID_7_0_EBX_RDSEED */ #define TCG_7_0_ECX_FEATURES (CPUID_7_0_ECX_PKU | \ /* CPUID_7_0_ECX_OSPKE is dynamic */ \ -CPUID_7_0_ECX_LA57 ) +CPUID_7_0_ECX_LA57 | CPUID_7_0_ECX_PKS)#define TCG_7_0_EDX_FEATURES 0#define TCG_7_1_EAX_FEATURES 0#define TCG_APM_FEATURES 0
@@ -964,7 +964,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {"la57" ,NULL ,NULL ,NULL ,NULL ,NULL ,"rdpid" ,NULL ,NULL ,"cldemote" ,NULL ,"movdiri" , - "movdir64b", NULL, NULL, NULL, + "movdir64b", NULL, NULL, "pks", }, .cpuid = { .eax = 7,
target/i386/cpu.h +5 -0
@@ -247,6 +247,7 @@ typedef enum X86Seg {#define CR4_SMEP_MASK (1U << 20)#define CR4_SMAP_MASK (1U << 21)#define CR4_PKE_MASK (1U << 22) +#define CR4_PKS_MASK (1U << 24)#define DR6_BD (1 << 13)#define DR6_BS (1 << 14)
@@ -357,6 +358,7 @@ typedef enum X86Seg {#define MSR_IA32_TSX_CTRL 0x122#define MSR_IA32_TSCDEADLINE 0x6e0 +#define MSR_IA32_PKRS 0x6e1#define FEATURE_CONTROL_LOCKED (1<<0)#define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1<<2)
@@ -772,6 +774,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_ECX_MOVDIRI (1U << 27)/* Move 64 Bytes as Direct Store Instruction */ #define CPUID_7_0_ECX_MOVDIR64B (1U << 28) +/* Protection Keys for Supervisor-mode Pages */ +#define CPUID_7_0_ECX_PKS (1U << 31)/* AVX512 Neural Network Instructions */ #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2)
@@ -1487,6 +1491,7 @@ typedef struct CPUX86State {uint64_t msr_smi_count;uint32_t pkru; +uint32_t pkrs;uint32_t tsx_ctrl;uint64_t spec_ctrl;
target/i386/helper.c +3 -0
@@ -194,6 +194,9 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)if (!(env->features[FEAT_7_0_ECX ] &CPUID_7_0_ECX_PKU )) { new_cr4 &= ~CR4_PKE_MASK ; } +if (!(env->features[FEAT_7_0_ECX ] &CPUID_7_0_ECX_PKS )) { + new_cr4 &= ~CR4_PKS_MASK ; + } env->cr[4 ] = new_cr4; env->hflags = hflags;
target/i386/machine.c +20 -4
@@ -980,7 +980,6 @@ static const VMStateDescription vmstate_umwait = { } }; -#ifdef TARGET_X86_64 static bool pkru_needed (void *opaque) {X86CPU *cpu = opaque;
@@ -999,7 +998,25 @@ static const VMStateDescription vmstate_pkru = { VMSTATE_END_OF_LIST() } }; -#endif + +static bool pkrs_needed (void *opaque) +{ +X86CPU *cpu = opaque; +CPUX86State *env = &cpu->env; + +return env->pkrs !=0 ; +} + +static const VMStateDescription vmstate_pkrs = { + .name ="cpu/pkrs" , + .version_id =1 , + .minimum_version_id =1 , + .needed = pkrs_needed, + .fields = (VMStateField []){ +VMSTATE_UINT32 (env.pkrs,X86CPU ), +VMSTATE_END_OF_LIST () + } +};static bool tsc_khz_needed (void *opaque) {
@@ -1480,9 +1497,8 @@ VMStateDescription vmstate_x86_cpu = { &vmstate_umwait, &vmstate_tsc_khz, &vmstate_msr_smi_count, -#ifdef TARGET_X86_64 &vmstate_pkru, -#endif + &vmstate_pkrs, &vmstate_spec_ctrl, &vmstate_mcg_ext_ctl, &vmstate_msr_intel_pt,
target/i386/tcg/excp_helper.c +20 -12
@@ -361,6 +361,7 @@ static int handle_mmu_fault(CPUState *cs, vaddr addr, int size,uint64_t rsvd_mask =PG_HI_RSVD_MASK ;uint32_t page_offset;target_ulong vaddr; +uint32_t pkr; is_user = mmu_idx ==MMU_USER_IDX ;#if defined(DEBUG_MMU )
@@ -588,21 +589,28 @@ do_check_protect_pse36: !((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)))) { prot |=PAGE_EXEC ; } -if ((env->cr[4 ] &CR4_PKE_MASK ) && (env->hflags &HF_LMA_MASK ) && - (ptep &PG_USER_MASK ) && env->pkru) { + +if (!(env->hflags &HF_LMA_MASK )) { + pkr =0 ; + }else if (ptep &PG_USER_MASK ) { + pkr = env->cr[4 ] &CR4_PKE_MASK ? env->pkru :0 ; + }else { + pkr = env->cr[4 ] &CR4_PKS_MASK ? env->pkrs :0 ; + } +if (pkr) {uint32_t pk = (pte &PG_PKRU_MASK ) >>PG_PKRU_BIT ; -uint32_t pkru_ad = (env->pkru >> pk *2 ) &1 ; -uint32_t pkru_wd = (env->pkru >> pk *2 ) &2 ; -uint32_t pkru_prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; - -if (pkru_ad) { - pkru_prot &= ~(PAGE_READ |PAGE_WRITE ); - }else if (pkru_wd && (is_user || env->cr[0 ] &CR0_WP_MASK )) { - pkru_prot &= ~PAGE_WRITE ; +uint32_t pkr_ad = (pkr >> pk *2 ) &1 ; +uint32_t pkr_wd = (pkr >> pk *2 ) &2 ; +uint32_t pkr_prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; + +if (pkr_ad) { + pkr_prot &= ~(PAGE_READ |PAGE_WRITE ); + }else if (pkr_wd && (is_user || env->cr[0 ] &CR0_WP_MASK )) { + pkr_prot &= ~PAGE_WRITE ; } - prot &= pkru_prot; -if ((pkru_prot & (1 << is_write1)) ==0 ) { + prot &= pkr_prot; +if ((pkr_prot & (1 << is_write1)) ==0 ) {assert (is_write1 !=2 ); error_code |=PG_ERROR_PK_MASK ; goto do_fault_protect;
target/i386/tcg/misc_helper.c +14 -0
@@ -244,6 +244,7 @@ void helper_rdmsr(CPUX86State *env)void helper_wrmsr (CPUX86State *env) {uint64_t val; +CPUState *cs =env_cpu (env);cpu_svm_check_intercept_param (env,SVM_EXIT_MSR ,1 ,GETPC ());
@@ -296,6 +297,13 @@ void helper_wrmsr(CPUX86State *env)case MSR_PAT : env->pat = val;break ; +case MSR_IA32_PKRS : +if (val &0xFFFFFFFF00000000ull ) { + goto error; + } + env->pkrs = val; +tlb_flush (cs); +break ;case MSR_VM_HSAVE_PA : env->vm_hsave = val;break ;
@@ -399,6 +407,9 @@ void helper_wrmsr(CPUX86State *env)/* XXX: exception? */ break ; } +return ; +error: +raise_exception_err_ra (env,EXCP0D_GPF ,0 ,GETPC ()); }void helper_rdmsr (CPUX86State *env)
@@ -430,6 +441,9 @@ void helper_rdmsr(CPUX86State *env)case MSR_PAT : val = env->pat;break ; +case MSR_IA32_PKRS : + val = env->pkrs; +break ;case MSR_VM_HSAVE_PA : val = env->vm_hsave;break ;
Signature · 1 line
2.29.2
[PULL 13/36] fuzz: fix wrong index in clear_bits
In reply to Paolo BonziniFrom: Qiuhao Li <[email protected]>
Message-Id: <SYCPR01MB3502E9F6EB06DEDCD484F738FCBA9@SYCPR01MB3502.ausprd01.prod.outlook.com>
--- scripts/oss-fuzz/minimize_qtest_trace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/oss-fuzz/minimize_qtest_trace.py +1 -1
@@ -261,7 +261,7 @@ def clear_bits(newtrace, outpath): data_try = hex(int("".join(data_bin_list), 2)) # It seems qtest only accepts padded hex-values. if len(data_try) % 2 == 1: - data_try = data_try[:2] + "0" + data_try[2:-1] + data_try = data_try[:2] + "0" + data_try[2:] newtrace[i] = "{prefix} {data_try}\n".format( prefix=prefix,
Signature · 1 line
2.29.2
[PULL 20/36] configure: Improve TCI feature description
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Users might want to enable all features, without realizing some features have negative effect. Mention the TCI feature is slow and experimental, hoping it will be selected knowingly.
Message-Id: <[email protected]>
--- configure | 2 +- meson_options.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
configure +1 -1
@@ -1748,7 +1748,7 @@ Advanced options (experts only): --with-trace-file=NAME Full PATH,NAME of file to store traces Default:trace-<pid> --disable-slirp disable SLIRP userspace network connectivity - --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI) + --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow) --enable-malloc-trim enable libc malloc_trim() for memory optimization --oss-lib path to OSS library --cpu=CPU Build for host CPU [$cpu]
meson_options.txt +1 -1
@@ -40,7 +40,7 @@ option('xen_pci_passthrough', type: 'feature', value: 'auto', option('tcg', type: 'feature', value: 'auto', description: 'TCG support') option('tcg_interpreter', type: 'boolean', value: false, - description: 'TCG bytecode interpreter (TCI)') + description: 'TCG with bytecode interpreter (experimental and slow)') option('cfi', type: 'boolean', value: 'false', description: 'Control-Flow Integrity (CFI)') option('cfi_debug', type: 'boolean', value: 'false',
Signature · 1 line
2.29.2
[PULL 17/36] target/i386: Fix decoding of certain BMI instructions
In reply to Paolo BonziniFrom: David Greenaway <[email protected]>
This patch fixes a translation bug for a subset of x86 BMI instructions such as the following:
c4 e2 f9 f7 c0 shlxq %rax, %rax, %rax
Currently, these incorrectly generate an undefined instruction exception when SSE is disabled via CR4, while instructions like "shrxq" work fine.
The problem appears to be related to BMI instructions encoded using VEX and with a mandatory prefix of "0x66" (data). Instructions with this data prefix (such as shlxq) are currently rejected. Instructions with other mandatory prefixes (such as shrxq) translate as expected.
This patch removes the incorrect check in "gen_sse" that causes the exception to be generated. For the non-BMI cases, the check is
redundant: prefixes are already checked at line 3696.
Message-Id: <[email protected]>
--- target/i386/tcg/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/tcg/translate.c +1 -1
@@ -3075,7 +3075,7 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, }if (is_xmm && !(s->flags &HF_OSFXSR_MASK ) - && ((b !=0x38 && b !=0x3a ) || (s->prefix &PREFIX_DATA ))) { + && (b !=0x38 && b !=0x3a )) { goto unknown_op; }if (b ==0x0e ) {
Signature · 1 line
2.29.2
[PULL 21/36] meson: Explicit TCG backend used
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- meson.build | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
meson.build +6 -2
@@ -227,7 +227,7 @@ tcg_arch = config_host['ARCH'] if not get_option('tcg').disabled() if cpu not in supported_cpus if get_option('tcg_interpreter') - warning('Unsupported CPU @0@, will use TCG with TCI (experimental)'.format(cpu)) + warning('Unsupported CPU @0@, will use TCG with TCI (experimental and slow)'.format(cpu)) else error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu)) endif
@@ -2459,8 +2459,12 @@ if have_system endif summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')} if config_all.has_key('CONFIG_TCG') + if get_option('tcg_interpreter') + summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, experimental and slow)'} + else + summary_info += {'TCG backend': 'native (@0@)'.format(cpu)} + endif summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')} - summary_info += {'TCG interpreter': tcg_arch == 'tci'} endif summary_info += {'target list': ' '.join(target_dirs)} if have_system
Signature · 1 line
2.29.2
[PULL 19/36] configure: Fix --enable-tcg-interpreter
In reply to Paolo BonziniFrom: Richard Henderson <[email protected]>
The configure option was backward, and we failed to pass the value on to meson.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- configure | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
configure +3 -2
@@ -1119,9 +1119,9 @@ for opt do ;; --enable-whpx) whpx="enabled" ;; - --disable-tcg-interpreter) tcg_interpreter="true" + --disable-tcg-interpreter) tcg_interpreter="false" ;; - --enable-tcg-interpreter) tcg_interpreter="false" + --enable-tcg-interpreter) tcg_interpreter="true" ;; --disable-cap-ng) cap_ng="disabled" ;;
@@ -6367,6 +6367,7 @@ NINJA=$ninja $meson setup \ -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \ -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \ -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \ + -Dtcg_interpreter=$tcg_interpreter \ -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \ -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \ -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
Signature · 1 line
2.29.2
[PULL 22/36] meson: Warn when TCI is selected but TCG backend is available
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Some new users get confused with 'TCG' and 'TCI', and enable TCI support expecting to enable TCG.
Emit a warning when native TCG backend is available on the host architecture, mentioning this is a suboptimal configuration.
Message-Id: <[email protected]>
--- meson.build | 7 +++++++ 1 file changed, 7 insertions(+)
meson.build +7 -0
@@ -231,6 +231,13 @@ if not get_option('tcg').disabled() else error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu)) endif + elif get_option('tcg_interpreter') + warning('Use of the TCG interpretor is not recommended on this host') + warning('architecture. There is a native TCG execution backend available') + warning('which provides substantially better performance and reliability.') + warning('It is strongly recommended to remove the --enable-tcg-interpreter') + warning('configuration option on this architecture to use the native') + warning('backend.') endif if get_option('tcg_interpreter') tcg_arch = 'tci'
Signature · 1 line
2.29.2
[PULL 32/36] qapi/meson: Remove QMP from user-mode emulation
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- qapi/meson.build | 10 +++++++--- tests/meson.build | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-)
qapi/meson.build +7 -3
@@ -4,14 +4,18 @@ util_ss.add(files( 'qapi-dealloc-visitor.c', 'qapi-util.c', 'qapi-visit-core.c', - 'qmp-dispatch.c', - 'qmp-event.c', - 'qmp-registry.c', 'qobject-input-visitor.c', 'qobject-output-visitor.c', 'string-input-visitor.c', 'string-output-visitor.c', )) +if have_system or have_tools + util_ss.add(files( + 'qmp-dispatch.c', + 'qmp-event.c', + 'qmp-registry.c', + )) +endif qapi_all_modules = [ 'acpi',
tests/meson.build +6 -1
@@ -86,7 +86,6 @@ tests = { 'test-qobject-input-visitor': [testqapi], 'test-string-input-visitor': [testqapi], 'test-string-output-visitor': [testqapi], - 'test-qmp-event': [testqapi], 'test-opts-visitor': [testqapi], 'test-visitor-serialization': [testqapi], 'test-bitmap': [],
@@ -117,6 +116,12 @@ tests = { 'test-qapi-util': [], } +if have_system or have_tools + tests += { + 'test-qmp-event': [testqapi], + } +endif + test_deps = { 'test-qht-par': qht_bench, }
Signature · 1 line
2.29.2
[PULL 24/36] build-sys: make libslirp a meson subproject
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Remove the manual build.
Message-Id: <[email protected]>
--- .gitmodules | 4 ++-- configure | 2 +- meson.build | 63 ++++------------------------------------------------- 3 files changed, 7 insertions(+), 62 deletions(-)
.gitmodules +2 -2
@@ -49,8 +49,8 @@ [submodule "roms/edk2"] path = roms/edk2 url = https://git.qemu.org/git/edk2.git -[submodule "slirp"] - path = slirp +[submodule "subprojects/libslirp"] + path = subprojects/libslirp url = https://git.qemu.org/git/libslirp.git [submodule "roms/opensbi"] path = roms/opensbi
configure +1 -1
@@ -5212,7 +5212,7 @@ case "$slirp" in auto | enabled | internal) # Simpler to always update submodule, even if not needed. if test -e "${source_path}/.git" && test $git_update = 'yes' ; then - git_submodules="${git_submodules} slirp" + git_submodules="${git_submodules} subprojects/libslirp" fi ;; esac
meson.build +4 -59
75 lines not on this page · raw message
Signature · 1 line
2.29.2
[PULL 36/36] accel/kvm/kvm-all: Fix wrong return code handling in dirty log code
In reply to Paolo BonziniFrom: Thomas Huth <[email protected]>
The kvm_vm_ioctl() wrapper already returns -errno if the ioctl itself returned -1, so the callers of kvm_vm_ioctl() should not check for -1 but for a value < 0 instead.
This problem has been fixed once already in commit b533f658a98325d0e4 but that commit missed that the ENOENT error code is not fatal for this ioctl, so the commit has been reverted in commit 50212d6346f33d6e since the problem occurred close to a pending release at that point in time. The plan was to fix it properly after the release, but it seems like this has been forgotten. So let's do it now finally instead.
Resolves: https://bugs.launchpad.net/qemu/+bug/1294227
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
accel/kvm/kvm-all.c +12 -9
@@ -668,16 +668,19 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml, d.dirty_bitmap = mem->dirty_bmap; d.slot = mem->slot | (kml->as_id <<16 ); -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { -DPRINTF ("ioctl failed %d\n" , errno); - ret =-1 ; + ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d); +if (ret == -ENOENT ) { +/* kernel does not have dirty bitmap in this slot */ + ret =0 ; + }else if (ret <0 ) { +error_report ("ioctl KVM_GET_DIRTY_LOG failed: %d" , errno); goto out; + }else { + subsection.offset_within_region += slot_offset; + subsection.size =int128_make64 (slot_size); +kvm_get_dirty_pages_log_range (&subsection, d.dirty_bitmap); } - subsection.offset_within_region += slot_offset; - subsection.size =int128_make64 (slot_size); -kvm_get_dirty_pages_log_range (&subsection, d.dirty_bitmap); - slot_offset += slot_size; start_addr += slot_size; size -= slot_size;
@@ -774,8 +777,8 @@ static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id, uint64_t start, d.num_pages = bmap_npages; d.slot = mem->slot | (as_id <<16 ); -if (kvm_vm_ioctl (s,KVM_CLEAR_DIRTY_LOG , &d) ==-1 ) { - ret = -errno; + ret =kvm_vm_ioctl (s,KVM_CLEAR_DIRTY_LOG , &d); +if (ret <0 && ret != -ENOENT ) { error_report("%s: KVM_CLEAR_DIRTY_LOG failed, slot=%d, " "start=0x%"PRIx64", size=0x%"PRIx32", errno=%d", __func__, d.slot, (uint64_t)d.first_page,
Signature · 1 line
2.29.2
[PULL 29/36] meson: Restrict some trace event directories to user/system emulation
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- meson.build | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
meson.build +16 -12
@@ -1658,22 +1658,10 @@ target_softmmu_arch = {} # TODO: add each directory to the subdirs from its own meson.build, once # we have those trace_events_subdirs = [ - 'accel/kvm', - 'accel/tcg', 'crypto', - 'hw/core', 'qapi', 'qom', 'monitor', - 'target/arm', - 'target/hppa', - 'target/i386', - 'target/i386/kvm', - 'target/mips', - 'target/ppc', - 'target/riscv', - 'target/s390x', - 'target/sparc', 'util', ] if have_user
@@ -1690,6 +1678,7 @@ if have_block endif if have_system trace_events_subdirs += [ + 'accel/kvm', 'audio', 'backends', 'backends/tpm',
@@ -1747,6 +1736,21 @@ if have_system 'ui', ] endif +if have_system or have_user + trace_events_subdirs += [ + 'accel/tcg', + 'hw/core', + 'target/arm', + 'target/hppa', + 'target/i386', + 'target/i386/kvm', + 'target/mips', + 'target/ppc', + 'target/riscv', + 'target/s390x', + 'target/sparc', + ] +endif vhost_user = not_found if 'CONFIG_VHOST_USER' in config_host
Signature · 1 line
2.29.2
[PULL 33/36] qapi/meson: Restrict system-mode specific modules
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- qapi/meson.build | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
qapi/meson.build +6 -6
@@ -18,8 +18,6 @@ if have_system or have_tools endif qapi_all_modules = [ - 'acpi', - 'audio', 'authz', 'block', 'block-core',
@@ -39,14 +37,10 @@ qapi_all_modules = [ 'misc-target', 'net', 'pragma', - 'pci', 'qom', - 'rdma', 'replay', - 'rocker', 'run-state', 'sockets', - 'tpm', 'trace', 'transaction', 'ui',
@@ -54,7 +48,13 @@ qapi_all_modules = [ ] if have_system qapi_all_modules += [ + 'acpi', + 'audio', 'qdev', + 'pci', + 'rdma', + 'rocker', + 'tpm', ] endif
Signature · 1 line
2.29.2
[PULL 34/36] qapi/meson: Restrict UI module to system emulation and tools
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- qapi/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qapi/meson.build +5 -1
@@ -43,7 +43,6 @@ qapi_all_modules = [ 'sockets', 'trace', 'transaction', - 'ui', 'yank', ] if have_system
@@ -57,6 +56,11 @@ if have_system 'tpm', ] endif +if have_system or have_tools + qapi_all_modules += [ + 'ui', + ] +endif qapi_storage_daemon_modules = [ 'block-core',
Signature · 1 line
2.29.2
[PULL 35/36] hvf: Fetch cr4 before evaluating CPUID(1)
In reply to Paolo BonziniFrom: Alexander Graf <[email protected]>
The CPUID function 1 has a bit called OSXSAVE which tells user space the status of the CR4.OSXSAVE bit. Our generic CPUID function injects that bit based on the status of CR4.
With Hypervisor.framework, we do not synchronize full CPU state often enough for this function to see the CR4 update before guest user space asks for it.
To be on the save side, let's just always synchronize it when we receive a CPUID(1) request. That way we can set the bit with real confidence.
Message-Id: <[email protected]>
--- target/i386/hvf/hvf.c | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/hvf/hvf.c +4 -0
@@ -734,6 +734,10 @@ int hvf_vcpu_exec(CPUState *cpu)uint32_t rcx = (uint32_t )rreg (cpu->hvf_fd,HV_X86_RCX );uint32_t rdx = (uint32_t )rreg (cpu->hvf_fd,HV_X86_RDX ); +if (rax ==1 ) { +/* CPUID1.ecx.OSXSAVE needs to know CR4 */ + env->cr[4 ] =rvmcs (cpu->hvf->fd,VMCS_GUEST_CR4 ); + }cpu_x86_cpuid (env, rax, rcx, &rax, &rbx, &rcx, &rdx);wreg (cpu->hvf_fd,HV_X86_RAX , rax);
Signature · 1 line
2.29.2
Quoted 7 lines · Paolo Bonzini
The following changes since commit
0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2021-01-28 12:30:30 +0000)
are available in the Git repository at:
Quoted 7 lines
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
6c52f4644c9c8a18b8495e169e539632a897f135:accel/kvm/kvm-all: Fix wrong return code handling in dirty log code (2021-01-29 10:38:38 +0100)
----------------------------------------------------------------
Fails to build, OSX:
../../subprojects/libslirp/src/slirp.c:131:17: error: unused variable 'old_stat' [-Werror,-Wunused-variable]
struct stat old_stat;
^
../../subprojects/libslirp/src/slirp.c:143:10: error: unused variable
'buff' [-Werror,-Wunused-variable]
char buff[512];
^thanks
-- PMM
Quoted 18 lines · Peter Maydell
Quoted 7 lines · Paolo Bonzini
The following changes since commit
0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2021-01-28 12:30:30 +0000)are available in the Git repository at:
Quoted 7 lines
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
6c52f4644c9c8a18b8495e169e539632a897f135:accel/kvm/kvm-all: Fix wrong return code handling in dirty log code (2021-01-29 10:38:38 +0100)
----------------------------------------------------------------
Fails to build, OSX:
Quoted 8 lines
../../subprojects/libslirp/src/slirp.c:131:17: error: unused variable 'old_stat' [-Werror,-Wunused-variable]struct stat old_stat; ^ ../../subprojects/libslirp/src/slirp.c:143:10: error: unused variable 'buff' [-Werror,-Wunused-variable] char buff[512]; ^
Hmm this is the same slirp failure that in theory should have been fixed by Marc-André. I'll check again on Monday.
Paolo
Hi
Quoted 29 lines · Paolo Bonzini
Quoted 18 lines · Peter Maydell
Quoted 7 lines · Paolo Bonzini
The following changes since commit
0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2021-01-28 12:30:30 +0000)are available in the Git repository at:
Quoted 7 lines
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
6c52f4644c9c8a18b8495e169e539632a897f135:accel/kvm/kvm-all: Fix wrong return code handling in dirty log code (2021-01-29 10:38:38 +0100)
----------------------------------------------------------------
Fails to build, OSX:
Quoted 8 lines
../../subprojects/libslirp/src/slirp.c:131:17: error: unused variable 'old_stat' [-Werror,-Wunused-variable]struct stat old_stat; ^ ../../subprojects/libslirp/src/slirp.c:143:10: error: unused variable 'buff' [-Werror,-Wunused-variable] char buff[512]; ^
Quoted 4 lines
Hmm this is the same slirp failure that in theory should have been fixed by Marc-André. I'll check again on Monday.
That's weird, https://patchew.org/QEMU/[email protected]/[email protected]/
-Subproject commit 8f43a99191afb47ca3f3c6972f6306209f367ece +Subproject commit 5dce846e3ee82d93462bc637bb0db2fd49f0fc5a
I can't really explain why the submodule wasn't updated to include the fix.
Peter, did this fail on various CI builds or during a manual build?
Signature · 1 line
Marc-André Lureau
Quoted 8 lines · Marc-André Lureau
That's weird, https://patchew.org/QEMU/[email protected]/[email protected]/
(quoted diff) +1
-1-Subproject commit 8f43a99191afb47ca3f3c6972f6306209f367ece +Subproject commit 5dce846e3ee82d93462bc637bb0db2fd49f0fc5aI can't really explain why the submodule wasn't updated to include the fix.
Peter, did this fail on various CI builds or during a manual build?
It failed on my usual pre-merge build (which is just make/make check).
thanks
-- PMM