Commit Graph

93 Commits

Author SHA1 Message Date
Paolo Bonzini
1551573acc
memory: differentiate memory_region_is_logging and memory_region_get_dirty_log_mask
For now memory regions only track DIRTY_MEMORY_VGA individually, but
this will change soon. To support this, split memory_region_is_logging
in two functions: one that returns a given bit from dirty_log_mask,
and one that returns the entire mask. memory_region_is_logging gets an
extra parameter so that the compiler flags misuse.

While VGA-specific users (including the Xen listener!) will want to keep
checking that bit, KVM and vhost check for "any bit except migration"
(because migration is handled via the global start/stop listener
callbacks).

Backports commit 2d1a35bef0ed96b3f23535e459c552414ccdbafd from qemu
2018-02-13 08:41:44 -05:00
Peter Maydell
825e74410f
memory: Replace io_mem_read/write with memory_region_dispatch_read/write
Rather than retaining io_mem_read/write as simple wrappers around
the memory_region_dispatch_read/write functions, make the latter
public and change all the callers to use them, since we need to
touch all the callsites anyway to add MemTxAttrs and MemTxResult
support. Delete io_mem_read and io_mem_write entirely.

(All the callers currently pass MEMTXATTRS_UNSPECIFIED
and convert the return value back to bool or ignore it.)

Backports commit 3b6434953934e6d4a776ed426d8c6d6badee176f from qemu
2018-02-12 17:26:52 -05:00
Peter Maydell
b2962f4613
memory: Define API for MemoryRegionOps to take attrs and return status
Define an API so that devices can register MemoryRegionOps whose read
and write callback functions are passed an arbitrary pointer to some
transaction attributes and can return a success-or-failure status code.
This will allow us to model devices which:
* behave differently for ARM Secure/NonSecure memory accesses
* behave differently for privileged/unprivileged accesses
* may return a transaction failure (causing a guest exception)
for erroneous accesses

This patch defines the new API and plumbs the attributes parameter through
to the memory.c public level functions io_mem_read() and io_mem_write(),
where it is currently dummied out.

The success/failure response indication is also propagated out to
io_mem_read() and io_mem_write(), which retain the old-style
boolean true-for-error return.

