Skip to content

Commit 6e77a8d

Browse files
Xiangyang Wulijinxia
authored andcommitted
HV:treewide:rename enum vpic_wire_mode, stack_canary, segment_override, pde_index
For data structure types "enum vpic_wire_mode, struct stack_canary", its name is identical with variable name in the same scope. This MISRA C violation is detected by static analysis tool. For variables "segment_override, pde_index", its name is identical with function name. This MISRA C violation is detected. Naming convention rule:Variable name can be shortened from its data structure type name. The following udpates are made: enum vpic_wire_mode vpic_wire_mode-->enum vpic_wire_mode wire_mode struct stack_canary stack_canary-->struct stack_canary stk_canary uint8_t segment_override:1 --> uint8_t seg_override:1 uint32_t pde_index--> uint32_t pde_idx V1-->V2: Remove update "enum cpu_state cpu_state-->enum cpu_state state" and "enum irqstate irqstate-->enum irq_ops_mode ops_mode", other patch will cover it. V2-->V3: Update "uint32_t pde_index--> uint32_t pde_idx". Signed-off-by: Xiangyang Wu <xiangyang.wu@linux.intel.com>
1 parent 52fe9f4 commit 6e77a8d

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static uint64_t get_random_value(void)
330330

331331
static void set_fs_base(void)
332332
{
333-
struct stack_canary *psc = &get_cpu_var(stack_canary);
333+
struct stack_canary *psc = &get_cpu_var(stk_canary);
334334

335335
psc->canary = get_random_value();
336336
msr_write(MSR_IA32_FS_BASE, (uint64_t)psc);

hypervisor/arch/x86/ept.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void free_ept_mem(void *pml4_addr)
5050
void *pte_addr;
5151
uint32_t pml4_index;
5252
uint32_t pdpt_index;
53-
uint32_t pde_index;
53+
uint32_t pde_idx;
5454

5555
if (pml4_addr == NULL) {
5656
ASSERT(false, "EPTP is NULL");
@@ -74,10 +74,10 @@ static void free_ept_mem(void *pml4_addr)
7474
continue;
7575
}
7676

77-
for (pde_index = 0U; pde_index < IA32E_NUM_ENTRIES;
78-
pde_index++) {
77+
for (pde_idx = 0U; pde_idx < IA32E_NUM_ENTRIES;
78+
pde_idx++) {
7979
/* Walk from the PD table to the page table */
80-
pte_addr = HPA2HVA(find_next_table(pde_index,
80+
pte_addr = HPA2HVA(find_next_table(pde_idx,
8181
pde_addr));
8282

8383
/* Free page table entry table */

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ emulate_movs(struct vcpu *vcpu, __unused uint64_t gpa, struct instr_emul_vie *vi
714714
}
715715
}
716716

717-
seg = (vie->segment_override != 0U) ? (vie->segment_register) : CPU_REG_DS;
717+
seg = (vie->seg_override != 0U) ? (vie->segment_register) : CPU_REG_DS;
718718
error = get_gla(vcpu, vie, paging, opsize, vie->addrsize,
719719
PROT_READ, seg, CPU_REG_RSI, &srcaddr, &fault);
720720
if ((error != 0) || (fault != 0)) {
@@ -1791,7 +1791,7 @@ decode_prefixes(struct instr_emul_vie *vie, enum vm_cpu_mode cpu_mode, bool cs_d
17911791
} else if (x == 0xF2U) {
17921792
vie->repnz_present = 1U;
17931793
} else if (segment_override(x, &vie->segment_register)) {
1794-
vie->segment_override = 1U;
1794+
vie->seg_override = 1U;
17951795
} else {
17961796
break;
17971797
}

hypervisor/arch/x86/guest/instr_emul_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct instr_emul_vie {
163163
repnz_present:1, /* REPNE/REPNZ prefix */
164164
opsize_override:1, /* Operand size override */
165165
addrsize_override:1, /* Address size override */
166-
segment_override:1; /* Segment override */
166+
seg_override:1; /* Segment override */
167167

168168
uint8_t mod:2, /* ModRM byte */
169169
reg:4,

hypervisor/arch/x86/guest/vioapic.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ vioapic_write(struct vioapic *vioapic, uint32_t addr, uint32_t data)
347347
/* mask -> umask */
348348
if ((last.full & IOAPIC_RTE_INTMASK) != 0UL &&
349349
((new.full & IOAPIC_RTE_INTMASK) == 0UL)) {
350-
if ((vioapic->vm->vpic_wire_mode ==
350+
if ((vioapic->vm->wire_mode ==
351351
VPIC_WIRE_NULL) ||
352-
(vioapic->vm->vpic_wire_mode ==
352+
(vioapic->vm->wire_mode ==
353353
VPIC_WIRE_INTR)) {
354-
vioapic->vm->vpic_wire_mode =
354+
vioapic->vm->wire_mode =
355355
VPIC_WIRE_IOAPIC;
356356
dev_dbg(ACRN_DBG_IOAPIC,
357357
"vpic wire mode -> IOAPIC");
@@ -362,9 +362,9 @@ vioapic_write(struct vioapic *vioapic, uint32_t addr, uint32_t data)
362362
/* unmask -> mask */
363363
} else if (((last.full & IOAPIC_RTE_INTMASK) == 0UL) &&
364364
(new.full & IOAPIC_RTE_INTMASK) != 0UL) {
365-
if (vioapic->vm->vpic_wire_mode ==
365+
if (vioapic->vm->wire_mode ==
366366
VPIC_WIRE_IOAPIC) {
367-
vioapic->vm->vpic_wire_mode =
367+
vioapic->vm->wire_mode =
368368
VPIC_WIRE_INTR;
369369
dev_dbg(ACRN_DBG_IOAPIC,
370370
"vpic wire mode -> INTR");

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ vlapic_lvt_write_handler(struct acrn_vlapic *vlapic, uint32_t offset)
611611

612612
/* mask -> unmask: may from every vlapic in the vm */
613613
if (((last & APIC_LVT_M) != 0U) && ((val & APIC_LVT_M) == 0U)) {
614-
if (vlapic->vm->vpic_wire_mode == VPIC_WIRE_INTR ||
615-
vlapic->vm->vpic_wire_mode == VPIC_WIRE_NULL) {
616-
vlapic->vm->vpic_wire_mode = VPIC_WIRE_LAPIC;
614+
if (vlapic->vm->wire_mode == VPIC_WIRE_INTR ||
615+
vlapic->vm->wire_mode == VPIC_WIRE_NULL) {
616+
vlapic->vm->wire_mode = VPIC_WIRE_LAPIC;
617617
dev_dbg(ACRN_DBG_LAPIC,
618618
"vpic wire mode -> LAPIC");
619619
} else {
@@ -622,8 +622,8 @@ vlapic_lvt_write_handler(struct acrn_vlapic *vlapic, uint32_t offset)
622622
}
623623
/* unmask -> mask: only from the vlapic LINT0-ExtINT enabled */
624624
} else if (((last & APIC_LVT_M) == 0U) && ((val & APIC_LVT_M) != 0U)) {
625-
if (vlapic->vm->vpic_wire_mode == VPIC_WIRE_LAPIC) {
626-
vlapic->vm->vpic_wire_mode = VPIC_WIRE_NULL;
625+
if (vlapic->vm->wire_mode == VPIC_WIRE_LAPIC) {
626+
vlapic->vm->wire_mode = VPIC_WIRE_NULL;
627627
dev_dbg(ACRN_DBG_LAPIC,
628628
"vpic wire mode -> NULL");
629629
}
@@ -1279,8 +1279,8 @@ vlapic_svr_write_handler(struct acrn_vlapic *vlapic)
12791279

12801280
vlapic_mask_lvts(vlapic);
12811281
/* the only one enabled LINT0-ExtINT vlapic disabled */
1282-
if (vlapic->vm->vpic_wire_mode == VPIC_WIRE_NULL) {
1283-
vlapic->vm->vpic_wire_mode = VPIC_WIRE_INTR;
1282+
if (vlapic->vm->wire_mode == VPIC_WIRE_NULL) {
1283+
vlapic->vm->wire_mode = VPIC_WIRE_INTR;
12841284
dev_dbg(ACRN_DBG_LAPIC,
12851285
"vpic wire mode -> INTR");
12861286
}

hypervisor/arch/x86/guest/vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
177177
vm->vpic = vpic_init(vm);
178178

179179
/* vpic wire_mode default is INTR */
180-
vm->vpic_wire_mode = VPIC_WIRE_INTR;
180+
vm->wire_mode = VPIC_WIRE_INTR;
181181

182182
/* Allocate full emulated vIOAPIC instance */
183183
vm->arch_vm.virt_ioapic = vioapic_init(vm);

hypervisor/arch/x86/guest/vpic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void vpic_notify_intr(struct acrn_vpic *vpic)
231231
* interrupt.
232232
*/
233233
i8259->intr_raised = true;
234-
if (vpic->vm->vpic_wire_mode == VPIC_WIRE_INTR) {
234+
if (vpic->vm->wire_mode == VPIC_WIRE_INTR) {
235235
struct vcpu *vcpu = vcpu_from_vid(vpic->vm, 0U);
236236

237237
ASSERT(vcpu != NULL, "vm%d, vcpu0", vpic->vm->attr.id);

hypervisor/arch/x86/pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uint8_t host_enter_s3_success = 1U;
1313
void restore_msrs(void)
1414
{
1515
#ifdef STACK_PROTECTOR
16-
struct stack_canary *psc = &get_cpu_var(stack_canary);
16+
struct stack_canary *psc = &get_cpu_var(stk_canary);
1717

1818
msr_write(MSR_IA32_FS_BASE, (uint64_t)psc);
1919
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct vm {
134134
enum vm_state state; /* VM state */
135135
void *vuart; /* Virtual UART */
136136
struct acrn_vpic *vpic; /* Virtual PIC */
137-
enum vpic_wire_mode vpic_wire_mode;
137+
enum vpic_wire_mode wire_mode;
138138
struct iommu_domain *iommu; /* iommu domain of this VM */
139139
struct list_head list; /* list of VM */
140140
spinlock_t spinlock; /* Spin-lock used to protect VM modifications */

0 commit comments

Comments
 (0)