Skip to content

Commit 7494ed2

Browse files
JasonChenCJEddie Dong
authored andcommitted
Clean up MISRA C violation
clean up a few MISRA C violations that can be fixed by code change in vboot files Tracked-On: #861 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent d364d35 commit 7494ed2

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

efi-stub/boot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
271271
if (addr < 4096)
272272
Print(L"Warning: CPU trampoline code buf occupied zero-page\n");
273273

274-
efi_ctx->ap_trampoline_buf = (void *)addr;
274+
efi_ctx->ap_trampoline_buf = addr;
275275

276276
config_table = sys_table->ConfigurationTable;
277277

hypervisor/boot/guest/deprivilege_boot.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ static void init_depri_boot(void)
2626
struct multiboot_info *mbi = NULL;
2727

2828
if (!depri_initialized) {
29-
parse_hv_cmdline();
29+
(void)parse_hv_cmdline();
3030

3131
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
32-
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U) {
32+
if ((mbi == NULL) || ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U)) {
3333
pr_err("no multiboot drivers for depri_boot found");
3434
} else {
35-
memcpy_s(&depri_boot_ctx, sizeof(struct depri_boot_context),
35+
(void)memcpy_s(&depri_boot_ctx, sizeof(struct depri_boot_context),
3636
hpa2hva((uint64_t)mbi->mi_drives_addr),
3737
sizeof(struct depri_boot_context));
3838
save_lapic(&depri_boot_lapic_regs);
@@ -55,15 +55,15 @@ const struct lapic_regs *get_depri_boot_lapic_regs(void)
5555

5656
static uint64_t get_depri_boot_ap_trampoline(void)
5757
{
58-
return (uint64_t)(depri_boot_ctx.ap_trampoline_buf);
58+
return depri_boot_ctx.ap_trampoline_buf;
5959
}
6060

6161
static void* get_depri_boot_rsdp(void)
6262
{
6363
return hpa2hva((uint64_t)(depri_boot_ctx.rsdp));
6464
}
6565

66-
static void depri_boot_spurious_handler(int32_t vector)
66+
static void depri_boot_spurious_handler(uint32_t vector)
6767
{
6868
if (get_pcpu_id() == BOOT_CPU_ID) {
6969
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);

hypervisor/boot/guest/vboot_wrapper.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <vboot.h>
1313
#include <direct_boot.h>
1414
#include <deprivilege_boot.h>
15+
#include <logmsg.h>
1516

1617
#define BOOTLOADER_NUM 4U
1718
#define BOOTLOADER_NAME_SIZE 20U
@@ -42,18 +43,22 @@ void init_vboot_operations(void)
4243
};
4344

4445
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
45-
for (i = 0U; i < BOOTLOADER_NUM; i++) {
46-
if (strncmp(hpa2hva(mbi->mi_loader_name), vboot_bootloader_maps[i].bootloader_name,
47-
strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) {
48-
/* Only support two vboot mode */
49-
if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) {
50-
vboot_ops = get_deprivilege_boot_ops();
51-
sos_boot_mode = DEPRI_BOOT_MODE;
52-
} else {
53-
vboot_ops = get_direct_boot_ops();
54-
sos_boot_mode = DIRECT_BOOT_MODE;
46+
if (mbi == NULL) {
47+
panic("No multiboot info");
48+
} else {
49+
for (i = 0U; i < BOOTLOADER_NUM; i++) {
50+
if (strncmp(hpa2hva(mbi->mi_loader_name), vboot_bootloader_maps[i].bootloader_name,
51+
strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) {
52+
/* Only support two vboot mode */
53+
if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) {
54+
vboot_ops = get_deprivilege_boot_ops();
55+
sos_boot_mode = DEPRI_BOOT_MODE;
56+
} else {
57+
vboot_ops = get_direct_boot_ops();
58+
sos_boot_mode = DIRECT_BOOT_MODE;
59+
}
60+
break;
5561
}
56-
break;
5762
}
5863
}
5964
}

hypervisor/boot/include/guest/deprivilege_boot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
struct depri_boot_context {
1313
struct acrn_vcpu_regs vcpu_regs;
1414
void *rsdp;
15-
void *ap_trampoline_buf;
15+
uint64_t ap_trampoline_buf;
1616
} __packed;
1717

1818
const struct depri_boot_context *get_depri_boot_ctx(void);

0 commit comments

Comments
 (0)