History | View | Annotate | Download (139.2 kB)
Fix unassigned memory access handling
cea5f9a28faa528b6b1b117c9ab2d8828f473fef exposed bugs in unassigned memoryaccess handling. Fix them by always passing CPUState to the handlers.
Reported-by: Hervé Poussineau <hpoussin@reactos.org>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
qemu_ram_ptr_length: take ram_addr_t as arguments
qemu_ram_ptr_length should take ram_addr_t as argument rather thantarget_phys_addr_t because is doing comparisons with RAMBlock addresses.
cpu_physical_memory_map should create a ram_addr_t address to pass to...
xen: Clean up map cache API naming
The map cache is a Xen thing, so its API should make this clear.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Alexander Graf <agraf@suse.de>
xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN
Xen won't be enabled if there is no backend support available for thehost. And that also means the map cache will work. So drop the separateconfig switch and move the required stubs over to xen-stub.c.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
exec.c: Fix calculation of code_gen_buffer_max_size
When calculating the point at which we should not try to put anotherTB into the code gen buffer, we have to allow not just for OPC_MAX_SIZEbut OPC_BUF_SIZE. This is because the target translate.c will only...
exec: add endian specific phys ld/st functions
Device code some times needs to access physical memory and does thatthrough the ld./st._phys functions. However, these are the exact samefunctions that the CPU uses to access memory, which means they willbe endianness swapped depending on the target CPU....
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
Remove exec-all.h include directives
Most exec-all.h include directives are now useless, remove them.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
exec: last_first_tb was only used in !ONLY_USER case
Once there, use a better variable name.
Signed-off-by: Juan Quintela <quintela@redhat.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Merge remote-tracking branch 'mst/for_anthony' into staging
Conflicts: hw/usb-uhci.c
xen: remove xen_map_block and xen_unmap_block
Replace xen_map_block with qemu_map_cache with the appropriate lockingand size parameters.Replace xen_unmap_block with qemu_invalidate_entry.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>...
exec.c: refactor cpu_physical_memory_map
Introduce qemu_ram_ptr_length that takes an address and a size asparameters rather than just an address.
Refactor cpu_physical_memory_map so that we call qemu_ram_ptr_length onlyonce rather than calling qemu_get_ram_ptr one time per page....
xen: mapcache performance improvements
Use qemu_invalidate_entry in cpu_physical_memory_unmap.
Do not lock mapcache entries in qemu_get_ram_ptr if the address falls inthe ramblock with offset == 0. We don't need to do that because thecallers of qemu_get_ram_ptr either try to map an entire block, other...
xen: remove qemu_map_cache_unlock
There is no need for qemu_map_cache_unlock, just useqemu_invalidate_entry instead.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>Signed-off-by: Alexander Graf <agraf@suse.de>
Merge remote-tracking branch 'origin/master' into pci
Conflicts: hw/virtio-pci.c
CPUPhysMemoryClient: batch addresses in catchup
When a phys memory client registers and we play catchup by walkingthe page tables, we can make a huge improvement in the number oftimes the set_memory callback is called by batching contiguouspages together. With a 4G guest, this reduces the number of callbacks...
Merge remote branch 'rth/axp-next' into alpha-merge
Fix compilation warning due to missing header for sigaction (followup)
This patch removes all references to signal.h when qemu-common.h is includedas they become redundant.
Signed-off-by: Alexandre Raymond <cerbere@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
exec: Implement qemu_ram_free_from_ptr()
Required for regions mapped via qemu_ram_alloc_from_ptr(). VFIOand ivshmem will make use of this to remove mappings when devicesare hot unplugged.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
target-alpha: Trap for unassigned and unaligned addresses.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Merge branch 'trivial-patches' of git://repo.or.cz/qemu/stefanha
Fix typos in comments (chek -> check)
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
s390x: change mapping base to allow guests > 2GB
the current s390x qemu memory layout is
0x1000000: guest start0x80000000: qemu binary
which limits the amount of available memory to <2GB.This patch moves the guest pages to 32GB to not collide with the binary...
s390x: complain when allocating ram fails
While trying out the > 64GB guest RAM patch, I hit some virtual addresslimitations of my host system, which resulted in mmap failing. Unfortunately,qemu didn't tell me about this failure, but just used the NULL pointer...
xen: Introduce the Xen mapcache
On IA32 host or IA32 PAE host, at present, generally, we can't createan HVM guest with more than 2G memory, because generally it's almostimpossible for Qemu to find a large enough and consecutive virtualaddress space to map an HVM guest's whole physical address space....
Introduce qemu_put_ram_ptr
This function allows to unlock a ram_ptr give by qemu_get_ram_ptr. Aftera call to qemu_put_ram_ptr, the pointer may be unmap from QEMU whenused with Xen.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>Acked-by: Alexander Graf <agraf@suse.de>...
Merge remote branch 'origin/master' into pci
Conflicts: exec.c
CPUPhysMemoryClient: Pass guest physical address not region offset
When we're trying to get a newly registered phys memory client updatedwith the current page mappings, we end up passing the region offset(a ram_addr_t) as the start address rather than the actual guest...
CPUPhysMemoryClient: Fix typo in phys memory client registration
When we register a physical memory client, we try to walk the pagetables, calling the set_memory hook for every entry. Effectivelyplaying catchup for the client for everything already registered....
Break up user and system cpu_interrupt implementations
Both have only two lines in common, and we will convert the systemservice into a callback which is of no use for user mode operation.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>CC: Riku Voipio <riku.voipio@iki.fi>...
Redirect cpu_interrupt to callback handler
This allows to override the interrupt handling of QEMU in system mode.KVM will make use of it to set a specialized handler.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Remove unused function parameter from cpu_restore_state
The previous patch removed the need for parameter puc.Is is now unused, so remove it.
Cc: Aurelien Jarno <aurelien@aurel32.net>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Stefan Weil <weil@mail.berlios.de>
exec: Remove a type cast which is no longer needed
All other type casts in calls of cpu_physical_memory_write areused by hardware emulations and will be fixed by separate patches.
Cc: Blue Swirl <blauwirbel@gmail.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
Replace cpu_physical_memory_rw were possible
Using cpu_physical_memory_read, cpu_physical_memory_write and ldub_physimproves readability and allows removing some type casts.
lduw_phys and ldl_phys were not used because both require alignedaddresses. Therefore it is not possible to simply replace existing...
exec: Handle registrations of the entire address space
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
cpu: add set_memory flag to request dirty logging
Pass the flag to all cpu notifiers, doingnothing at this point. Will be used byfollow-up patches.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Expose thread_id in info cpus
Based on patch by Glauber Costa:
To allow management applications like libvirt to apply CPU affinities tothe VCPU threads, expose their ID via info cpus. This patch provides thepre-existing and used interface from qemu-kvm....
s390: Detect invalid invocations of qemu_ram_free/remap
This both detects invalid invocations of qemu_ram_free andqemu_ram_remap when mem_path is non-NULL and fixes a build error ons390 ("'area' may be used uninitialized in this function").
Add qemu_ram_remap
qemu_ram_remap() unmaps the specified RAM pages, then re-maps thesepages again. This is used by KVM HWPoison support to clear HWPoisonedpage tables across guest rebooting, so that a new page may beallocated later to recover the memory error....
Refactor thread retrieval and check
We have qemu_cpu_self and qemu_thread_self. The latter is retrieving thecurrent thread, the former is checking for equality (using CPUState). Wealso have qemu_thread_equal which is only used like qemu_cpu_self.
This refactors the interfaces, creating qemu_cpu_is_self and...
Fix performance regression in qemu_get_ram_ptr
When the commit f471a17e9d869df3c6573f7ec02c4725676d6f3a converted theram_blocks structure to QLIST, it also removed the conditional check beforeswitching the current block at the beginning of the list.
In the common use case where ram_blocks has a few blocks with only one...
Introduce log_start/log_stop in CPUPhysMemoryClient
In order to use log_start/log_stop with Xen as well in the vga code,this two operations have been put in CPUPhysMemoryClient.
The two new functions cpu_physical_log_start,cpu_physical_log_stop areused in hw/vga.c and replace the kvm_log_start/stop. With this, vga does...
Make tb_alloc static
This function is only used within exec.c, so no need to make it public.
Signed-off-by: Tristan Gingold <gingold@adacore.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
tcg/sparc64: fix segfault
With current OpenBSD, code_gen_buffer was mapped 8GB away fromtext segment. Then any helpers were beyond the 2GB range of callinstruction genereated by TCG and so the calls would go nowhere,leading to a segfault.
Fix by specifying an address for the code_gen_buffer,...
Use mmap() within code_gen_alloc() for OpenBSD.
Signed-off-by: Brad Smith <brad@comstyle.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
exec: introduce endianness swapped mmio
The way we're currently modeling mmio is too simplified. We assume thatevery device has the same endianness as the target CPU. In reality,most devices are little endian (all PCI and ISA ones I'm aware of). Someare big endian (special system devices) and a very little fraction is...
Add endianness as io mem parameter
As stated before, devices can be little, big or native endian. Thetarget endianness is not of their concern, so we need to push thingsdown a level.
This patch adds a parameter to cpu_register_io_memory that allows adevice to choose its endianness. For now, all devices simply choose...
exec: Remove debugging fprintf() that slipped into qemu_ram_alloc_from_ptr()
Remove the debugging fprintf() slipped in via the following commit:
commit b2e0a138e77245290428a7d599a929e2e1bfe510 Author: Michael S. Tsirkin <mst@redhat.com> Date: Mon Nov 22 19:52:34 2010 +0200...
migration: stable ram block ordering
This makes ram block ordering under migration stable, ordered by offset.This is especially useful for migration to exec, for debugging.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Tested-by: Jason Wang <jasowang@redhat.com>
exec: Use fprintf_function for dump_exec_info (format checking)
fprintf_function uses format checking with GCC_FMT_ATTR.
It is declared in qemu-common.h and used in cpu-all.h(which is included from cpu.h), so qemu-common.h mustbe included earlier. Some redundant include statements...
Export qemu_ram_addr_from_host
To be used by next patches.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Avi Kivity <avi@redhat.com>
exec: Fix compilation error for debug code
is_softmmu was removed with commitd4c430a80f000d722bb70287af4d4c184a8d7006,so remove it now from debug code, too.
Fix also the format specifier for paddrin the same line of code.
Cc: Blue Swirl <blauwirbel@gmail.com>...
Introduce qemu_madvise()
vl.c has a Sun-specific hack to supply a prototype for madvise(),but the call site has apparently moved to arch_init.c.
Haiku doesn't implement madvise() in favor of posix_madvise().OpenBSD and Solaris 10 don't implement posix_madvise() but madvise()....
Fix segfault in mmio subpage handling code.
It is possible that subpage mmio is registered over existing memorypage. When this happens "memory" will have real memory address and notindex into io_mem array so next access to the page will generatesegfault. It is uncommon to have some part of a page to be accessed as...
exec: replace tabs by spaces.
Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
exec: remove code duplication in qemu_ram_alloc() and qemu_ram_alloc_from_ptr()
Since most of the code in qemu_ram_alloc() andqemu_ram_alloc_from_ptr() are duplicated, letqemu_ram_alloc_from_ptr() to switch by checking void *host, and changeqemu_ram_alloc() to a wrapper....
Add qemu_ram_alloc_from_ptr function
Provide a function to add an allocated region of memory to the qemu RAM.
This patch is copied from Marcelo's qemu_ram_map() in qemu-kvm and given theclearer name qemu_ram_alloc_from_ptr().
Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>...
Declare code_gen_ptr, code_gen_max_blocks 'static'
Both values are only used in exec.c, so there is no needto make them globally available.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Fix warning about uninitialized variable
With gcc 4.2.1-sjlj (mingw32-2) I get this warning:/src/qemu/exec.c: In function 'qemu_ram_alloc':/src/qemu/exec.c:2777: warning: 'offset' may be used uninitialized in this function
Fix by initializing the variable....
ramblocks: No more being lazy about duplicate names
Now that we have a working qemu_ram_free() and the primary runtimeuser of it has been updated, don't be lenient about duplicate id strings.We also shouldn't need to create them ondemand at the target....
savevm: Add DeviceState param
When available, we'd like to be able to access the DeviceStatewhen registering a savevm. For buses with a get_dev_path()function, this will allow us to create more unique savevmid strings.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
qemu_ram_alloc: Add DeviceState and name parameters
These will be used to generate unique id strings for ramblocks. The namefield is required, the device pointer is optional as most callers don'thave a device. When there's no device or the device isn't a child of...
ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
With these two pieces in place, we can start naming ramblocks. Whenthe device is present and it lives on a bus that provides a devicepath, we concatenate the path and the provided name. Otherwise we...
qemu_ram_free: Implement it
Now that we can support a ram_addr_t space with holes, we can implementqemu_ram_free().
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Remove uses of ram.last_offset (aka last_ram_offset)
We currently need this either to allocate the next ram_addr_t for anew block, or for total memory to be migrated. Both of which we cancalculate without need of this to keep us in a contiguous address space....
A bit optimization for tlb_set_page()
This patch avoids handling write watchpoints on read-only memory access.It also breaks the searching loop for watchpoint once the setup forhandling watchpoint later is done.
Signed-off-by: Jun Koi <junkoi2004@gmail.com>...
ram_blocks: Convert to a QLIST
This makes the RAM block list easier to manipulate. Also incorporaterelevant variables into the RAMList struct.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Acked-by: Chris Wright <chrisw@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tcg-s390: Allocate the code_gen_buffer near the main program.
This allows the use of direct calls to the helpers,and a direct branch back to the epilogue.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
tcg: get rid of copy_size in TCGOpDef
copy_size is a left-over from the dyngen era, remove it.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
tcg: Initialize the prologue after GUEST_BASE is fixed.
This will allow backends to make intelligent choices about howto implement GUEST_BASE.
Fix -mem-path with hugetlbfs
Fallback to qemu_vmalloc in case file_ram_alloc fails.
Fill in unassigned mem read/write callbacks.
Implement the "functions may be omitted with NULL pointer" interface mentioned in the function block comment by transformingNULL entries in the read/write arrays into calls to theunassigned_mem family of functions....
qemu: address todo comment in exec.c
exec.c has a comment 'XXX: optimize' for lduw_phys/stw_phys,so let's do it, along the lines of stl_phys.
The reason to address 16 bit accesses specifically is that virtio relieson these accesses to be done atomically, using memset as we do now...
Fix zero-length write(2).
Remove PAGE_RESERVED
The usermode PAGE_RESERVED code is not required by the current mmapimplementation, and is already broken when guest_base != 0.Unfortunately the bsd emulation still uses the old mmap implementation,so we can't rip it out altogether....
Remove IO_MEM_SUBWIDTH.
Greatly simplify the subpage implementation by not supportingmultiple devices at the same address at different widths. Wedon't need full copies of mem_read/mem_write/opaque for eachaddress, only a single index back into the main io_mem_* arrays....
Cleanup dead code
This patch removes some dead code in exec.c
Signed-off-by: Jun Koi <junkoi2004@gmail.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Revert "Avoid page_set_flags() assert in qemu-user host page protection code"
This reverts commit 01c0bef1625d8e5d6d5c6abaf413214d667615ad.
(breaks build on 32-bit hosts)
Avoid page_set_flags() assert in qemu-user host page protection code
V2 that uses endaddr = end-of-guest-address-space if !h2g_valid(endaddr)after I found out that indeed works; and also disables the FreeBSD 6.x/compat/linux/proc/self/maps fallback because it can return partial lines...
Replace direct phys_ram_dirty access with wrapper functions.
Replaces direct phys_ram_dirty access with wrapper functions to preventdirect access to the phys_ram_dirty bitmap.
Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>...
Split TLB addend and target_phys_addr_t
Historically the qemu tlb "addend" field was used for both RAM and IO accesses,so needed to be able to hold both host addresses (unsigned long) and guestphysical addresses (target_phys_addr_t). However since the introduction of...
linux-user: fix page_unprotect when host page size > target page size
When the host page size is bigger that the target one, unprotecting apage should:- mark all the target pages corresponding to the host page as writable- invalidate all tb corresponding to the host page (and not the target...
tcg: align static_code_gen_buffer to CODE_GEN_ALIGN
On ia64, the default memory alignement is not enough for a codealignement. To fix that, force static_code_gen_buffer alignmentto CODE_GEN_ALIGN.
Get bsd-user host page protection code working on FreeBSD hosts
Use kinfo_getvmmap(3) on FeeBSD >= 7.x and /compat/linux/proc on olderFreeBSD. (kinfo_getvmmap is preferred since /compat/linux/proc isusually only mounted on hosts also using the Linuxolator.)...
Compile qemu-timer only once
Arrange various declarations so that also non-CPU code can accessthem, adjust users.
Move CPU specific code to cpus.c.
exec: remove dead code
be more specific in -mem-path error messages
Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Large page TLB flush
QEMU uses a fixed page size for the CPU TLB. If the guest uses largepages then we effectively split these into multiple smaller pages, andpopulate the corresponding TLB entries on demand.
When the guest invalidates the TLB by virtual address we must invalidate...
Fix pagetable code
The multi-level pagetable code fails to iterate ove all entries becauseof the L2_BITS v.s. L2_SIZE thinko.
Signed-off-by: Paul Brook <paul@codesourcery.com>
Fix more wrong usermode virtual address types
Fixes warning: CC sparc-bsd-user/exec.o/src/qemu/exec.c: In function `page_check_range':/src/qemu/exec.c:2375: warning: comparison is always true due to limited range of data type
Fix usermode virtual address type
Usermode virtual addresses are abi_ulong, not target_ulong.
Disable phsyical memory handling in userspace emulation.
Code to handle physical memory access is not meaningful in usrmode emulation,so disable it.
Add tb_page_addr_t
The page tracking code in exec.c is used by both userspace and systememulation. Userspace emulation uses it to track virtual pages, andsystem emulation to track ram pages. Introduce a new type to hold thiskind of address.
Fix last page errors in page_check_range and page_set_flags.
The addr < end comparison prevents iterating over the lastpage in the guest address space; an iteration based onlength avoids this problem.
At the same time, assert that the given address is in the...
Implement multi-level page tables.
Define L1_MAP_ADDR_SPACE_BITS to be either the virtual address size(in user mode) or physical address size (in system mode), and usethat to size l1_map. This rewrites page_find_alloc, page_flush_tb,and walk_memory_regions....
Move TARGET_PHYS_ADDR_SPACE_BITS to target-*/cpu.h.
Removes a set of ifdefs from exec.c.
Introduce TARGET_VIRT_ADDR_SPACE_BITS for all targets otherthan Alpha. This will be used for page_find_alloc, which issupposed to be using virtual addresses in the first place....
KVM: Rework VCPU state writeback API
This grand cleanup drops all reset and vmsave/load relatedsynchronization points in favor of four(!) generic hooks:
- cpu_synchronize_all_states in qemu_savevm_state_complete (initial sync from kernel before vmsave)...
Add option to use file backed guest memory
Port qemu-kvm's -mem-path and -mem-prealloc options. These are usefulfor backing guest memory with huge pages via hugetlbfs.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>CC: john cooper <john.cooper@redhat.com>
Avoid tlb_set_page in userspace emulation
tlb_set_page isn't meaningful for userspace emulation, so remove it.
Move subpage definitions
Move definitions for subpage handling into !CONFIG_USER_ONLY code.