Skip to content

Commit

Permalink
hv: fix misra-c violations in reused partition mode functions
Browse files Browse the repository at this point in the history
Fixed violations in vlapic_x2apic_pt_icr_access()
- Procedure has more than one exit point;
- Value is not of appropriate type;
- Narrower init conversion without cast;
- Implicit conversion: actual to formal param (MR)
Fixed violation in switch_apicv_mode_x2apic()
- No space between if, while, for and expresn.

Tracked-On: #861
Signed-off-by: Yan, Like <like.yan@intel.com>
  • Loading branch information
lyan3 authored and wenlingz committed Jan 29, 2019
1 parent 7d4ba5d commit b038ade
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions hypervisor/arch/x86/guest/vlapic.c
Expand Up @@ -2075,41 +2075,41 @@ static inline uint32_t x2apic_msr_to_regoff(uint32_t msr)
static int32_t
vlapic_x2apic_pt_icr_access(struct acrn_vm *vm, uint64_t val)
{
uint64_t apic_id = (uint32_t) (val >> 32U);
uint32_t icr_low = val;
uint32_t apic_id = (uint32_t)(val >> 32U);
uint32_t icr_low = (uint32_t)val;
uint32_t mode = icr_low & APIC_DELMODE_MASK;
uint16_t vcpu_id;
struct acrn_vcpu *target_vcpu;
bool phys;
uint32_t shorthand;
int32_t ret = 0;

phys = ((icr_low & APIC_DESTMODE_LOG) == 0UL);
shorthand = icr_low & APIC_DEST_MASK;

if ((phys == false) || (shorthand != APIC_DEST_DESTFLD)) {
pr_err("Logical destination mode or shorthands \
not supported in ICR forpartition mode\n");
return -1;
}

vcpu_id = vm_apicid2vcpu_id(vm, apic_id);
target_vcpu = vcpu_from_vid(vm, vcpu_id);
ret = -1;
} else {
vcpu_id = vm_apicid2vcpu_id(vm, apic_id);
target_vcpu = vcpu_from_vid(vm, vcpu_id);

if (target_vcpu == NULL) {
return 0;
}
switch (mode) {
case APIC_DELMODE_INIT:
vlapic_process_init_sipi(target_vcpu, mode, icr_low, vcpu_id);
break;
case APIC_DELMODE_STARTUP:
vlapic_process_init_sipi(target_vcpu, mode, icr_low, vcpu_id);
break;
default:
msr_write(MSR_IA32_EXT_APIC_ICR, (apic_id << 32U) | icr_low);
break;
if (target_vcpu != NULL) {
switch (mode) {
case APIC_DELMODE_INIT:
vlapic_process_init_sipi(target_vcpu, mode, icr_low, vcpu_id);
break;
case APIC_DELMODE_STARTUP:
vlapic_process_init_sipi(target_vcpu, mode, icr_low, vcpu_id);
break;
default:
msr_write(MSR_IA32_EXT_APIC_ICR, (((uint64_t)apic_id) << 32U) | icr_low);
break;
}
}
}
return 0;
return ret;
}

static int32_t vlapic_x2apic_access(struct acrn_vcpu *vcpu, uint32_t msr, bool write,
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/arch/x86/vmcs.c
Expand Up @@ -563,7 +563,7 @@ void init_vmcs(struct acrn_vcpu *vcpu)
void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
{
uint32_t value32;
if(is_lapic_pt(vcpu->vm)) {
if (is_lapic_pt(vcpu->vm)) {
/*
* Disable external interrupt exiting and irq ack
* Disable posted interrupt processing
Expand Down

0 comments on commit b038ade

Please sign in to comment.