Skip to content

Commit a44c1c9

Browse files
jsun26intelwenlingz
authored andcommitted
HV: Kconfig: remove MAX_VCPUS_PER_VM in Kconfig
In current architecutre, the maximum vCPUs number per VM could not exceed the pCPUs number. Given the MAX_PCPU_NUM macro is provided in board configurations, so remove the MAX_VCPUS_PER_VM from Kconfig and add a macro of MAX_VCPUS_PER_VM to reference MAX_PCPU_NUM directly. Tracked-On: #4230 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 0ba8434 commit a44c1c9

File tree

10 files changed

+15
-21
lines changed

10 files changed

+15
-21
lines changed

hypervisor/arch/x86/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ config RELEASE
7676
console and hypervisor shell are available only in non-release
7777
(i.e. debug) builds. Assertions are not effective in release builds.
7878

79-
config MAX_VCPUS_PER_VM
80-
int "Maximum number of VCPUs per VM"
81-
range 1 48
82-
default 8
83-
help
84-
The maximum number of virtual CPUs the hypervisor can support in a
85-
single VM.
86-
8779
config MAX_EMULATED_MMIO_REGIONS
8880
int "Maximum number of emulated MMIO regions"
8981
range 0 128

hypervisor/arch/x86/guest/hyperv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ hyperv_init_vcpuid_entry(uint32_t leaf, uint32_t subleaf, uint32_t flags,
262262
entry->edx = 0U;
263263
break;
264264
case 0x40000005U: /* HV Maximum Supported Virtual & logical Processors */
265-
entry->eax = CONFIG_MAX_VCPUS_PER_VM;
265+
entry->eax = MAX_VCPUS_PER_VM;
266266
entry->ebx = 0U;
267267
entry->ecx = 0U;
268268
entry->edx = 0U;

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
412412
* vm->hw.created_vcpus++;
413413
*/
414414
vcpu_id = vm->hw.created_vcpus;
415-
if (vcpu_id < CONFIG_MAX_VCPUS_PER_VM) {
415+
if (vcpu_id < MAX_VCPUS_PER_VM) {
416416
/* Allocate memory for VCPU */
417417
vcpu = &(vm->hw.vcpu_array[vcpu_id]);
418418
(void)memset((void *)vcpu, 0U, sizeof(struct acrn_vcpu));
@@ -443,7 +443,7 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
443443
*
444444
* This assignment guarantees a unique non-zero per vcpu vpid in runtime.
445445
*/
446-
vcpu->arch.vpid = 1U + (vm->vm_id * CONFIG_MAX_VCPUS_PER_VM) + vcpu->vcpu_id;
446+
vcpu->arch.vpid = 1U + (vm->vm_id * MAX_VCPUS_PER_VM) + vcpu->vcpu_id;
447447

448448
/* Initialize exception field in VCPU context */
449449
vcpu->arch.exception_info.exception = VECTOR_INVALID;

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ vlapic_reset(struct acrn_vlapic *vlapic, const struct acrn_apicv_ops *ops)
16851685

16861686
/**
16871687
* @pre vlapic->vm != NULL
1688-
* @pre vlapic->vcpu->vcpu_id < CONFIG_MAX_VCPUS_PER_VM
1688+
* @pre vlapic->vcpu->vcpu_id < MAX_VCPUS_PER_VM
16891689
*/
16901690
void
16911691
vlapic_init(struct acrn_vlapic *vlapic)

hypervisor/common/hypercall.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int32_t hcall_get_platform_info(struct acrn_vm *vm, uint64_t param)
120120
struct hc_platform_info platform_info;
121121

122122
platform_info.cpu_num = get_pcpu_nums();
123-
platform_info.max_vcpus_per_vm = CONFIG_MAX_VCPUS_PER_VM;
123+
platform_info.max_vcpus_per_vm = MAX_VCPUS_PER_VM;
124124
platform_info.max_kata_containers = CONFIG_MAX_KATA_VM_NUM;
125125
if (copy_to_gpa(vm, &platform_info, param, sizeof(platform_info)) != 0) {
126126
pr_err("%s: Unable copy param to vm\n", __func__);
@@ -317,7 +317,7 @@ int32_t hcall_set_vcpu_regs(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
317317
(target_vm->state != VM_STARTED)) {
318318
if (copy_from_gpa(vm, &vcpu_regs, param, sizeof(vcpu_regs)) != 0) {
319319
pr_err("%s: Unable copy param to vm\n", __func__);
320-
} else if (vcpu_regs.vcpu_id >= CONFIG_MAX_VCPUS_PER_VM) {
320+
} else if (vcpu_regs.vcpu_id >= MAX_VCPUS_PER_VM) {
321321
pr_err("%s: invalid vcpu_id for set_vcpu_regs\n", __func__);
322322
} else {
323323
vcpu = vcpu_from_vid(target_vm, vcpu_regs.vcpu_id);
@@ -548,7 +548,7 @@ int32_t hcall_notify_ioreq_finish(uint16_t vmid, uint16_t vcpu_id)
548548
dev_dbg(ACRN_DBG_HYCALL, "[%d] NOTIFY_FINISH for vcpu %d",
549549
vmid, vcpu_id);
550550

551-
if (vcpu_id >= CONFIG_MAX_VCPUS_PER_VM) {
551+
if (vcpu_id >= MAX_VCPUS_PER_VM) {
552552
pr_err("%s, failed to get VCPU %d context from VM %d\n",
553553
__func__, vcpu_id, target_vm->vm_id);
554554
} else {

hypervisor/include/arch/x86/guest/vlapic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void vlapic_create(struct acrn_vcpu *vcpu);
191191
void vlapic_free(struct acrn_vcpu *vcpu);
192192
/**
193193
* @pre vlapic->vm != NULL
194-
* @pre vlapic->vcpu->vcpu_id < CONFIG_MAX_VCPUS_PER_VM
194+
* @pre vlapic->vcpu->vcpu_id < MAX_VCPUS_PER_VM
195195
*/
196196
void vlapic_init(struct acrn_vlapic *vlapic);
197197
void vlapic_reset(struct acrn_vlapic *vlapic, const struct acrn_apicv_ops *ops);

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
struct vm_hw_info {
3434
/* vcpu array of this VM */
35-
struct acrn_vcpu vcpu_array[CONFIG_MAX_VCPUS_PER_VM];
35+
struct acrn_vcpu vcpu_array[MAX_VCPUS_PER_VM];
3636
uint16_t created_vcpus; /* Number of created vcpus */
3737
} __aligned(PAGE_SIZE);
3838

@@ -165,7 +165,7 @@ static inline uint64_t vm_active_cpus(const struct acrn_vm *vm)
165165
}
166166

167167
/*
168-
* @pre vcpu_id < CONFIG_MAX_VCPUS_PER_VM
168+
* @pre vcpu_id < MAX_VCPUS_PER_VM
169169
* @pre &(vm->hw.vcpu_array[vcpu_id])->state != VCPU_OFFLINE
170170
*/
171171
static inline struct acrn_vcpu *vcpu_from_vid(struct acrn_vm *vm, uint16_t vcpu_id)

hypervisor/include/arch/x86/vm_config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <sgx.h>
1616

1717
#define AFFINITY_CPU(n) (1U << (n))
18+
#define MAX_VCPUS_PER_VM MAX_PCPU_NUM
1819
#define MAX_VUART_NUM_PER_VM 2U
1920
#define MAX_VM_OS_NAME_LEN 32U
2021
#define MAX_MOD_TAG_LEN 32U
@@ -99,7 +100,7 @@ struct acrn_vm_config {
99100
const uint8_t uuid[16]; /* UUID of the VM */
100101
uint16_t vcpu_num; /* Number of vCPUs for the VM */
101102

102-
uint64_t vcpu_affinity[CONFIG_MAX_VCPUS_PER_VM];/* bitmaps for vCPUs' affinity */
103+
uint64_t vcpu_affinity[MAX_VCPUS_PER_VM];/* bitmaps for vCPUs' affinity */
103104
uint64_t guest_flags; /* VM flags that we want to configure for guest
104105
* Now we have two flags:
105106
* GUEST_FLAG_SECURE_WORLD_ENABLED

hypervisor/include/debug/profiling_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifdef PROFILING_ON
1111

1212
#include <vcpu.h>
13+
#include <vm_config.h>
1314
#include <vm_configurations.h>
1415

1516
#define MAX_MSR_LIST_NUM 15U
@@ -114,7 +115,7 @@ struct profiling_vm_info {
114115
uint8_t uuid[16];
115116
char vm_name[16];
116117
uint16_t num_vcpus;
117-
struct profiling_vcpu_pcpu_map cpu_map[CONFIG_MAX_VCPUS_PER_VM];
118+
struct profiling_vcpu_pcpu_map cpu_map[MAX_VCPUS_PER_VM];
118119
};
119120

120121
struct profiling_vm_info_list {

hypervisor/pre_build/static_checks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
typedef int32_t CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]
1717

1818
/* This is to make sure the 16 bits vpid won't overflow */
19-
#if ((CONFIG_MAX_VM_NUM * CONFIG_MAX_VCPUS_PER_VM) > 0xffffU)
19+
#if ((CONFIG_MAX_VM_NUM * MAX_VCPUS_PER_VM) > 0xffffU)
2020
#error "VM number or VCPU number are too big"
2121
#endif
2222

0 commit comments

Comments
 (0)