Skip to content

Commit 40475e2

Browse files
lifeixacrnsi
authored andcommitted
hv: debug: use printf to debug on early boot
1) Using printf to warn if platform ram size configuration is wrong. 2) Using printf to warn if the platform is not supported by ACRN hypervisor. Tracked-On: #2987 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent cc47dbe commit 40475e2

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ void init_pcpu_pre(bool is_bsp)
120120
*/
121121
init_pcpu_capabilities();
122122

123+
if (detect_hardware_support() != 0) {
124+
panic("hardware not support!");
125+
}
126+
123127
init_pcpu_model_name();
124128

125129
load_pcpu_state_data();
@@ -128,10 +132,6 @@ void init_pcpu_pre(bool is_bsp)
128132
init_e820();
129133
init_paging();
130134

131-
if (!pcpu_has_cap(X86_FEATURE_X2APIC)) {
132-
panic("x2APIC is not present!");
133-
}
134-
135135
early_init_lapic();
136136

137137
init_vboot();
@@ -199,10 +199,6 @@ void init_pcpu_post(uint16_t pcpu_id)
199199

200200
pr_dbg("Core %hu is up", BOOT_CPU_ID);
201201

202-
if (detect_hardware_support() != 0) {
203-
panic("hardware not support!");
204-
}
205-
206202
if (!sanitize_vm_config()) {
207203
panic("VM Configuration Error!");
208204
}

hypervisor/arch/x86/cpu_caps.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ static int32_t check_vmx_mmu_cap(void)
332332
int32_t ret = 0;
333333

