hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime
Use target_arch() to check at runtime which target architecture is being run. Note, since TARGET_ARM is defined for TARGET_AARCH64, we check for both ARM & AARCH64 enum values. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20250502214551.80401-4-philmd@linaro.org>
This commit is contained in:
parent
3c0b42c68f
commit
d9a8e9d79a
1 changed files with 16 additions and 8 deletions
|
|
@ -15,6 +15,7 @@
|
|||
#include "qemu/cutils.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/units.h"
|
||||
#include "qemu/target-info-qapi.h"
|
||||
#include "system/numa.h"
|
||||
#include "system/system.h"
|
||||
#include "system/ramblock.h"
|
||||
|
|
@ -170,13 +171,20 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
|
|||
* necessary (as the section size can change). But it's more likely that the
|
||||
* section size will rather get smaller and not bigger over time.
|
||||
*/
|
||||
#if defined(TARGET_X86_64) || defined(TARGET_I386) || defined(TARGET_S390X)
|
||||
#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))
|
||||
#elif defined(TARGET_ARM)
|
||||
#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
|
||||
#else
|
||||
#error VIRTIO_MEM_USABLE_EXTENT not defined
|
||||
#endif
|
||||
static uint64_t virtio_mem_usable_extent_size(void)
|
||||
{
|
||||
switch (target_arch()) {
|
||||
case SYS_EMU_TARGET_I386:
|
||||
case SYS_EMU_TARGET_X86_64:
|
||||
case SYS_EMU_TARGET_S390X:
|
||||
return 2 * 128 * MiB;
|
||||
case SYS_EMU_TARGET_AARCH64:
|
||||
case SYS_EMU_TARGET_ARM:
|
||||
return 2 * 512 * MiB;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static bool virtio_mem_is_busy(void)
|
||||
{
|
||||
|
|
@ -699,7 +707,7 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *vmem,
|
|||
bool can_shrink)
|
||||
{
|
||||
uint64_t newsize = MIN(memory_region_size(&vmem->memdev->mr),
|
||||
requested_size + VIRTIO_MEM_USABLE_EXTENT);
|
||||
requested_size + virtio_mem_usable_extent_size());
|
||||
|
||||
/* The usable region size always has to be multiples of the block size. */
|
||||
newsize = QEMU_ALIGN_UP(newsize, vmem->block_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue