HV: Fix new MISRAC violations for brackets

Fix remaining 11S and 12S violations. These
are after the 7 patches submitted earlier.

Signed-off-by: Arindam Roy <arindam.roy@intel.com>
This commit is contained in:
Arindam Roy 2018-07-12 16:46:07 -07:00 committed by lijinxia
parent 90b342bd53
commit 944776f238
19 changed files with 123 additions and 70 deletions

View File

@ -198,8 +198,9 @@ register_gas_io_handler(struct vm *vm, struct acpi_generic_address *gas)
if ((gas->address == 0UL) if ((gas->address == 0UL)
|| (gas->space_id != SPACE_SYSTEM_IO) || (gas->space_id != SPACE_SYSTEM_IO)
|| (gas->access_size == 0U) || (gas->access_size == 0U)
|| (gas->access_size > 4U)) || (gas->access_size > 4U)) {
return; return;
}
gas_io.flags = IO_ATTR_RW, gas_io.flags = IO_ATTR_RW,
gas_io.base = (uint16_t)gas->address, gas_io.base = (uint16_t)gas->address,

View File

@ -51,8 +51,9 @@ void acrn_update_ucode(struct vcpu *vcpu, uint64_t v)
(data_size + CPU_PAGE_SIZE - 1) >> CPU_PAGE_SHIFT; (data_size + CPU_PAGE_SIZE - 1) >> CPU_PAGE_SHIFT;
ucode_ptr = alloc_pages(data_page_num); ucode_ptr = alloc_pages(data_page_num);
if (ucode_ptr == NULL) if (ucode_ptr == NULL) {
return; return;
}
err_code = 0U; err_code = 0U;
err = copy_from_gva(vcpu, ucode_ptr, gva, data_size, &err_code); err = copy_from_gva(vcpu, ucode_ptr, gva, data_size, &err_code);

View File

@ -1682,8 +1682,9 @@ vlapic_deliver_intr(struct vm *vm, bool level, uint32_t dest, bool phys,
struct vlapic *vlapic; struct vlapic *vlapic;
bitmap_clear(vcpu_id, &dmask); bitmap_clear(vcpu_id, &dmask);
target_vcpu = vcpu_from_vid(vm, vcpu_id); target_vcpu = vcpu_from_vid(vm, vcpu_id);
if (target_vcpu == NULL) if (target_vcpu == NULL) {
return; return;
}
/* only make request when vlapic enabled */ /* only make request when vlapic enabled */
vlapic = target_vcpu->arch_vcpu.vlapic; vlapic = target_vcpu->arch_vcpu.vlapic;
@ -2112,8 +2113,9 @@ int vlapic_create(struct vcpu *vcpu)
(uint64_t)DEFAULT_APIC_BASE, (uint64_t)DEFAULT_APIC_BASE,
(uint64_t)DEFAULT_APIC_BASE + (uint64_t)DEFAULT_APIC_BASE +
CPU_PAGE_SIZE, CPU_PAGE_SIZE,
(void *) 0) != 0) (void *) 0) != 0) {
return -1; return -1;
}
} }
vcpu->arch_vcpu.vlapic = vlapic; vcpu->arch_vcpu.vlapic = vlapic;
@ -2455,8 +2457,9 @@ int apic_write_vmexit_handler(struct vcpu *vcpu)
break; break;
case APIC_OFFSET_ICR_LOW: case APIC_OFFSET_ICR_LOW:
error = vlapic_icrlo_write_handler(vlapic); error = vlapic_icrlo_write_handler(vlapic);
if (error != 0) if (error != 0) {
handled = 0; handled = 0;
}
break; break;
case APIC_OFFSET_CMCI_LVT: case APIC_OFFSET_CMCI_LVT:
case APIC_OFFSET_TIMER_LVT: case APIC_OFFSET_TIMER_LVT:

View File

@ -87,8 +87,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
/* Init mmio list */ /* Init mmio list */
INIT_LIST_HEAD(&vm->mmio_list); INIT_LIST_HEAD(&vm->mmio_list);
if (vm->hw.num_vcpus == 0U) if (vm->hw.num_vcpus == 0U) {
vm->hw.num_vcpus = phys_cpu_num; vm->hw.num_vcpus = phys_cpu_num;
}
vm->hw.vcpu_array = vm->hw.vcpu_array =
calloc(1, sizeof(struct vcpu *) * vm->hw.num_vcpus); calloc(1, sizeof(struct vcpu *) * vm->hw.num_vcpus);
@ -221,8 +222,9 @@ int shutdown_vm(struct vm *vm)
vioapic_cleanup(vm->arch_vm.virt_ioapic); vioapic_cleanup(vm->arch_vm.virt_ioapic);
/* Destroy secure world */ /* Destroy secure world */
if (vm->sworld_control.sworld_enabled) if (vm->sworld_control.sworld_enabled) {
destroy_secure_world(vm); destroy_secure_world(vm);
}
/* Free EPT allocated resources assigned to VM */ /* Free EPT allocated resources assigned to VM */
destroy_ept(vm); destroy_ept(vm);

