From b67b94ab73813d2f98f4bb1186dfe481ab4df1bc Mon Sep 17 00:00:00 2001 From: psorokin Date: Thu, 6 Dec 2018 12:26:43 +0300 Subject: [PATCH] Change max vms to 64 and rename variable This change will allow running more than 8 virtual machines. uint8_t changed to uint64_t Signed-off-by: Pavel Sorokin --- core/include/config.h | 2 ++ core/vm.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/include/config.h b/core/include/config.h index 535ad67e..afaea13f 100644 --- a/core/include/config.h +++ b/core/include/config.h @@ -65,5 +65,7 @@ struct config_t { }; #define HAX_MAX_VCPUS 16 +// Matches the number of bits in vm_mid_bits (see vm.c) +#define HAX_MAX_VMS 64 #endif // HAX_CORE_CONFIG_H_ diff --git a/core/vm.c b/core/vm.c index 184a943d..45fb6323 100644 --- a/core/vm.c +++ b/core/vm.c @@ -35,9 +35,9 @@ #include "include/hax_core_interface.h" #include "include/ept.h" #include "include/paging.h" +#include "include/config.h" -static uint8_t vm_mid_bits = 0; -#define VM_MID_BIT 8 +static uint64_t vm_mid_bits = 0; #ifdef HAX_ARCH_X86_32 static void gpfn_to_hva_recycle_total(struct vm_t *vm, uint64_t cr3_cur, @@ -48,7 +48,7 @@ static int get_free_vm_mid(void) { int i; - for (i = 0; i < VM_MID_BIT; i++) { + for (i = 0; i < HAX_MAX_VMS; i++) { if (!hax_test_and_set_bit(i, (uint64_t *)&vm_mid_bits)) return i; } @@ -64,7 +64,7 @@ static void hax_put_vm_mid(int id) static int valid_vm_mid(int vm_id) { - return (vm_id >= 0) && (vm_id < VM_MID_BIT); + return (vm_id >= 0) && (vm_id < HAX_MAX_VMS); } int hax_vm_set_qemuversion(struct vm_t *vm, struct hax_qemu_version *ver)