Backports commit cc05c43ad942165ecc6ffd39e41991bee43af044 from qemu
2018-02-12 17:17:27 -05:00
Nguyen Anh Quynh
6ea39f7d5a merge msvc with master 2017-02-24 10:39:36 +08:00
Nguyen Anh Quynh
5de0785a1b cleanup qemu/memory.c 2017-01-22 23:07:17 +08:00
Nguyen Anh Quynh
206819bd98 cleanup after msvc port 2017-01-22 21:27:17 +08:00
xorstream
770c5616e2 Automated leading tab to spaces conversion. 2017-01-21 12:28:22 +11:00
xorstream
b0ae2138fb Merge remote-tracking branch 'unicorn-engine/master' into msvc_native 2017-01-20 22:37:51 +11:00
Nguyen Anh Quynh
c6de7930c9 remove mutex code 2017-01-20 15:44:03 +08:00
Nguyen Anh Quynh
a7fca49f7a delete qemu/include/qemu/notify.h 2017-01-20 14:47:41 +08:00
xorstream
002151874a Unicorn interface working with test app in 32bit and 64bit builds. 2017-01-20 17:27:22 +11:00
xorstream
1aeaf5c40d This code should now build the x86_x64-softmmu part 2. 2017-01-19 22:50:28 +11:00
Chris Eagle
fccbcfd4c2 revert to use of g_free to make future qemu integrations easier (#695)
* revert to use of g_free to make future qemu integrations easier

* bracing
2016-12-21 22:28:36 +08:00
Chris Eagle
e46545f722 remove glib dependency by provide compatible replacements 2016-12-18 14:56:58 -08:00
Fish
ad7ae63e92 Remove unmapped/freed memory regions from the object property list.
This commit fixes the following issues:
- Any unmapped/free'd memory regions (MemoryRegion instances) are not
  removed from the object property linked list of its owner (which is
  always qdev_get_machine(uc)). This issue makes adding new memory
  mapping by calling mem_map() or mem_map_ptr() slower as more and more
  memory pages are mapped and unmapped - yes, even if those memory pages
  are unmapped, they still impact the speed of future memory page
  mappings due to this issue.
- FlatView is not reconstructed after a memory region is freed during
  unmapping, which leads to a use-after-free the next time a new memory
  region is mapped in address_space_update_topology().
2016-10-20 03:48:58 -07:00
Nguyen Anh Quynh
8b030ae51a fix for issue #523 2016-08-27 21:49:11 +08:00
Nguyen Anh Quynh
b69feb8d0b Merge branch 'master' into memleak2 2016-02-15 15:52:10 +08:00
coco
95beec805c fixed memcpy that should be memmove 2016-02-11 16:38:50 +01:00
farmdve
036763d6ae Fix memory leaks as reported by DrMemory and Valgrind.
ARM and probably the rest of the arches have significant memory leaks as
they have no release interface.

Additionally, DrMemory does not have 64-bit support and thus I can't
test the 64-bit version under Windows. Under Linux valgrind supports
both 32-bit and 64-bit but there are different macros and code for Linux
and Windows.
2016-01-08 01:42:56 +02:00
Nguyen Anh Quynh
771f9f7c3b fix conflicts when merging map-ptr branch to master branch 2015-12-17 08:12:02 +08:00
farmdve
8b79a872d0 Fix segfault introduced in my previous commits. 2015-12-11 22:35:25 +02:00
Nguyen Anh Quynh
74986cc59a g_free() can handle NULL pointer 2015-12-11 11:25:35 +08:00
farmdve
3e57615c76 Fix uc_mem_unmap memory leak and in uc_close.
It appears the problem is that we are not calling the memory region
destructor. After modifying memory_unmap to include the destructor call
for the memory region, the memory is freed.

Furthermore in uc_close we must explicitly free any blocks that were not
unmapped by the user to prevent leaks.

This should fix issue 305.
2015-12-11 02:42:31 +02:00
Ryan Hileman
230cbd5330 add permissions to map_ptr api 2015-11-28 11:28:31 -08:00
Nguyen Anh Quynh
4a759cebb5 set permission for memory region allocated by memory_map_ptr(). this fixes the segfault in sample_x86.c, function test_x86_map_ptr() 2015-11-28 17:11:27 +08:00
Ryan Hileman
6d21ebabea implement host-controlled memory mapping for #261 2015-11-27 23:30:36 -08:00
Nguyen Anh Quynh
272293556a do not abort() when memory is insufficient. this fixes issue #244 2015-11-10 11:44:29 +08:00
Nguyen Anh Quynh
b66a323b19 do not free MemoryRegion in memory_unmap() because it will be unref later in memory_region_unref(). this fixes issue #202 2015-10-28 01:26:59 +08:00
Chris Eagle
8cfd902e4b Move mem_xxx samples to regress. Add check to only flush tlb when unmapping if there is a current cpu 2015-09-04 00:48:24 -07:00
Chris Eagle
2da46caef7 smooth out split_region related code 2015-09-03 12:26:36 -07:00
Chris Eagle
b27e987932 Add target_page_size member to uc_struct to track TARGET_PAGE_SIZE 2015-08-31 01:00:44 -07:00
Chris Eagle
410e317e92 dont use explicit page size, use TARGET_PAGE_SIZE 2015-08-30 21:24:14 -07:00
Chris Eagle
0a60fa4c8a fix perms 2015-08-30 00:22:49 -07:00
Chris Eagle
942de0f2ae implemented basic block splitting, uc_mem_unmap should work for sub=blocks or across contiguous blocks 2015-08-30 00:22:18 -07:00
Chris Eagle
4a680b9277 Merge branch 'master' into mem_map_ex_cse 2015-08-29 21:22:33 -07:00
Chris Eagle
6beb1b8a13 intermediate commit, working unmap of complete blocks, still need sub-blocks, and cross block 2015-08-29 21:17:30 -07:00
Nguyen Anh Quynh
c23d387e2f remove redundant uc_struct.ram 2015-08-30 10:51:28 +08:00
Nguyen Anh Quynh
3b5df362d7 chmod -x <some source code> 2015-08-28 18:12:56 +08:00
Chris Eagle
9530b2daff Remove MemoryBlock struct by consolidating in MemoryRegion. add new API uc_mem_protect. Add regress/mem_protect.c. Drop UC_PROT_EXEC for time being 2015-08-27 23:19:32 -07:00
Chris Eagle
686acb7e6e Detect all occurences of write to read only page. Add callback capability on write to read only. Add new error type UC_ERR_MEM_WRITE_RO and new access type UC_MEM_WRITE_RO for use in callback 2015-08-27 18:03:17 -07:00
Chris Eagle
4b529bc56c Free up all MemoryRegion* when uc is closed 2015-08-26 14:09:46 -07:00
Chris Eagle
00944b6cde Add ability to mark memory are read only. Add new API uc_mem_map_ex to allow permissions to be passed. Change MemoryBlock to track created MemoryRegions. Add regress/ro_mem_test.c 2015-08-26 13:29:54 -07:00
Nguyen Anh Quynh
344d016104 import 2015-08-21 15:04:50 +08:00