View File

@ -489,8 +489,9 @@ static void vpic_set_pinstate(struct vpic *vpic, uint8_t pin, bool newstate)
} else if (oldcnt == 1 && newcnt == 0) { } else if (oldcnt == 1 && newcnt == 0) {
/* falling edge */ /* falling edge */
dev_dbg(ACRN_DBG_PIC, "pic pin%hhu: deasserted\n", pin); dev_dbg(ACRN_DBG_PIC, "pic pin%hhu: deasserted\n", pin);
if (level) if (level) {
pic->request &= ~(uint8_t)(1U << (pin & 0x7U)); pic->request &= ~(uint8_t)(1U << (pin & 0x7U));
}
} else { } else {
dev_dbg(ACRN_DBG_PIC, dev_dbg(ACRN_DBG_PIC,
"pic pin%hhu: %s, ignored, acnt %d\n", "pic pin%hhu: %s, ignored, acnt %d\n",
@ -598,8 +599,9 @@ int vpic_get_irq_trigger(struct vm *vm, uint32_t irq, enum vpic_trigger *trigger
{ {
struct vpic *vpic; struct vpic *vpic;
if (irq >= NR_VPIC_PINS_TOTAL) if (irq >= NR_VPIC_PINS_TOTAL) {
return -EINVAL; return -EINVAL;
}
vpic = vm_pic(vm); vpic = vm_pic(vm);
if (vpic == NULL) { if (vpic == NULL) {
@ -659,8 +661,9 @@ static void vpic_pin_accepted(struct pic *pic, uint8_t pin)
} }
if (pic->aeoi == true) { if (pic->aeoi == true) {
if (pic->rotate == true) if (pic->rotate == true) {
pic->lowprio = pin; pic->lowprio = pin;
}
} else { } else {
pic->service |= (uint8_t)(1U << pin); pic->service |= (uint8_t)(1U << pin);
} }
@ -756,8 +759,9 @@ static int vpic_write(struct vpic *vpic, struct pic *pic,
break; break;
} }
} else { } else {
if ((val & (1U << 4U)) != 0U) if ((val & (1U << 4U)) != 0U) {
error = vpic_icw1(vpic, pic, val); error = vpic_icw1(vpic, pic, val);
}
if (pic->ready) { if (pic->ready) {
if ((val & (1U << 3U)) != 0U) { if ((val & (1U << 3U)) != 0U) {

View File

@ -619,8 +619,9 @@ void unregister_handler_common(struct dev_handler_node *node)
} }
while (head->next != NULL) { while (head->next != NULL) {
if (head->next == node) if (head->next == node) {
break; break;
}
head = head->next; head = head->next;
} }

View File

@ -345,8 +345,9 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
/* Invalidate TLB and page-structure cache, /* Invalidate TLB and page-structure cache,
* if it is the first mapping no need to invalidate TLB * if it is the first mapping no need to invalidate TLB
*/ */
if ((table_type == PTT_HOST) && prev_entry_present) if ((table_type == PTT_HOST) && prev_entry_present) {
mmu_need_invtlb = true; mmu_need_invtlb = true;
}
break; break;
} }
case PAGING_REQUEST_TYPE_UNMAP: case PAGING_REQUEST_TYPE_UNMAP:
@ -360,8 +361,9 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
/* Unmap, need to invalidate TLB and /* Unmap, need to invalidate TLB and
* page-structure cache * page-structure cache
*/ */
if (table_type == PTT_HOST) if (table_type == PTT_HOST) {
mmu_need_invtlb = true; mmu_need_invtlb = true;
}
} }
break; break;
} }
@ -379,8 +381,9 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
/* Modify, need to invalidate TLB and /* Modify, need to invalidate TLB and
* page-structure cache * page-structure cache
*/ */
if (table_type == PTT_HOST) if (table_type == PTT_HOST) {
mmu_need_invtlb = true; mmu_need_invtlb = true;
}
break; break;
} }
case PAGING_REQUEST_TYPE_MODIFY_MT: case PAGING_REQUEST_TYPE_MODIFY_MT:
@ -554,8 +557,9 @@ static void *walk_paging_struct(void *addr, void *table_base,
/* Write entry to current table to reference the new /* Write entry to current table to reference the new
* sub-table * sub-table
*/ */
if (map_params->page_table_type == PTT_HOST) if (map_params->page_table_type == PTT_HOST) {
entry_present |= attr; entry_present |= attr;
}
mem_write64(table_base + table_offset, mem_write64(table_base + table_offset,
HVA2HPA(sub_table_addr) | entry_present); HVA2HPA(sub_table_addr) | entry_present);
@ -683,8 +687,9 @@ bool check_continuous_hpa(struct vm *vm, uint64_t gpa, uint64_t size)
curr_hpa = gpa2hpa(vm, gpa); curr_hpa = gpa2hpa(vm, gpa);
gpa += PAGE_SIZE_4K; gpa += PAGE_SIZE_4K;
next_hpa = gpa2hpa(vm, gpa); next_hpa = gpa2hpa(vm, gpa);
if (next_hpa != (curr_hpa + PAGE_SIZE_4K)) if (next_hpa != (curr_hpa + PAGE_SIZE_4K)) {
return false; return false;
}
size -= PAGE_SIZE_4K; size -= PAGE_SIZE_4K;
} }
return true; return true;
@ -703,8 +708,9 @@ int obtain_last_page_table_entry(struct map_params *map_params,
/* Obtain page table entry from PML4 table*/ /* Obtain page table entry from PML4 table*/
ret = get_table_entry(addr, table_addr, IA32E_PML4, &table_entry); ret = get_table_entry(addr, table_addr, IA32E_PML4, &table_entry);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
entry_present = check_page_table_present(map_params->page_table_type, entry_present = check_page_table_present(map_params->page_table_type,
table_entry); table_entry);
if (entry_present == PT_MISCFG_PRESENT) { if (entry_present == PT_MISCFG_PRESENT) {
@ -726,8 +732,9 @@ int obtain_last_page_table_entry(struct map_params *map_params,
/* Obtain page table entry from PDPT table*/ /* Obtain page table entry from PDPT table*/
table_addr = HPA2HVA(table_entry & IA32E_REF_MASK); table_addr = HPA2HVA(table_entry & IA32E_REF_MASK);
ret = get_table_entry(addr, table_addr, IA32E_PDPT, &table_entry); ret = get_table_entry(addr, table_addr, IA32E_PDPT, &table_entry);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
entry_present = check_page_table_present(map_params->page_table_type, entry_present = check_page_table_present(map_params->page_table_type,
table_entry); table_entry);
if (entry_present == PT_MISCFG_PRESENT) { if (entry_present == PT_MISCFG_PRESENT) {
@ -761,8 +768,9 @@ int obtain_last_page_table_entry(struct map_params *map_params,
/* Obtain page table entry from PD table*/ /* Obtain page table entry from PD table*/
table_addr = HPA2HVA(table_entry & IA32E_REF_MASK); table_addr = HPA2HVA(table_entry & IA32E_REF_MASK);
ret = get_table_entry(addr, table_addr, IA32E_PD, &table_entry); ret = get_table_entry(addr, table_addr, IA32E_PD, &table_entry);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
entry_present = check_page_table_present(map_params->page_table_type, entry_present = check_page_table_present(map_params->page_table_type,
table_entry); table_entry);
if (entry_present == PT_MISCFG_PRESENT) { if (entry_present == PT_MISCFG_PRESENT) {
@ -792,8 +800,9 @@ int obtain_last_page_table_entry(struct map_params *map_params,
/* Obtain page table entry from PT table*/ /* Obtain page table entry from PT table*/
table_addr = HPA2HVA(table_entry & IA32E_REF_MASK); table_addr = HPA2HVA(table_entry & IA32E_REF_MASK);
ret = get_table_entry(addr, table_addr, IA32E_PT, &table_entry); ret = get_table_entry(addr, table_addr, IA32E_PT, &table_entry);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
entry_present = check_page_table_present(map_params->page_table_type, entry_present = check_page_table_present(map_params->page_table_type,
table_entry); table_entry);
if (entry_present == PT_MISCFG_PRESENT) { if (entry_present == PT_MISCFG_PRESENT) {
@ -825,8 +834,9 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
/* Walk from the PML4 table to the PDPT table */ /* Walk from the PML4 table to the PDPT table */
table_addr = walk_paging_struct(vaddr, table_addr, IA32E_PML4, table_addr = walk_paging_struct(vaddr, table_addr, IA32E_PML4,
map_params, attr); map_params, attr);
if (table_addr == NULL) if (table_addr == NULL) {
return 0; return 0;
}
if ((remaining_size >= MEM_1G) if ((remaining_size >= MEM_1G)
&& (MEM_ALIGNED_CHECK(vaddr, MEM_1G)) && (MEM_ALIGNED_CHECK(vaddr, MEM_1G))
@ -842,8 +852,9 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
/* Walk from the PDPT table to the PD table */ /* Walk from the PDPT table to the PD table */
table_addr = walk_paging_struct(vaddr, table_addr, table_addr = walk_paging_struct(vaddr, table_addr,
IA32E_PDPT, map_params, attr); IA32E_PDPT, map_params, attr);
if (table_addr == NULL) if (table_addr == NULL) {
return 0; return 0;
}
/* Map this 2 MByte memory region */ /* Map this 2 MByte memory region */
adjustment_size = map_mem_region(vaddr, paddr, adjustment_size = map_mem_region(vaddr, paddr,
table_addr, attr, IA32E_PD, table_type, table_addr, attr, IA32E_PD, table_type,
@ -852,13 +863,15 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
/* Walk from the PDPT table to the PD table */ /* Walk from the PDPT table to the PD table */
table_addr = walk_paging_struct(vaddr, table_addr = walk_paging_struct(vaddr,
table_addr, IA32E_PDPT, map_params, attr); table_addr, IA32E_PDPT, map_params, attr);
if (table_addr == NULL) if (table_addr == NULL) {
return 0; return 0;
}
/* Walk from the PD table to the page table */ /* Walk from the PD table to the page table */
table_addr = walk_paging_struct(vaddr, table_addr = walk_paging_struct(vaddr,
table_addr, IA32E_PD, map_params, attr); table_addr, IA32E_PD, map_params, attr);
if (table_addr == NULL) if (table_addr == NULL) {
return 0; return 0;
}
/* Map this 4 KByte memory region */ /* Map this 4 KByte memory region */
adjustment_size = map_mem_region(vaddr, paddr, adjustment_size = map_mem_region(vaddr, paddr,
table_addr, attr, IA32E_PT, table_addr, attr, IA32E_PT,
@ -1010,8 +1023,9 @@ static int modify_paging(struct map_params *map_params, void *paddr,
*/ */
while (remaining_size > 0) { while (remaining_size > 0) {
if (obtain_last_page_table_entry(map_params, &entry, vaddr, if (obtain_last_page_table_entry(map_params, &entry, vaddr,
direct) < 0) direct) < 0) {
return -EINVAL; return -EINVAL;
}
/* filter the unmap request, no action in this case*/ /* filter the unmap request, no action in this case*/
page_size = entry.page_size; page_size = entry.page_size;
if ((request_type == PAGING_REQUEST_TYPE_UNMAP) if ((request_type == PAGING_REQUEST_TYPE_UNMAP)
@ -1040,8 +1054,9 @@ static int modify_paging(struct map_params *map_params, void *paddr,
*/ */
page_size = break_page_table(map_params, page_size = break_page_table(map_params,
paddr, vaddr, page_size, direct); paddr, vaddr, page_size, direct);
if (page_size == 0UL) if (page_size == 0UL) {
return -EINVAL; return -EINVAL;
}
} }
} else { } else {
page_size = ((uint64_t)remaining_size < page_size) page_size = ((uint64_t)remaining_size < page_size)
@ -1050,8 +1065,9 @@ static int modify_paging(struct map_params *map_params, void *paddr,
/* The function return the memory size that one entry can map */ /* The function return the memory size that one entry can map */
adjust_size = update_page_table_entry(map_params, paddr, vaddr, adjust_size = update_page_table_entry(map_params, paddr, vaddr,
page_size, attr, request_type, direct); page_size, attr, request_type, direct);
if (adjust_size == 0UL) if (adjust_size == 0UL) {
return -EINVAL; return -EINVAL;
}
vaddr += adjust_size; vaddr += adjust_size;
paddr += adjust_size; paddr += adjust_size;
remaining_size -= adjust_size; remaining_size -= adjust_size;
@ -1068,8 +1084,9 @@ int map_mem(struct map_params *map_params, void *paddr, void *vaddr,
/* used for MMU and EPT*/ /* used for MMU and EPT*/
ret = modify_paging(map_params, paddr, vaddr, size, flags, ret = modify_paging(map_params, paddr, vaddr, size, flags,
PAGING_REQUEST_TYPE_MAP, true); PAGING_REQUEST_TYPE_MAP, true);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
/* only for EPT */ /* only for EPT */
if (map_params->page_table_type == PTT_EPT) { if (map_params->page_table_type == PTT_EPT) {
ret = modify_paging(map_params, vaddr, paddr, size, flags, ret = modify_paging(map_params, vaddr, paddr, size, flags,
@ -1086,8 +1103,9 @@ int unmap_mem(struct map_params *map_params, void *paddr, void *vaddr,
/* used for MMU and EPT */ /* used for MMU and EPT */
ret = modify_paging(map_params, paddr, vaddr, size, flags, ret = modify_paging(map_params, paddr, vaddr, size, flags,
PAGING_REQUEST_TYPE_UNMAP, true); PAGING_REQUEST_TYPE_UNMAP, true);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
/* only for EPT */ /* only for EPT */
if (map_params->page_table_type == PTT_EPT) { if (map_params->page_table_type == PTT_EPT) {
ret = modify_paging(map_params, vaddr, paddr, size, flags, ret = modify_paging(map_params, vaddr, paddr, size, flags,
@ -1104,8 +1122,9 @@ int modify_mem(struct map_params *map_params, void *paddr, void *vaddr,
/* used for MMU and EPT*/ /* used for MMU and EPT*/
ret = modify_paging(map_params, paddr, vaddr, size, flags, ret = modify_paging(map_params, paddr, vaddr, size, flags,
PAGING_REQUEST_TYPE_MODIFY, true); PAGING_REQUEST_TYPE_MODIFY, true);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
/* only for EPT */ /* only for EPT */
if (map_params->page_table_type == PTT_EPT) { if (map_params->page_table_type == PTT_EPT) {
ret = modify_paging(map_params, vaddr, paddr, size, flags, ret = modify_paging(map_params, vaddr, paddr, size, flags,
@ -1122,8 +1141,9 @@ int modify_mem_mt(struct map_params *map_params, void *paddr, void *vaddr,
/* used for MMU and EPT*/ /* used for MMU and EPT*/
ret = modify_paging(map_params, paddr, vaddr, size, flags, ret = modify_paging(map_params, paddr, vaddr, size, flags,
PAGING_REQUEST_TYPE_MODIFY_MT, true); PAGING_REQUEST_TYPE_MODIFY_MT, true);
if (ret < 0) if (ret < 0) {
return ret; return ret;
}
/* only for EPT */ /* only for EPT */
if (map_params->page_table_type == PTT_EPT) { if (map_params->page_table_type == PTT_EPT) {

View File

@ -46,8 +46,9 @@ void setup_notification(void)
char name[32] = {0}; char name[32] = {0};
cpu = get_cpu_id(); cpu = get_cpu_id();
if (cpu > 0U) if (cpu > 0U) {
return; return;
}
/* support IPI notification, VM0 will register all CPU */ /* support IPI notification, VM0 will register all CPU */
snprintf(name, 32, "NOTIFY_ISR%d", cpu); snprintf(name, 32, "NOTIFY_ISR%d", cpu);
@ -63,7 +64,8 @@ void setup_notification(void)
static void cleanup_notification(void) static void cleanup_notification(void)
{ {
if (notification_node != NULL) if (notification_node != NULL) {
unregister_handler_common(notification_node); unregister_handler_common(notification_node);
}
notification_node = NULL; notification_node = NULL;
} }

View File

@ -31,8 +31,9 @@ void raise_softirq(int softirq_id)
uint16_t cpu_id = get_cpu_id(); uint16_t cpu_id = get_cpu_id();
uint64_t *bitmap = &per_cpu(softirq_pending, cpu_id); uint64_t *bitmap = &per_cpu(softirq_pending, cpu_id);
if (cpu_id >= phys_cpu_num) if (cpu_id >= phys_cpu_num) {
return; return;
}
bitmap_set(softirq_id, bitmap); bitmap_set(softirq_id, bitmap);
} }
@ -44,8 +45,9 @@ void exec_softirq(void)
uint16_t softirq_id; uint16_t softirq_id;
if (cpu_id >= phys_cpu_num) if (cpu_id >= phys_cpu_num) {
return; return;
}
if (((*bitmap) & SOFTIRQ_MASK) == 0UL) { if (((*bitmap) & SOFTIRQ_MASK) == 0UL) {
return; return;
@ -90,4 +92,3 @@ again:
enable_softirq(cpu_id); enable_softirq(cpu_id);
} }

View File

@ -313,8 +313,9 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
} }
idx = vcpu->arch_vcpu.cur_context; idx = vcpu->arch_vcpu.cur_context;
if (idx >= NR_WORLD) if (idx >= NR_WORLD) {
return -1; return -1;
}
ctx_ptr = &(vcpu->arch_vcpu.contexts[idx]); ctx_ptr = &(vcpu->arch_vcpu.contexts[idx]);

View File

@ -560,8 +560,9 @@ static void init_guest_state(struct vcpu *vcpu)
/*************************************************/ /*************************************************/
pr_dbg("Natural-width********"); pr_dbg("Natural-width********");
if (vcpu_mode == CPU_MODE_64BIT) if (vcpu_mode == CPU_MODE_64BIT) {
cur_context->ia32_efer = MSR_IA32_EFER_LME_BIT; cur_context->ia32_efer = MSR_IA32_EFER_LME_BIT;
}
/* Setup guest control register values /* Setup guest control register values
* cr4 should be set before cr0, because when set cr0, cr4 value will be * cr4 should be set before cr0, because when set cr0, cr4 value will be

View File

@ -410,11 +410,13 @@ static void dmar_register_hrhd(struct dmar_drhd_rt *dmar_uint)
#endif #endif
/* check capability */ /* check capability */
if ((iommu_cap_super_page_val(dmar_uint->cap) & 0x1UL) == 0) if ((iommu_cap_super_page_val(dmar_uint->cap) & 0x1UL) == 0) {
dev_dbg(ACRN_DBG_IOMMU, "dmar uint doesn't support 2MB page!"); dev_dbg(ACRN_DBG_IOMMU, "dmar uint doesn't support 2MB page!");
}
if ((iommu_cap_super_page_val(dmar_uint->cap) & 0x2UL) == 0) if ((iommu_cap_super_page_val(dmar_uint->cap) & 0x2UL) == 0) {
dev_dbg(ACRN_DBG_IOMMU, "dmar uint doesn't support 1GB page!"); dev_dbg(ACRN_DBG_IOMMU, "dmar uint doesn't support 1GB page!");
}
/* when the hardware support snoop control, /* when the hardware support snoop control,
* to make sure snoop control is always enabled, * to make sure snoop control is always enabled,
@ -610,8 +612,9 @@ static void dmar_invalid_iotlb(struct dmar_drhd_rt *dmar_uint,
case DMAR_IIRG_PAGE: case DMAR_IIRG_PAGE:
cmd |= DMA_IOTLB_PAGE_INVL | DMA_IOTLB_DID(did); cmd |= DMA_IOTLB_PAGE_INVL | DMA_IOTLB_DID(did);
addr = address | DMA_IOTLB_INVL_ADDR_AM(am); addr = address | DMA_IOTLB_INVL_ADDR_AM(am);
if (hint) if (hint) {
addr |= DMA_IOTLB_INVL_ADDR_IH_UNMODIFIED; addr |= DMA_IOTLB_INVL_ADDR_IH_UNMODIFIED;
}
break; break;
default: default:
pr_err("unknown IIRG type"); pr_err("unknown IIRG type");
@ -736,8 +739,9 @@ static void fault_status_analysis(uint32_t status)
static void fault_record_analysis(__unused uint64_t low, uint64_t high) static void fault_record_analysis(__unused uint64_t low, uint64_t high)
{ {
if (DMA_FRCD_UP_F(high) == 0U) if (DMA_FRCD_UP_F(high) == 0U) {
return; return;
}
/* currently skip PASID related parsing */ /* currently skip PASID related parsing */
pr_info("%s, Reason: 0x%x, SID: %x.%x.%x @0x%llx", pr_info("%s, Reason: 0x%x, SID: %x.%x.%x @0x%llx",

View File

@ -115,16 +115,18 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
pr_dbg("Loading guest to run-time location"); pr_dbg("Loading guest to run-time location");
/* FIXME: set config according to predefined offset */ /* FIXME: set config according to predefined offset */
if (!is_vm0(vm)) if (!is_vm0(vm)) {
return load_guest(vm, vcpu); return load_guest(vm, vcpu);
}
/* calculate the kernel entry point */ /* calculate the kernel entry point */
zeropage = (struct zero_page *) zeropage = (struct zero_page *)
vm->sw.kernel_info.kernel_src_addr; vm->sw.kernel_info.kernel_src_addr;
kernel_entry_offset = (zeropage->hdr.setup_sects + 1) * 512; kernel_entry_offset = (zeropage->hdr.setup_sects + 1) * 512;
if (vcpu->arch_vcpu.cpu_mode == CPU_MODE_64BIT) if (vcpu->arch_vcpu.cpu_mode == CPU_MODE_64BIT) {
/* 64bit entry is the 512bytes after the start */ /* 64bit entry is the 512bytes after the start */
kernel_entry_offset += 512; kernel_entry_offset += 512;
}
vm->sw.kernel_info.kernel_entry_addr = vm->sw.kernel_info.kernel_entry_addr =
(void *)((uint64_t)vm->sw.kernel_info.kernel_load_addr (void *)((uint64_t)vm->sw.kernel_info.kernel_load_addr

View File

@ -149,9 +149,10 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
/* switch to sbuf from sos */ /* switch to sbuf from sos */
do_copy_earlylog(sbuf, early_sbuf); do_copy_earlylog(sbuf, early_sbuf);
free_earlylog_sbuf(pcpu_id); free_earlylog_sbuf(pcpu_id);
} else } else {
/* use earlylog sbuf if no sbuf from sos */ /* use earlylog sbuf if no sbuf from sos */
sbuf = early_sbuf; sbuf = early_sbuf;
}
} }
if (sbuf != NULL) { if (sbuf != NULL) {

View File

@ -135,8 +135,9 @@ uint32_t serial_get_rx_data(uint32_t uart_handle)
uint8_t ch; uint8_t ch;
uint32_t total_bytes_read = 0U; uint32_t total_bytes_read = 0U;
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
return 0U; return 0U;
}
index = SERIAL_DECODE_INDEX(uart_handle); index = SERIAL_DECODE_INDEX(uart_handle);
if (index >= SERIAL_MAX_DEVS) { if (index >= SERIAL_MAX_DEVS) {

View File

@ -567,8 +567,9 @@ int shell_pause_vcpu(struct shell *p_shell,
vm_id = (uint16_t)status; vm_id = (uint16_t)status;
} }
vcpu_id = (uint16_t)atoi(argv[2]); vcpu_id = (uint16_t)atoi(argv[2]);
if (vcpu_id >= phys_cpu_num) if (vcpu_id >= phys_cpu_num) {
return (-EINVAL); return (-EINVAL);
}
vm = get_vm_from_vmid(vm_id); vm = get_vm_from_vmid(vm_id);
if (vm != NULL) { if (vm != NULL) {
vcpu = vcpu_from_vid(vm, vcpu_id); vcpu = vcpu_from_vid(vm, vcpu_id);
@ -622,8 +623,9 @@ int shell_resume_vcpu(struct shell *p_shell,
} }
vm_id = (uint16_t)status; vm_id = (uint16_t)status;
vcpu_id = (uint16_t)atoi(argv[2]); vcpu_id = (uint16_t)atoi(argv[2]);
if (vcpu_id >= phys_cpu_num) if (vcpu_id >= phys_cpu_num) {
return (-EINVAL); return (-EINVAL);
}
vm = get_vm_from_vmid(vm_id); vm = get_vm_from_vmid(vm_id);
if (vm != NULL) { if (vm != NULL) {
vcpu = vcpu_from_vid(vm, vcpu_id); vcpu = vcpu_from_vid(vm, vcpu_id);
@ -682,8 +684,9 @@ int shell_vcpu_dumpreg(struct shell *p_shell,
} }
vm_id = (uint16_t)status; vm_id = (uint16_t)status;
vcpu_id = (uint16_t)atoi(argv[2]); vcpu_id = (uint16_t)atoi(argv[2]);
if (vcpu_id >= phys_cpu_num) if (vcpu_id >= phys_cpu_num) {
return (-EINVAL); return (-EINVAL);
}
vm = get_vm_from_vmid(vm_id); vm = get_vm_from_vmid(vm_id);
if (vm == NULL) { if (vm == NULL) {
shell_puts(p_shell, "No vm found in the input " shell_puts(p_shell, "No vm found in the input "
@ -804,8 +807,9 @@ int shell_vcpu_dumpmem(struct shell *p_shell,
} }
vm_id = (uint16_t)status; vm_id = (uint16_t)status;
vcpu_id = (uint16_t)atoi(argv[2]); vcpu_id = (uint16_t)atoi(argv[2]);
if (vcpu_id >= phys_cpu_num) if (vcpu_id >= phys_cpu_num) {
return (-EINVAL); return (-EINVAL);
}
vm = get_vm_from_vmid(vm_id); vm = get_vm_from_vmid(vm_id);
if (vm == NULL) { if (vm == NULL) {
status = -EINVAL; status = -EINVAL;

View File

@ -64,8 +64,9 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
uint32_t requested_buffs; uint32_t requested_buffs;
/* Check if provided memory pool exists */ /* Check if provided memory pool exists */
if (pool == NULL) if (pool == NULL) {
return NULL; return NULL;
}
/* Acquire the pool lock */ /* Acquire the pool lock */
spinlock_obtain(&pool->spinlock); spinlock_obtain(&pool->spinlock);
@ -102,8 +103,9 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
* out-of-range * out-of-range
*/ */
tmp_idx++; tmp_idx++;
if (tmp_idx == pool->bmp_size) if (tmp_idx == pool->bmp_size) {
break; break;
}
/* Reset tmp_bit_idx */ /* Reset tmp_bit_idx */
tmp_bit_idx = 0U; tmp_bit_idx = 0U;
} }
@ -424,8 +426,9 @@ void *memset(void *base, uint8_t v, size_t n)
dest_p = (uint8_t *)base; dest_p = (uint8_t *)base;
if ((dest_p == NULL) || (n == 0U)) if ((dest_p == NULL) || (n == 0U)) {
return NULL; return NULL;
}
/*do the few bytes to get uint64_t alignment*/ /*do the few bytes to get uint64_t alignment*/
count = n; count = n;

View File

@ -229,8 +229,9 @@ static int format_number(struct print_param *param)
/* emit prefix, return early if an error occurred */ /* emit prefix, return early if an error occurred */
res = param->emit(PRINT_CMD_COPY, param->vars.prefix, res = param->emit(PRINT_CMD_COPY, param->vars.prefix,
param->vars.prefixlen, param->data); param->vars.prefixlen, param->data);
if ((param->vars.prefix != NULL) && (res < 0)) if ((param->vars.prefix != NULL) && (res < 0)) {
return res; return res;
}
/* invalidate prefix */ /* invalidate prefix */
param->vars.prefix = NULL; param->vars.prefix = NULL;
@ -241,8 +242,9 @@ static int format_number(struct print_param *param)
* an error occurred * an error occurred
*/ */
res = param->emit(PRINT_CMD_FILL, &pad, w, param->data); res = param->emit(PRINT_CMD_FILL, &pad, w, param->data);
if (res < 0) if (res < 0) {
return res; return res;
}
} }
/* emit prefix (if any), return early in case of an error */ /* emit prefix (if any), return early in case of an error */
@ -271,8 +273,9 @@ static int format_number(struct print_param *param)
if ((param->vars.flags & PRINT_FLAG_LEFT_JUSTIFY) != 0) { if ((param->vars.flags & PRINT_FLAG_LEFT_JUSTIFY) != 0) {
/* emit trailing blanks, return early in case of an error */ /* emit trailing blanks, return early in case of an error */
res = param->emit(PRINT_CMD_FILL, " ", w, param->data); res = param->emit(PRINT_CMD_FILL, " ", w, param->data);
if (res < 0) if (res < 0) {
return res; return res;
}
} }
/* done, return the last result */ /* done, return the last result */
@ -520,8 +523,9 @@ int do_print(const char *fmt, struct print_param *param,
if (*fmt == '.') { if (*fmt == '.') {
fmt++; fmt++;
fmt = get_int(fmt, &(param->vars.precision)); fmt = get_int(fmt, &(param->vars.precision));
if (param->vars.precision < 0) if (param->vars.precision < 0) {
param->vars.precision = 0; param->vars.precision = 0;
}
} }
fmt = get_length_modifier(fmt, &(param->vars.flags), fmt = get_length_modifier(fmt, &(param->vars.flags),

View File

@ -85,8 +85,7 @@ long strtol_deci(const char *nptr)
if (any < 0) { if (any < 0) {
acc = (neg != 0) ? LONG_MIN : LONG_MAX; acc = (neg != 0) ? LONG_MIN : LONG_MAX;
} } else if (neg != 0) {
else if (neg != 0) {
acc = -acc; acc = -acc;
} }
return acc; return acc;
@ -123,14 +122,11 @@ uint64_t strtoul_hex(const char *nptr)
do { do {
if (c >= '0' && c <= '9') { if (c >= '0' && c <= '9') {
c -= '0'; c -= '0';
} } else if (c >= 'A' && c <= 'F') {
else if (c >= 'A' && c <= 'F') {
c -= 'A' - 10; c -= 'A' - 10;
} } else if (c >= 'a' && c <= 'f') {
else if (c >= 'a' && c <= 'f') {
c -= 'a' - 10; c -= 'a' - 10;
} } else {
else {
break; break;
} }
if (c >= base) { if (c >= base) {
@ -138,8 +134,7 @@ uint64_t strtoul_hex(const char *nptr)
} }
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) { if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) {
any = -1; any = -1;
} } else {
else {
any = 1; any = 1;
acc *= base; acc *= base;
acc += c; acc += c;
@ -220,8 +215,9 @@ char *strcpy_s(char *d, size_t dmax, const char *s)
} }
*d = *s; *d = *s;
if (*d == '\0') if (*d == '\0') {
return dest_base; return dest_base;
}
d++; d++;
s++; s++;
@ -347,8 +343,9 @@ size_t strnlen_s(const char *str, size_t maxlen)
{ {
size_t count; size_t count;
if (str == NULL) if (str == NULL) {
return 0; return 0;
}
count = 0U; count = 0U;
while ((*str) != 0) { while ((*str) != 0) {