summaryrefslogtreecommitdiffstats
path: root/exec.c
Commit message (Collapse)AuthorAgeFilesLines
* tcg/sparc64: fix segfaultBlue Swirl2011-01-161-0/+7
| | | | | | | | | | | | With current OpenBSD, code_gen_buffer was mapped 8GB away from text segment. Then any helpers were beyond the 2GB range of call instruction genereated by TCG and so the calls would go nowhere, leading to a segfault. Fix by specifying an address for the code_gen_buffer, hopefully free and nearby the helpers. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Use mmap() within code_gen_alloc() for OpenBSD.Brad2010-12-211-1/+2
| | | | | Signed-off-by: Brad Smith <brad@comstyle.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Add endianness as io mem parameterAlexander Graf2010-12-111-7/+14
| | | | | | | | | | | | | As stated before, devices can be little, big or native endian. The target endianness is not of their concern, so we need to push things down a level. This patch adds a parameter to cpu_register_io_memory that allows a device to choose its endianness. For now, all devices simply choose native endian, because that's the same behavior as before. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* exec: introduce endianness swapped mmioAlexander Graf2010-12-111-2/+121
| | | | | | | | | | | | | | | | | | | | The way we're currently modeling mmio is too simplified. We assume that every 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). Some are big endian (special system devices) and a very little fraction is target native endian (fw_cfg). So instead of assuming every device to be native endianness, let's move to a model where the device tells us which endianness it's in. That way we can compile the devices only once and get rid of all the ugly swap will be done by the underlying layer. For the same of readability, this patch only introduces the helper framework but doesn't allow the registering code to set its endianness yet. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* exec: Remove debugging fprintf() that slipped into qemu_ram_alloc_from_ptr()Stefan Hajnoczi2010-12-031-1/+0
| | | | | | | | | | | | | 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 Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* migration: stable ram block orderingMichael S. Tsirkin2010-12-021-2/+22
| | | | | | | | 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)Stefan Weil2010-10-301-12/+4
| | | | | | | | | | | | | | | 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 must be included earlier. Some redundant include statements for standard include files were removed. Fix also two format errors (ptrdiff_t needs %td). Cc: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Export qemu_ram_addr_from_hostMarcelo Tosatti2010-10-201-9/+17
| | | | | | | 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 codeStefan Weil2010-10-031-2/+3
| | | | | | | | | | | | | is_softmmu was removed with commit d4c430a80f000d722bb70287af4d4c184a8d7006, so remove it now from debug code, too. Fix also the format specifier for paddr in the same line of code. Cc: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Introduce qemu_madvise()Andreas Färber2010-09-251-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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(). MinGW implements neither. Check for madvise() and posix_madvise() in configure and supply qemu_madvise() as wrapper. Prefer madvise() over posix_madvise() due to flag availability. Convert all callers to use qemu_madvise() and QEMU_MADV_*. Note that on Solaris the warning is fixed by moving the madvise() prototype, not by qemu_madvise() itself. It helps with porting though, and it simplifies most call sites. v7 -> v8: * Some versions of MinGW have no sys/mman.h header. Reported by Blue Swirl. v6 -> v7: * Adopt madvise() rather than posix_madvise() semantics for returning errors. * Use EINVAL in place of ENOTSUP. v5 -> v6: * Replace two leftover instances of POSIX_MADV_NORMAL with QEMU_MADV_INVALID. Spotted by Blue Swirl. v4 -> v5: * Introduce QEMU_MADV_INVALID, suggested by Alexander Graf. Note that this relies on -1 not being a valid advice value. v3 -> v4: * Eliminate #ifdefs at qemu_advise() call sites. Requested by Blue Swirl. This will currently break the check in kvm-all.c by calling madvise() with a supported flag, which will not fail. Ideas/patches welcome. v2 -> v3: * Reuse the *_MADV_* defines for QEMU_MADV_*. Suggested by Alexander Graf. * Add configure check for madvise(), too. Add defines to Makefile, not QEMU_CFLAGS. Convert all callers, untested. Suggested by Blue Swirl. * Keep Solaris' madvise() prototype around. Pointed out by Alexander Graf. * Display configure check results. v1 -> v2: * Don't rely on posix_madvise() availability, add qemu_madvise(). Suggested by Blue Swirl. Signed-off-by: Andreas Färber <afaerber@opensolaris.org> Cc: Blue Swirl <blauwirbel@gmail.com> Cc: Alexander Graf <agraf@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix segfault in mmio subpage handling code.Gleb Natapov2010-08-281-0/+2
| | | | | | | | | | | | | It is possible that subpage mmio is registered over existing memory page. When this happens "memory" will have real memory address and not index into io_mem array so next access to the page will generate segfault. It is uncommon to have some part of a page to be accessed as memory and some as mmio, but qemu shouldn't crash even when guest does stupid things. So lets just pretend that the rest of the page is unassigned if guest configure part of the memory page as mmio. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* exec: remove code duplication in qemu_ram_alloc() and qemu_ram_alloc_from_ptr()Yoshiaki Tamura2010-08-221-58/+26
| | | | | | | | | | Since most of the code in qemu_ram_alloc() and qemu_ram_alloc_from_ptr() are duplicated, let qemu_ram_alloc_from_ptr() to switch by checking void *host, and change qemu_ram_alloc() to a wrapper. Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* exec: replace tabs by spaces.Yoshiaki Tamura2010-08-221-28/+28
| | | | | Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add qemu_ram_alloc_from_ptr functionCam Macdonell2010-08-101-0/+43
| | | | | | | | | | 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 the clearer name qemu_ram_alloc_from_ptr(). Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Declare code_gen_ptr, code_gen_max_blocks 'static'Stefan Weil2010-07-221-2/+2
| | | | | | | | Both values are only used in exec.c, so there is no need to 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 variableBlue Swirl2010-07-071-1/+1
| | | | | | | | | | 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. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* ramblocks: No more being lazy about duplicate namesAlex Williamson2010-07-061-10/+3
| | | | | | | | | Now that we have a working qemu_ram_free() and the primary runtime user 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. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu_ram_free: Implement itAlex Williamson2010-07-061-4/+58
| | | | | | | | Now that we can support a ram_addr_t space with holes, we can implement qemu_ram_free(). Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_pathAlex Williamson2010-07-061-2/+27
| | | | | | | | | | | | | With these two pieces in place, we can start naming ramblocks. When the device is present and it lives on a bus that provides a device path, we concatenate the path and the provided name. Otherwise we just use name. The resulting id string must be unique. For now we assume an allocation for the same name and size is a device that has been removed and reinserted and return the same block. This will go away once qemu_ram_free() is implemented. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu_ram_alloc: Add DeviceState and name parametersAlex Williamson2010-07-061-1/+1
| | | | | | | | | | | These will be used to generate unique id strings for ramblocks. The name field is required, the device pointer is optional as most callers don't have a device. When there's no device or the device isn't a child of a bus implementing BusInfo.get_dev_path, the name should be unique for the platform. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* savevm: Add DeviceState paramAlex Williamson2010-07-061-2/+2
| | | | | | | | | | When available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings. 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)Alex Williamson2010-07-061-5/+14
| | | | | | | | | We currently need this either to allocate the next ram_addr_t for a new block, or for total memory to be migrated. Both of which we can calculate without need of this to keep us in a contiguous address space. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* A bit optimization for tlb_set_page()Jun Koi2010-06-301-4/+6
| | | | | | | | | This patch avoids handling write watchpoints on read-only memory access. It also breaks the searching loop for watchpoint once the setup for handling watchpoint later is done. Signed-off-by: Jun Koi <junkoi2004@gmail.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* ram_blocks: Convert to a QLISTAlex Williamson2010-06-141-51/+27
| | | | | | | | | This makes the RAM block list easier to manipulate. Also incorporate relevant 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.Richard Henderson2010-06-111-0/+7
| | | | | | | | 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 TCGOpDefAurelien Jarno2010-06-091-1/+1
| | | | | | 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.Richard Henderson2010-05-211-0/+5
| | | | | | | | This will allow backends to make intelligent choices about how to implement GUEST_BASE. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix -mem-path with hugetlbfsMarcelo Tosatti2010-05-111-2/+6
| | | | | | | Fallback to qemu_vmalloc in case file_ram_alloc fails. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* Fill in unassigned mem read/write callbacks.Richard Henderson2010-05-071-2/+10
| | | | | | | | | | Implement the "functions may be omitted with NULL pointer" interface mentioned in the function block comment by transforming NULL entries in the read/write arrays into calls to the unassigned_mem family of functions. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu: address todo comment in exec.cMichael S. Tsirkin2010-05-061-7/+60
| | | | | | | | | | | | | | | 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 relies on these accesses to be done atomically, using memset as we do now breaks this assumption, which is reported to cause qemu with kvm to read wrong index values under stress. https://bugzilla.redhat.com/show_bug.cgi?id=525323 Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix zero-length write(2).Richard Henderson2010-05-061-0/+3
| | | | | Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Remove PAGE_RESERVEDPaul Brook2010-05-051-29/+2
| | | | | | | | | The usermode PAGE_RESERVED code is not required by the current mmap implementation, 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. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Remove IO_MEM_SUBWIDTH.Richard Henderson2010-04-251-77/+36
| | | | | | | | | | Greatly simplify the subpage implementation by not supporting multiple devices at the same address at different widths. We don't need full copies of mem_read/mem_write/opaque for each address, only a single index back into the main io_mem_* arrays. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Cleanup dead codeJun Koi2010-04-111-3/+0
| | | | | | | 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"Aurelien Jarno2010-04-101-7/+6
| | | | | | This reverts commit 01c0bef1625d8e5d6d5c6abaf413214d667615ad. (breaks build on 32-bit hosts)
* Avoid page_set_flags() assert in qemu-user host page protection codeJuergen Lock2010-04-091-6/+7
| | | | | | | | | | | | 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 if (at least I think that's the reason) the mappings change between subsequent read() calls. Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> Acked-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Replace direct phys_ram_dirty access with wrapper functions.Yoshiaki Tamura2010-04-081-25/+20
| | | | | | | | | | Replaces direct phys_ram_dirty access with wrapper functions to prevent direct 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> Reviewed-by: Avi Kivity <avi@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Split TLB addend and target_phys_addr_tPaul Brook2010-04-051-1/+1
| | | | | | | | | | | | | | 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 guest physical addresses (target_phys_addr_t). However since the introduction of the iotlb field it has only been used for RAM accesses. This means we can change the type of addend to unsigned long, and remove associated hacks in the big-endian TCG backends. We can also remove the host dependence from target_phys_addr_t. Signed-off-by: Paul Brook <paul@codesourcery.com>
* tcg: align static_code_gen_buffer to CODE_GEN_ALIGNAurelien Jarno2010-04-011-1/+2
| | | | | | | | On ia64, the default memory alignement is not enough for a code alignement. To fix that, force static_code_gen_buffer alignment to CODE_GEN_ALIGN. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: fix page_unprotect when host page size > target page sizeAurelien Jarno2010-04-011-23/+22
| | | | | | | | | | When the host page size is bigger that the target one, unprotecting a page 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 page) Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Get bsd-user host page protection code working on FreeBSD hostsJuergen Lock2010-03-301-0/+50
| | | | | | | | | | | | | | | | | Use kinfo_getvmmap(3) on FeeBSD >= 7.x and /compat/linux/proc on older FreeBSD. (kinfo_getvmmap is preferred since /compat/linux/proc is usually only mounted on hosts also using the Linuxolator.) This patch is a bit hacky because the includes needed for kinfo_getvmmap conflict with other definitions in exec.c by default so I had to `trick around' a little, but I built the result in FreeBSD 6.4-stable and 7.2-stable tbs and on 8-stable on the host so the hacks at least should be stable. (If this is a problem maybe we could also move the kinfo_getvmmap invocations into a seperate source file but that would be more work...) Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Compile qemu-timer only onceBlue Swirl2010-03-291-0/+1
| | | | | | | | | Arrange various declarations so that also non-CPU code can access them, adjust users. Move CPU specific code to cpus.c. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* exec: remove dead codeAurelien Jarno2010-03-281-1/+0
| | | | Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* be more specific in -mem-path error messagesMichael Tokarev2010-03-271-2/+2
| | | | | Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Large page TLB flushPaul Brook2010-03-171-10/+45
| | | | | | | | | | | | | | | | | | QEMU uses a fixed page size for the CPU TLB. If the guest uses large pages then we effectively split these into multiple smaller pages, and populate the corresponding TLB entries on demand. When the guest invalidates the TLB by virtual address we must invalidate all entries covered by the large page. However the address used to invalidate the entry may not be present in the QEMU TLB, so we do not know which regions to clear. Implementing a full vaiable size TLB is hard and slow, so just keep a simple address/mask pair to record which addresses may have been mapped by large pages. If the guest invalidates this region then flush the whole TLB. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Fix pagetable codePaul Brook2010-03-141-6/+6
| | | | | | | The multi-level pagetable code fails to iterate ove all entries because of the L2_BITS v.s. L2_SIZE thinko. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Fix more wrong usermode virtual address typesBlue Swirl2010-03-131-2/+2
| | | | | | | | | 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 Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix usermode virtual address typePaul Brook2010-03-121-10/+12
| | | | | | Usermode virtual addresses are abi_ulong, not target_ulong. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Disable phsyical memory handling in userspace emulation.Paul Brook2010-03-121-2/+4
| | | | | | | Code to handle physical memory access is not meaningful in usrmode emulation, so disable it. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Add tb_page_addr_tPaul Brook2010-03-121-26/+31
| | | | | | | | | The page tracking code in exec.c is used by both userspace and system emulation. Userspace emulation uses it to track virtual pages, and system emulation to track ram pages. Introduce a new type to hold this kind of address. Signed-off-by: Paul Brook <paul@codesourcery.com>
OpenPOWER on IntegriCloud