aboutsummaryrefslogtreecommitdiffstats
path: root/exec.c
AgeCommit message (Collapse)AuthorFilesLines
2010-07-22Declare code_gen_ptr, code_gen_max_blocks 'static'Stefan Weil1-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>
2010-07-07Fix warning about uninitialized variableBlue Swirl1-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>
2010-07-06ramblocks: No more being lazy about duplicate namesAlex Williamson1-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>
2010-07-06qemu_ram_free: Implement itAlex Williamson1-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>
2010-07-06ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_pathAlex Williamson1-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>
2010-07-06qemu_ram_alloc: Add DeviceState and name parametersAlex Williamson1-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>
2010-07-06savevm: Add DeviceState paramAlex Williamson1-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>
2010-07-06Remove uses of ram.last_offset (aka last_ram_offset)Alex Williamson1-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>
2010-06-30A bit optimization for tlb_set_page()Jun Koi1-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>
2010-06-14ram_blocks: Convert to a QLISTAlex Williamson1-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>
2010-06-11tcg-s390: Allocate the code_gen_buffer near the main program.Richard Henderson1-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>
2010-06-09tcg: get rid of copy_size in TCGOpDefAurelien Jarno1-1/+1
copy_size is a left-over from the dyngen era, remove it. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21tcg: Initialize the prologue after GUEST_BASE is fixed.Richard Henderson1-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>
2010-05-11Fix -mem-path with hugetlbfsMarcelo Tosatti1-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>
2010-05-07Fill in unassigned mem read/write callbacks.Richard Henderson1-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>
2010-05-06qemu: address todo comment in exec.cMichael S. Tsirkin1-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>
2010-05-06Fix zero-length write(2).Richard Henderson1-0/+3
Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-05Remove PAGE_RESERVEDPaul Brook1-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>
2010-04-25Remove IO_MEM_SUBWIDTH.Richard Henderson1-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>
2010-04-11Cleanup dead codeJun Koi1-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>
2010-04-10Revert "Avoid page_set_flags() assert in qemu-user host page protection code"Aurelien Jarno1-7/+6
This reverts commit 01c0bef1625d8e5d6d5c6abaf413214d667615ad. (breaks build on 32-bit hosts)
2010-04-09Avoid page_set_flags() assert in qemu-user host page protection codeJuergen Lock1-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>
2010-04-08Replace direct phys_ram_dirty access with wrapper functions.Yoshiaki Tamura1-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>
2010-04-05Split TLB addend and target_phys_addr_tPaul Brook1-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>
2010-04-01tcg: align static_code_gen_buffer to CODE_GEN_ALIGNAurelien Jarno1-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>
2010-04-01linux-user: fix page_unprotect when host page size > target page sizeAurelien Jarno1-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>
2010-03-30Get bsd-user host page protection code working on FreeBSD hostsJuergen Lock1-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>
2010-03-29Compile qemu-timer only onceBlue Swirl1-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>
2010-03-28exec: remove dead codeAurelien Jarno1-1/+0
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-27be more specific in -mem-path error messagesMichael Tokarev1-2/+2
Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-17Large page TLB flushPaul Brook1-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>
2010-03-14Fix pagetable codePaul Brook1-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>
2010-03-13Fix more wrong usermode virtual address typesBlue Swirl1-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>
2010-03-12Fix usermode virtual address typePaul Brook1-10/+12
Usermode virtual addresses are abi_ulong, not target_ulong. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-03-12Disable phsyical memory handling in userspace emulation.Paul Brook1-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>
2010-03-12Add tb_page_addr_tPaul Brook1-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>
2010-03-12Fix last page errors in page_check_range and page_set_flags.Richard Henderson1-18/+36
The addr < end comparison prevents iterating over the last page in the guest address space; an iteration based on length avoids this problem. At the same time, assert that the given address is in the guest address space. Signed-off-by: Richard Henderson <rth@twiddle.net>
2010-03-12Implement multi-level page tables.Richard Henderson1-175/+270
Define L1_MAP_ADDR_SPACE_BITS to be either the virtual address size (in user mode) or physical address size (in system mode), and use that to size l1_map. This rewrites page_find_alloc, page_flush_tb, and walk_memory_regions. Use TARGET_PHYS_ADDR_SPACE_BITS for the physical memory map based off of l1_phys_map. This rewrites page_phys_find_alloc and phys_page_for_each. Signed-off-by: Richard Henderson <rth@twiddle.net>
2010-03-12Move TARGET_PHYS_ADDR_SPACE_BITS to target-*/cpu.h.Richard Henderson1-17/+0
Removes a set of ifdefs from exec.c. Introduce TARGET_VIRT_ADDR_SPACE_BITS for all targets other than Alpha. This will be used for page_find_alloc, which is supposed to be using virtual addresses in the first place. Signed-off-by: Richard Henderson <rth@twiddle.net>
2010-03-04KVM: Rework VCPU state writeback APIJan Kiszka1-17/+0
This grand cleanup drops all reset and vmsave/load related synchronization points in favor of four(!) generic hooks: - cpu_synchronize_all_states in qemu_savevm_state_complete (initial sync from kernel before vmsave) - cpu_synchronize_all_post_init in qemu_loadvm_state (writeback after vmload) - cpu_synchronize_all_post_init in main after machine init - cpu_synchronize_all_post_reset in qemu_system_reset (writeback after system reset) These writeback points + the existing one of VCPU exec after cpu_synchronize_state map on three levels of writeback: - KVM_PUT_RUNTIME_STATE (during runtime, other VCPUs continue to run) - KVM_PUT_RESET_STATE (on synchronous system reset, all VCPUs stopped) - KVM_PUT_FULL_STATE (on init or vmload, all VCPUs stopped as well) This level is passed to the arch-specific VCPU state writing function that will decide which concrete substates need to be written. That way, no writer of load, save or reset functions that interact with in-kernel KVM states will ever have to worry about synchronization again. That also means that a lot of reasons for races, segfaults and deadlocks are eliminated. cpu_synchronize_state remains untouched, just as Anthony suggested. We continue to need it before reading or writing of VCPU states that are also tracked by in-kernel KVM subsystems. Consequently, this patch removes many cpu_synchronize_state calls that are now redundant, just like remaining explicit register syncs. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-03-04Add option to use file backed guest memoryMarcelo Tosatti1-5/+110
Port qemu-kvm's -mem-path and -mem-prealloc options. These are useful for backing guest memory with huge pages via hugetlbfs. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> CC: john cooper <john.cooper@redhat.com>
2010-03-01Avoid tlb_set_page in userspace emulationPaul Brook1-7/+13
tlb_set_page isn't meaningful for userspace emulation, so remove it. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-03-01Move subpage definitionsPaul Brook1-9/+9
Move definitions for subpage handling into !CONFIG_USER_ONLY code. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-03-01Remove bogus cpu_physical_memory_rwPaul Brook1-13/+9
Userspace doesn't have physical memory, so cpu_physical_memory_rw makes no sense. This is only used to implement cpu_memory_rw_debug, so just implement that directly instead. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-02-28Remove l1_phys_map from userspace emulationPaul Brook1-2/+5
Userspace emulation doesn't have a physical address space, so l1_phys_map makes no sense. This code is never actually used, so don't try and build it. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-02-28Fix userspace breakpoint invalidationPaul Brook1-0/+7
Remove bogus virtual->physical address translation in breakpoint_invalidate for userspace emulation. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-02-09kvm: move kvm to use memory notifiersMichael S. Tsirkin1-16/+1
remove direct kvm calls from exec.c, make kvm use memory notifiers framework instead. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-09qemu: memory notifiersMichael S. Tsirkin1-3/+110
This adds notifiers for phys memory changes: a set of callbacks that vhost can register and update kernel accordingly. Down the road, kvm code can be switched to use these as well, instead of calling kvm code directly from exec.c as is done now. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-08Merge remote branch 'qemu-kvm/uq/master' into staging-tmpAnthony Liguori1-0/+6
2010-02-06linux-user: remove signal handler before calling abort()Riku Voipio1-0/+9
Qemu may hang in host_signal_handler after qemu has done a seppuku with cpu_abort(). But at this stage we are not really interested in target process coredump anymore, so unregister host_signal_handler to die grafefully. Signed-off-by: Riku Voipio <riku.voipio@nokia.com>