qemu/softmmu
Paolo Bonzini 4bfb024bc7 memory: clamp cached translation in case it points to an MMIO region
In using the address_space_translate_internal API, address_space_cache_init
forgot one piece of advice that can be found in the code for
address_space_translate_internal:

    /* MMIO registers can be expected to perform full-width accesses based only
     * on their address, without considering adjacent registers that could
     * decode to completely different MemoryRegions.  When such registers
     * exist (e.g. I/O ports 0xcf8 and 0xcf9 on most PC chipsets), MMIO
     * regions overlap wildly.  For this reason we cannot clamp the accesses
     * here.
     *
     * If the length is small (as is the case for address_space_ldl/stl),
     * everything works fine.  If the incoming length is large, however,
     * the caller really has to do the clamping through memory_access_size.
     */

address_space_cache_init is exactly one such case where "the incoming length
is large", therefore we need to clamp the resulting length---not to
memory_access_size though, since we are not doing an access yet, but to
the size of the resulting section.  This ensures that subsequent accesses
to the cached MemoryRegionSection will be in range.

With this patch, the enclosed testcase notices that the used ring does
not fit into the MSI-X table and prints a "qemu-system-x86_64: Cannot map used"
error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-12-15 12:52:00 -05:00
..
arch_init.c 8bit AVR port from Michael Rolnik. 2020-07-11 19:27:59 +01:00
balloon.c qapi: Restrict balloon-related commands to machine code 2020-09-29 15:41:35 +02:00
bootdevice.c softmmu: move more files to softmmu/ 2020-10-12 11:50:21 -04:00
cpu-throttle.c qemu/atomic.h: rename atomic_ to qatomic_ 2020-09-23 16:07:44 +01:00
cpu-timers.c cpus: prepare new CpusAccel cpu accelerator interface 2020-10-05 16:41:22 +02:00
cpus.c WHPX: support for the kernel-irqchip on/off 2020-12-10 12:15:01 -05:00
datadir.c vl: extract softmmu/datadir.c 2020-12-10 12:15:18 -05:00
device_tree.c vl: make qemu_get_machine_opts static 2020-12-15 12:51:55 -05:00
dma-helpers.c dma: Let dma_memory_set() propagate MemTxResult 2020-12-10 12:15:01 -05:00
globals.c qmp: generalize watchdog-set-action to -no-reboot/-no-shutdown 2020-12-15 12:51:57 -05:00
icount.c accel/tcg: split CpusAccel into three TCG variants 2020-12-10 17:44:10 -06:00
ioport.c softmmu: Add missing trace-events file 2020-09-09 17:15:18 +01:00
main.c meson: move SDL and SDL-image detection to meson 2020-08-21 06:30:44 -04:00
memory.c memory: allow creating MemoryRegions before accelerators 2020-12-15 12:51:56 -05:00
memory_mapping.c softmmu: move softmmu only files from root 2020-07-10 18:02:24 -04:00
meson.build qmp: generalize watchdog-set-action to -no-reboot/-no-shutdown 2020-12-15 12:51:57 -05:00
physmem.c memory: clamp cached translation in case it points to an MMIO region 2020-12-15 12:52:00 -05:00
qdev-monitor.c machine: introduce MachineInitPhase 2020-12-15 12:51:52 -05:00
qemu-seccomp.c softmmu: move more files to softmmu/ 2020-10-12 11:50:21 -04:00
qtest.c module: silence errors for module_load_qom_all(). 2020-10-15 10:43:48 +02:00
rtc.c vl: extract softmmu/rtc.c 2020-12-10 12:15:18 -05:00
runstate-action.c vl: Add option to avoid stopping VM upon guest panic 2020-12-15 12:51:58 -05:00
runstate.c vl: Add option to avoid stopping VM upon guest panic 2020-12-15 12:51:58 -05:00
timers-state.h cpu-timers, icount: new modules 2020-10-05 16:41:22 +02:00
tpm.c softmmu: move more files to softmmu/ 2020-10-12 11:50:21 -04:00
trace-events softmmu: Add missing trace-events file 2020-09-09 17:15:18 +01:00
trace.h softmmu: Add missing trace-events file 2020-09-09 17:15:18 +01:00
vl.c vl: Add option to avoid stopping VM upon guest panic 2020-12-15 12:51:58 -05:00