memory: add memory_region_set_size

Add API to change MR size.
Will be used internally for RAM resize.

Backports commit e7af4c67300b3f9382e96f7a6741a5992116b2d2 from qemu
This commit is contained in:
Michael S. Tsirkin 2018-02-17 16:02:13 -05:00 committed by Lioncash
parent 73c55b2eb3
commit dce38dd8eb
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
16 changed files with 40 additions and 0 deletions

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_aarch64
#define memory_region_set_global_locking memory_region_set_global_locking_aarch64
#define memory_region_set_readonly memory_region_set_readonly_aarch64
#define memory_region_set_size memory_region_set_size_aarch64
#define memory_region_set_skip_dump memory_region_set_skip_dump_aarch64
#define memory_region_size memory_region_size_aarch64
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_aarch64

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_aarch64eb
#define memory_region_set_global_locking memory_region_set_global_locking_aarch64eb
#define memory_region_set_readonly memory_region_set_readonly_aarch64eb
#define memory_region_set_size memory_region_set_size_aarch64eb
#define memory_region_set_skip_dump memory_region_set_skip_dump_aarch64eb
#define memory_region_size memory_region_size_aarch64eb
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_aarch64eb

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_arm
#define memory_region_set_global_locking memory_region_set_global_locking_arm
#define memory_region_set_readonly memory_region_set_readonly_arm
#define memory_region_set_size memory_region_set_size_arm
#define memory_region_set_skip_dump memory_region_set_skip_dump_arm
#define memory_region_size memory_region_size_arm
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_arm

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_armeb
#define memory_region_set_global_locking memory_region_set_global_locking_armeb
#define memory_region_set_readonly memory_region_set_readonly_armeb
#define memory_region_set_size memory_region_set_size_armeb
#define memory_region_set_skip_dump memory_region_set_skip_dump_armeb
#define memory_region_size memory_region_size_armeb
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_armeb

View file

@ -2115,6 +2115,7 @@ symbols = (
'memory_region_set_enabled',
'memory_region_set_global_locking',
'memory_region_set_readonly',
'memory_region_set_size',
'memory_region_set_skip_dump',
'memory_region_size',
'memory_region_test_and_clear_dirty',

View file

@ -713,6 +713,16 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled);
*/
void memory_region_set_address(MemoryRegion *mr, hwaddr addr);
/*
* memory_region_set_size: dynamically update the size of a region.
*
* Dynamically updates the size of a region.
*
* @mr: the region to be updated
* @size: used size of the region.
*/
void memory_region_set_size(MemoryRegion *mr, uint64_t size);
/*
* memory_region_set_alias_offset: dynamically update a memory alias's offset
*

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_m68k
#define memory_region_set_global_locking memory_region_set_global_locking_m68k
#define memory_region_set_readonly memory_region_set_readonly_m68k
#define memory_region_set_size memory_region_set_size_m68k
#define memory_region_set_skip_dump memory_region_set_skip_dump_m68k
#define memory_region_size memory_region_size_m68k
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_m68k

View file

@ -1475,6 +1475,22 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled)
memory_region_transaction_commit(mr->uc);
}
void memory_region_set_size(MemoryRegion *mr, uint64_t size)
{
Int128 s = int128_make64(size);
if (size == UINT64_MAX) {
s = int128_2_64();
}
if (int128_eq(s, mr->size)) {
return;
}
memory_region_transaction_begin(mr->uc);
mr->size = s;
mr->uc->memory_region_update_pending = true;
memory_region_transaction_commit(mr->uc);
}
static void memory_region_readd_subregion(MemoryRegion *mr)
{
MemoryRegion *container = mr->container;

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_mips
#define memory_region_set_global_locking memory_region_set_global_locking_mips
#define memory_region_set_readonly memory_region_set_readonly_mips
#define memory_region_set_size memory_region_set_size_mips
#define memory_region_set_skip_dump memory_region_set_skip_dump_mips
#define memory_region_size memory_region_size_mips
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_mips

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_mips64
#define memory_region_set_global_locking memory_region_set_global_locking_mips64
#define memory_region_set_readonly memory_region_set_readonly_mips64
#define memory_region_set_size memory_region_set_size_mips64
#define memory_region_set_skip_dump memory_region_set_skip_dump_mips64
#define memory_region_size memory_region_size_mips64
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_mips64

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_mips64el
#define memory_region_set_global_locking memory_region_set_global_locking_mips64el
#define memory_region_set_readonly memory_region_set_readonly_mips64el
#define memory_region_set_size memory_region_set_size_mips64el
#define memory_region_set_skip_dump memory_region_set_skip_dump_mips64el
#define memory_region_size memory_region_size_mips64el
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_mips64el

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_mipsel
#define memory_region_set_global_locking memory_region_set_global_locking_mipsel
#define memory_region_set_readonly memory_region_set_readonly_mipsel
#define memory_region_set_size memory_region_set_size_mipsel
#define memory_region_set_skip_dump memory_region_set_skip_dump_mipsel
#define memory_region_size memory_region_size_mipsel
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_mipsel

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_powerpc
#define memory_region_set_global_locking memory_region_set_global_locking_powerpc
#define memory_region_set_readonly memory_region_set_readonly_powerpc
#define memory_region_set_size memory_region_set_size_powerpc
#define memory_region_set_skip_dump memory_region_set_skip_dump_powerpc
#define memory_region_size memory_region_size_powerpc
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_powerpc

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_sparc
#define memory_region_set_global_locking memory_region_set_global_locking_sparc
#define memory_region_set_readonly memory_region_set_readonly_sparc
#define memory_region_set_size memory_region_set_size_sparc
#define memory_region_set_skip_dump memory_region_set_skip_dump_sparc
#define memory_region_size memory_region_size_sparc
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_sparc

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_sparc64
#define memory_region_set_global_locking memory_region_set_global_locking_sparc64
#define memory_region_set_readonly memory_region_set_readonly_sparc64
#define memory_region_set_size memory_region_set_size_sparc64
#define memory_region_set_skip_dump memory_region_set_skip_dump_sparc64
#define memory_region_size memory_region_size_sparc64
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_sparc64

View file

@ -2109,6 +2109,7 @@
#define memory_region_set_enabled memory_region_set_enabled_x86_64
#define memory_region_set_global_locking memory_region_set_global_locking_x86_64
#define memory_region_set_readonly memory_region_set_readonly_x86_64
#define memory_region_set_size memory_region_set_size_x86_64
#define memory_region_set_skip_dump memory_region_set_skip_dump_x86_64
#define memory_region_size memory_region_size_x86_64
#define memory_region_test_and_clear_dirty memory_region_test_and_clear_dirty_x86_64