334334
if (!pcpu_has_vmx_ept_cap(VMX_EPT_INVEPT)) {
335-
pr_fatal("%s, invept not supported\n", __func__);
335+
printf("%s, invept not supported\n", __func__);
336336
ret = -ENODEV;
337337
} else if (!pcpu_has_vmx_vpid_cap(VMX_VPID_INVVPID) ||
338338
!pcpu_has_vmx_vpid_cap(VMX_VPID_INVVPID_SINGLE_CONTEXT) ||
339339
!pcpu_has_vmx_vpid_cap(VMX_VPID_INVVPID_GLOBAL_CONTEXT)) {
340-
pr_fatal("%s, invvpid not supported\n", __func__);
340+
printf("%s, invvpid not supported\n", __func__);
341341
ret = -ENODEV;
342342
} else if (!pcpu_has_vmx_ept_cap(VMX_EPT_1GB_PAGE)) {
343-
pr_fatal("%s, ept not support 1GB large page\n", __func__);
343+
printf("%s, ept not support 1GB large page\n", __func__);
344344
ret = -ENODEV;
345345
} else {
346346
/* No other state currently, do nothing */
@@ -361,65 +361,65 @@ int32_t detect_hardware_support(void)
361361

362362
/* Long Mode (x86-64, 64-bit support) */
363363
if (!pcpu_has_cap(X86_FEATURE_LM)) {
364-
pr_fatal("%s, LM not supported\n", __func__);
364+
printf("%s, LM not supported\n", __func__);
365365
ret = -ENODEV;
366366
} else if ((boot_cpu_data.phys_bits == 0U) ||
367367
(boot_cpu_data.virt_bits == 0U)) {
368-
pr_fatal("%s, can't detect Linear/Physical Address size\n", __func__);
368+
printf("%s, can't detect Linear/Physical Address size\n", __func__);
369369
ret = -ENODEV;
370370
} else if (!pcpu_has_cap(X86_FEATURE_TSC_DEADLINE)) {
371371
/* lapic TSC deadline timer */
372-
pr_fatal("%s, TSC deadline not supported\n", __func__);
372+
printf("%s, TSC deadline not supported\n", __func__);
373373
ret = -ENODEV;
374374
} else if (!pcpu_has_cap(X86_FEATURE_NX)) {
375375
/* Execute Disable */
376-
pr_fatal("%s, NX not supported\n", __func__);
376+
printf("%s, NX not supported\n", __func__);
377377
ret = -ENODEV;
378378
} else if (!pcpu_has_cap(X86_FEATURE_SMEP)) {
379379
/* Supervisor-Mode Execution Prevention */
380-
pr_fatal("%s, SMEP not supported\n", __func__);
380+
printf("%s, SMEP not supported\n", __func__);
381381
ret = -ENODEV;
382382
} else if (!pcpu_has_cap(X86_FEATURE_SMAP)) {
383383
/* Supervisor-Mode Access Prevention */
384-
pr_fatal("%s, SMAP not supported\n", __func__);
384+
printf("%s, SMAP not supported\n", __func__);
385385
ret = -ENODEV;
386386
} else if (!pcpu_has_cap(X86_FEATURE_MTRR)) {
387-
pr_fatal("%s, MTRR not supported\n", __func__);
387+
printf("%s, MTRR not supported\n", __func__);
388388
ret = -ENODEV;
389389
} else if (!pcpu_has_cap(X86_FEATURE_CLFLUSHOPT)) {
390-
pr_fatal("%s, CLFLUSHOPT not supported\n", __func__);
390+
printf("%s, CLFLUSHOPT not supported\n", __func__);
391391
ret = -ENODEV;
392392
} else if (!pcpu_has_cap(X86_FEATURE_PAGE1GB)) {
393-
pr_fatal("%s, not support 1GB page\n", __func__);
393+
printf("%s, not support 1GB page\n", __func__);
394394
ret = -ENODEV;
395395
} else if (!pcpu_has_cap(X86_FEATURE_VMX)) {
396-
pr_fatal("%s, vmx not supported\n", __func__);
396+
printf("%s, vmx not supported\n", __func__);
397397
ret = -ENODEV;
398398
} else if (!is_fast_string_erms_supported_and_enabled()) {
399399
ret = -ENODEV;
400400
} else if (!pcpu_has_vmx_unrestricted_guest_cap()) {
401-
pr_fatal("%s, unrestricted guest not supported\n", __func__);
401+
printf("%s, unrestricted guest not supported\n", __func__);
402402
ret = -ENODEV;
403403
} else if (!is_ept_supported()) {
404-
pr_fatal("%s, EPT not supported\n", __func__);
404+
printf("%s, EPT not supported\n", __func__);
405405
ret = -ENODEV;
406406
} else if (!is_apicv_basic_feature_supported()) {
407-
pr_fatal("%s, APICV not supported\n", __func__);
407+
printf("%s, APICV not supported\n", __func__);
408408
ret = -ENODEV;
409409
} else if (boot_cpu_data.cpuid_level < 0x15U) {
410-
pr_fatal("%s, required CPU feature not supported\n", __func__);
410+
printf("%s, required CPU feature not supported\n", __func__);
411411
ret = -ENODEV;
412412
} else if (is_vmx_disabled()) {
413-
pr_fatal("%s, VMX can not be enabled\n", __func__);
413+
printf("%s, VMX can not be enabled\n", __func__);
414414
ret = -ENODEV;
415415
} else if (get_pcpu_nums() > CONFIG_MAX_PCPU_NUM) {
416-
pr_fatal("%s, pcpu number(%d) is out of range\n", __func__, get_pcpu_nums());
416+
printf("%s, pcpu number(%d) is out of range\n", __func__, get_pcpu_nums());
417+
ret = -ENODEV;
418+
} else if (!pcpu_has_cap(X86_FEATURE_X2APIC)) {
419+
printf("%s, x2APIC not supported\n", __func__);
417420
ret = -ENODEV;
418421
} else {
419422
ret = check_vmx_mmu_cap();
420-
if (ret == 0) {
421-
pr_acrnlog("hardware support HV");
422-
}
423423
}
424424

425425
return ret;

hypervisor/arch/x86/mmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ void init_paging(void)
235235
high64_max_ram = round_pde_up(p_e820_mem_info->mem_top);
236236
if ((high64_max_ram > (CONFIG_PLATFORM_RAM_SIZE + PLATFORM_LO_MMIO_SIZE)) ||
237237
(high64_max_ram < (1UL << 32U))) {
238+
printf("ERROR!!! high64_max_ram: 0x%llx, top address space: 0x%llx\n",
239+
high64_max_ram, CONFIG_PLATFORM_RAM_SIZE + PLATFORM_LO_MMIO_SIZE);
238240
panic("Please configure HV_ADDRESS_SPACE correctly!\n");
239241
}
240242

0 commit comments

Comments
 (0)