summaryrefslogtreecommitdiffstats
path: root/exec.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Fix last page errors in page_check_range and page_set_flags.Richard Henderson2010-03-121-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>
* Implement multi-level page tables.Richard Henderson2010-03-121-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>
* Move TARGET_PHYS_ADDR_SPACE_BITS to target-*/cpu.h.Richard Henderson2010-03-121-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>
* KVM: Rework VCPU state writeback APIJan Kiszka2010-03-041-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>
* Add option to use file backed guest memoryMarcelo Tosatti2010-03-041-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>
* Avoid tlb_set_page in userspace emulationPaul Brook2010-03-011-7/+13
| | | | | | tlb_set_page isn't meaningful for userspace emulation, so remove it. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Move subpage definitionsPaul Brook2010-03-011-9/+9
| | | | | | Move definitions for subpage handling into !CONFIG_USER_ONLY code. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Remove bogus cpu_physical_memory_rwPaul Brook2010-03-011-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>
* Remove l1_phys_map from userspace emulationPaul Brook2010-02-281-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>
* Fix userspace breakpoint invalidationPaul Brook2010-02-281-0/+7
| | | | | | | Remove bogus virtual->physical address translation in breakpoint_invalidate for userspace emulation. Signed-off-by: Paul Brook <paul@codesourcery.com>
* kvm: move kvm to use memory notifiersMichael S. Tsirkin2010-02-091-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>
* qemu: memory notifiersMichael S. Tsirkin2010-02-091-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>
* Merge remote branch 'qemu-kvm/uq/master' into staging-tmpAnthony Liguori2010-02-081-0/+6
|\
| * kvm: Flush coalesced MMIO buffer periodlySheng Yang2010-02-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default action of coalesced MMIO is, cache the writing in buffer, until: 1. The buffer is full. 2. Or the exit to QEmu due to other reasons. But this would result in a very late writing in some condition. 1. The each time write to MMIO content is small. 2. The writing interval is big. 3. No need for input or accessing other devices frequently. This issue was observed in a experimental embbed system. The test image simply print "test" every 1 seconds. The output in QEmu meets expectation, but the output in KVM is delayed for seconds. Per Avi's suggestion, I hooked flushing coalesced MMIO buffer in VGA update handler. By this way, We don't need vcpu explicit exit to QEmu to handle this issue. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | linux-user: remove signal handler before calling abort()Riku Voipio2010-02-061-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>
* | fix locking error with current_tbRiku Voipio2010-02-061-2/+2
| | | | | | | | Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
* | exec.c: dead assignmentsPaolo Bonzini2010-02-051-4/+0
|/ | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* win32: pair qemu_memalign() with qemu_vfree()Herve Poussineau2010-01-261-1/+1
| | | | | | | | | | Win32 suffers from a very big memory leak when dealing with SCSI devices. Each read/write request allocates memory with qemu_memalign (ie VirtualAlloc) but frees it with qemu_free (ie free). Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks. Signed-off-by: Herve Poussineau <hpoussin@reactos.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* linux-user: enable tb unlinking when compiled with NPTLRiku Voipio2009-12-191-5/+3
| | | | | | | | | | | | | Fixes receiving signals when guest code is being executed in a tight loop. For an example, try interrupting the following code with ctrl-c. http://nchipin.kos.to/test-loop.c The tight loop is ofcourse brainless, but it is also exactly how the waitpid* testcases are implemented. Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Give a error when running out of iomem areas.Riku Voipio2009-12-181-1/+1
| | | | | | | | | The limit of iomem areas is quite low. Without the debug print, it is quite hard to figure out why more devices are not getting registered. Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix win32 log file locationJuha Riihimäki2009-12-181-0/+4
| | | | | | | | /tmp doesn't exist under win32. Ease the pain of win32 development slightly. From: Juha Riihimäki <juha.riihimaki@nokia.com> Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Allocate physical memory in low virtual address spaceAlexander Graf2009-12-051-0/+6
| | | | | | | | | | | | | KVM on S390x requires the virtual address space of the guest's RAM to be within the first 256GB. The general direction I'd like to see KVM on S390 move is that this requirement is losened, but for now that's what we're stuck with. So let's just hack up qemu_ram_alloc until KVM behaves nicely :-). Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Add support for GNU/kFreeBSDAurelien Jarno2009-11-291-1/+1
| | | | Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* ksm supportIzik Eidus2009-10-151-0/+3
| | | | | | | | | | | Call MADV_MERGEABLE on guest memory allocations. MADV_MERGABLE will be available starting in Linux 2.6.32. This system call registers a region of virtual address space with Linux as a candidate for transparent memory sharing. Patchworks-ID: 35447 Signed-off-by: Izik Eidus <ieidus@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* fix comment on cpu_register_physical_memory_offsetMichael S. Tsirkin2009-10-051-2/+3
| | | | | | | | We don't require full pages in cpu_register_physical_memory, except for RAM. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vmstate: remove const from pre_save() functionsJuan Quintela2009-10-051-2/+2
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vmstate: add version_id argument to post_loadJuan Quintela2009-10-051-1/+1
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "Get rid of _t suffix"Anthony Liguori2009-10-011-109/+109
| | | | | | | | | | | | In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Get rid of _t suffixmalc2009-10-011-109/+109
| | | | | | | Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
* Fix sys-queue.h conflict for goodBlue Swirl2009-09-121-25/+25
| | | | | | | | | | | | | | | Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* vmstate: port cpu_comonJuan Quintela2009-09-111-14/+25
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* microblaze: Trap on bus accesses to unmapped areas.Edgar E. Iglesias2009-09-031-6/+6
| | | | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* kvm: Simplify cpu_synchronize_state()Avi Kivity2009-08-271-2/+2
| | | | | | | | | | | cpu_synchronize_state() is a little unreadable since the 'modified' argument isn't self-explanatory. Simplify it by making it always synchronize the kernel state into qemu, and automatically flush the registers back to the kernel if they've been synchronized on this exit. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Make CPURead/WriteFunc structure 'const'Blue Swirl2009-08-251-14/+14
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Unbreak large mem support by removing kqemuAnthony Liguori2009-08-241-89/+2
| | | | | | | | | | | | | | | | | | | | | | kqemu introduces a number of restrictions on the i386 target. The worst is that it prevents large memory from working in the default build. Furthermore, kqemu is fundamentally flawed in a number of ways. It relies on the TSC as a time source which will not be reliable on a multiple processor system in userspace. Since most modern processors are multicore, this severely limits the utility of kqemu. kvm is a viable alternative for people looking to accelerate qemu and has the benefit of being supported by the upstream Linux kernel. If someone can implement work arounds to remove the restrictions introduced by kqemu, I'm happy to avoid and/or revert this patch. N.B. kqemu will still function in the 0.11 series but this patch removes it from the 0.12 series. Paul, please Ack or Nack this patch. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix Sparse warnings: "Using plain integer as NULL pointer"Blue Swirl2009-07-311-3/+4
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* rename USE_NPTL to CONFIG_USE_NPTLJuan Quintela2009-07-271-1/+1
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32Filip Navara2009-07-271-1/+2
| | | | | | | On Win32 the setvbuf function requires the last parameter to be size between 2 and INT_MAX bytes, so the calls always failed. Since the whole point of the calls is to set line-buffered mode for the file handle and that's not supported on Win32 anyway, conditionally remove them. Signed-off-by: Filip Navara <filip.navara@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix most warnings (errors with -Werror) when debugging is enabledBlue Swirl2009-07-201-22/+3
| | | | | | | I used the following command to enable debugging: perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * */* */*/* Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* tlb flush cleanupIgor Kovalenko2009-07-161-6/+9
| | | | | | | | | | | | | Use static empty variable s_cputlb_empty_entry to clear entries, also reset addend member when clearing entries. This helps running with valgrind/memcheck Signed-off-by: igor.v.kovalenko@gmail.com -- Kind regards, Igor V. Kovalenko Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Update to a hopefully more future proof FSF addressBlue Swirl2009-07-161-2/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* cpu_unregister_map_client: fix memory leak.Isaku Yamahata2009-06-291-1/+2
| | | | | | | fix memory leak in cpu_unregister_map_client() and cpu_notify_map_clients(). Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Win32: Reduce section alignment for Windows.Stefan Weil2009-06-221-0/+4
| | | | | | | | | | | Maximum alignment for Win32 is 16, so don't try to set it to 32. Otherwise the compiler complains: exec.c:102: warning: alignment of 'code_gen_prologue' is greater than maximum object file alignment. Using 16 Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* exec.c: remove unnecessary #if NB_MMU_MODESIsaku Yamahata2009-06-161-76/+23
| | | | | | | | remove unnecessary #if NB_MMU_MODES by using loop. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud