Skip to content

Commit 3702659

Browse files
rarindamlijinxia
authored andcommitted
HV: Rename functions, variables starting with "_"
In order to comply with MISRA C rules, renamed vairables and function names starting with "_". The major changes invloves mostly static function names, as they are being called inside the same file by a wrapper function. Signed-off-by: Arindam Roy <arindam.roy@intel.com>
1 parent a71dede commit 3702659

File tree

14 files changed

+51
-51
lines changed

14 files changed

+51
-51
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ is_entry_active(struct ptdev_remapping_info *entry)
5656

5757
/* require ptdev_lock protect */
5858
static inline struct ptdev_remapping_info *
59-
_lookup_entry_by_id(uint32_t id)
59+
local_lookup_entry_by_id(uint32_t id)
6060
{
6161
struct ptdev_remapping_info *entry;
6262
struct list_head *pos;
@@ -74,7 +74,7 @@ _lookup_entry_by_id(uint32_t id)
7474

7575
/* require ptdev_lock protect */
7676
static inline struct ptdev_remapping_info *
77-
_lookup_entry_by_vmsi(struct vm *vm, uint16_t vbdf, uint32_t index)
77+
local_lookup_entry_by_vmsi(struct vm *vm, uint16_t vbdf, uint32_t index)
7878
{
7979
struct ptdev_remapping_info *entry;
8080
struct list_head *pos;
@@ -100,14 +100,14 @@ lookup_entry_by_vmsi(struct vm *vm, uint16_t vbdf, uint32_t index)
100100
struct ptdev_remapping_info *entry;
101101

102102
spinlock_obtain(&ptdev_lock);
103-
entry = _lookup_entry_by_vmsi(vm, vbdf, index);
103+
entry = local_lookup_entry_by_vmsi(vm, vbdf, index);
104104
spinlock_release(&ptdev_lock);
105105
return entry;
106106
}
107107

108108
/* require ptdev_lock protect */
109109
static inline struct ptdev_remapping_info *
110-
_lookup_entry_by_vintx(struct vm *vm, uint8_t vpin,
110+
local_lookup_entry_by_vintx(struct vm *vm, uint8_t vpin,
111111
enum ptdev_vpin_source vpin_src)
112112
{
113113
struct ptdev_remapping_info *entry;
@@ -134,7 +134,7 @@ lookup_entry_by_vintx(struct vm *vm, uint8_t vpin,
134134
struct ptdev_remapping_info *entry;
135135

136136
spinlock_obtain(&ptdev_lock);
137-
entry = _lookup_entry_by_vintx(vm, vpin, vpin_src);
137+
entry = local_lookup_entry_by_vintx(vm, vpin, vpin_src);
138138
spinlock_release(&ptdev_lock);
139139
return entry;
140140
}
@@ -307,10 +307,10 @@ add_msix_remapping(struct vm *vm, uint16_t virt_bdf, uint16_t phys_bdf,
307307
struct ptdev_remapping_info *entry;
308308

309309
spinlock_obtain(&ptdev_lock);
310-
entry = _lookup_entry_by_id(
310+
entry = local_lookup_entry_by_id(
311311
entry_id_from_msix(phys_bdf, msix_entry_index));
312312
if (entry == NULL) {
313-
if (_lookup_entry_by_vmsi(vm, virt_bdf, msix_entry_index) != NULL) {
313+
if (local_lookup_entry_by_vmsi(vm, virt_bdf, msix_entry_index) != NULL) {
314314
pr_err("MSIX re-add vbdf%x", virt_bdf);
315315

316316
spinlock_release(&ptdev_lock);
@@ -357,7 +357,7 @@ remove_msix_remapping(struct vm *vm, uint16_t virt_bdf, uint32_t msix_entry_inde
357357
struct ptdev_remapping_info *entry;
358358

359359
spinlock_obtain(&ptdev_lock);
360-
entry = _lookup_entry_by_vmsi(vm, virt_bdf, msix_entry_index);
360+
entry = local_lookup_entry_by_vmsi(vm, virt_bdf, msix_entry_index);
361361
if (entry == NULL) {
362362
goto END;
363363
}
@@ -393,9 +393,9 @@ add_intx_remapping(struct vm *vm, uint8_t virt_pin,
393393
pic_pin ? PTDEV_VPIN_PIC : PTDEV_VPIN_IOAPIC;
394394

395395
spinlock_obtain(&ptdev_lock);
396-
entry = _lookup_entry_by_id(entry_id_from_intx(phys_pin));
396+
entry = local_lookup_entry_by_id(entry_id_from_intx(phys_pin));
397397
if (entry == NULL) {
398-
if (_lookup_entry_by_vintx(vm, virt_pin, vpin_src) != NULL) {
398+
if (local_lookup_entry_by_vintx(vm, virt_pin, vpin_src) != NULL) {
399399
pr_err("INTX re-add vpin %d", virt_pin);
400400
spinlock_release(&ptdev_lock);
401401
return &invalid_entry;
@@ -445,7 +445,7 @@ static void remove_intx_remapping(struct vm *vm, uint8_t virt_pin, bool pic_pin)
445445
pic_pin ? PTDEV_VPIN_PIC : PTDEV_VPIN_IOAPIC;
446446

447447
spinlock_obtain(&ptdev_lock);
448-
entry = _lookup_entry_by_vintx(vm, virt_pin, vpin_src);
448+
entry = local_lookup_entry_by_vintx(vm, virt_pin, vpin_src);
449449
if (entry == NULL) {
450450
goto END;
451451
}

hypervisor/arch/x86/ept.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void destroy_ept(struct vm *vm)
116116
}
117117
}
118118

119-
uint64_t _gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size)
119+
uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size)
120120
{
121121
uint64_t hpa = 0UL;
122122
uint64_t *pgentry, pg_size = 0UL;
@@ -142,7 +142,7 @@ uint64_t _gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size)
142142
/* using return value 0 as failure, make sure guest will not use hpa 0 */
143143
uint64_t gpa2hpa(struct vm *vm, uint64_t gpa)
144144
{
145-
return _gpa2hpa(vm, gpa, NULL);
145+
return local_gpa2hpa(vm, gpa, NULL);
146146
}
147147

148148
uint64_t hpa2gpa(struct vm *vm, uint64_t hpa)

hypervisor/arch/x86/guest/guest.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ enum vm_paging_mode get_vcpu_paging_mode(struct vcpu *vcpu)
134134

135135
/* TODO: Add code to check for Revserved bits, SMAP and PKE when do translation
136136
* during page walk */
137-
static int _gva2gpa_common(struct vcpu *vcpu, struct page_walk_info *pw_info,
137+
static int local_gva2gpa_common(struct vcpu *vcpu, struct page_walk_info *pw_info,
138138
uint64_t gva, uint64_t *gpa, uint32_t *err_code)
139139
{
140140
uint32_t i;
@@ -220,7 +220,7 @@ static int _gva2gpa_common(struct vcpu *vcpu, struct page_walk_info *pw_info,
220220
return ret;
221221
}
222222

223-
static int _gva2gpa_pae(struct vcpu *vcpu, struct page_walk_info *pw_info,
223+
static int local_gva2gpa_pae(struct vcpu *vcpu, struct page_walk_info *pw_info,
224224
uint64_t gva, uint64_t *gpa, uint32_t *err_code)
225225
{
226226
int index;
@@ -246,7 +246,7 @@ static int _gva2gpa_pae(struct vcpu *vcpu, struct page_walk_info *pw_info,
246246

247247
pw_info->level = 2U;
248248
pw_info->top_entry = entry;
249-
ret = _gva2gpa_common(vcpu, pw_info, gva, gpa, err_code);
249+
ret = local_gva2gpa_common(vcpu, pw_info, gva, gpa, err_code);
250250

251251
out:
252252
return ret;
@@ -298,15 +298,15 @@ int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa,
298298

299299
if (pm == PAGING_MODE_4_LEVEL) {
300300
pw_info.width = 9U;
301-
ret = _gva2gpa_common(vcpu, &pw_info, gva, gpa, err_code);
301+
ret = local_gva2gpa_common(vcpu, &pw_info, gva, gpa, err_code);
302302
} else if(pm == PAGING_MODE_3_LEVEL) {
303303
pw_info.width = 9U;
304-
ret = _gva2gpa_pae(vcpu, &pw_info, gva, gpa, err_code);
304+
ret = local_gva2gpa_pae(vcpu, &pw_info, gva, gpa, err_code);
305305
} else if (pm == PAGING_MODE_2_LEVEL) {
306306
pw_info.width = 10U;
307307
pw_info.pse = ((cur_context->cr4 & CR4_PSE) != 0UL);
308308
pw_info.nxe = false;
309-
ret = _gva2gpa_common(vcpu, &pw_info, gva, gpa, err_code);
309+
ret = local_gva2gpa_common(vcpu, &pw_info, gva, gpa, err_code);
310310
} else {
311311
*gpa = gva;
312312
}
@@ -320,14 +320,14 @@ int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa,
320320
return ret;
321321
}
322322

323-
static inline uint32_t _copy_gpa(struct vm *vm, void *h_ptr, uint64_t gpa,
323+
static inline uint32_t local_copy_gpa(struct vm *vm, void *h_ptr, uint64_t gpa,
324324
uint32_t size, uint32_t fix_pg_size, bool cp_from_vm)
325325
{
326326
uint64_t hpa;
327327
uint32_t offset_in_pg, len, pg_size;
328328
void *g_ptr;
329329

330-
hpa = _gpa2hpa(vm, gpa, &pg_size);
330+
hpa = local_gpa2hpa(vm, gpa, &pg_size);
331331
if (pg_size == 0U) {
332332
pr_err("GPA2HPA not found");
333333
return 0;
@@ -366,7 +366,7 @@ static inline int copy_gpa(struct vm *vm, void *h_ptr_arg, uint64_t gpa_arg,
366366
}
367367

368368
while (size > 0U) {
369-
len = _copy_gpa(vm, h_ptr, gpa, size, 0U, cp_from_vm);
369+
len = local_copy_gpa(vm, h_ptr, gpa, size, 0U, cp_from_vm);
370370
if (len == 0U) {
371371
return -EINVAL;
372372
}
@@ -406,7 +406,7 @@ static inline int copy_gva(struct vcpu *vcpu, void *h_ptr_arg, uint64_t gva_arg,
406406
return ret;
407407
}
408408

409-
len = _copy_gpa(vcpu->vm, h_ptr, gpa, size,
409+
len = local_copy_gpa(vcpu->vm, h_ptr, gpa, size,
410410
PAGE_SIZE_4K, cp_from_vm);
411411

412412
if (len == 0U) {

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ decode_moffset(struct instr_emul_vie *vie)
21512151
}
21522152

21532153
int
2154-
__decode_instruction(enum vm_cpu_mode cpu_mode, bool cs_d, struct instr_emul_vie *vie)
2154+
local_decode_instruction(enum vm_cpu_mode cpu_mode, bool cs_d, struct instr_emul_vie *vie)
21552155
{
21562156
if (decode_prefixes(vie, cpu_mode, cs_d) != 0) {
21572157
return -1;

hypervisor/arch/x86/guest/instr_emul.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int vie_init(struct instr_emul_vie *vie, struct vcpu *vcpu);
8989
*/
9090
#define VIE_INVALID_GLA (1UL << 63) /* a non-canonical address */
9191
int
92-
__decode_instruction(enum vm_cpu_mode cpu_mode, bool cs_d, struct instr_emul_vie *vie);
92+
local_decode_instruction(enum vm_cpu_mode cpu_mode, bool cs_d, struct instr_emul_vie *vie);
9393

9494
int emulate_instruction(struct vcpu *vcpu);
9595
int decode_instruction(struct vcpu *vcpu);

hypervisor/arch/x86/guest/instr_emul_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ int decode_instruction(struct vcpu *vcpu)
358358
get_guest_paging_info(vcpu, emul_ctxt, csar);
359359
cpu_mode = get_vcpu_mode(vcpu);
360360

361-
retval = __decode_instruction(cpu_mode, SEG_DESC_DEF32(csar),
361+
retval = local_decode_instruction(cpu_mode, SEG_DESC_DEF32(csar),
362362
&emul_ctxt->vie);
363363

364364
if (retval != 0) {

hypervisor/arch/x86/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static uint32_t alloc_irq(void)
104104
}
105105

106106
/* need irq_lock protection before use */
107-
static void _irq_desc_set_vector(uint32_t irq, uint32_t vr)
107+
static void local_irq_desc_set_vector(uint32_t irq, uint32_t vr)
108108
{
109109
struct irq_desc *desc;
110110

@@ -321,7 +321,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri)
321321
pr_err("no vector found for irq[%d]", irq);
322322
goto OUT;
323323
}
324-
_irq_desc_set_vector(irq, vr);
324+
local_irq_desc_set_vector(irq, vr);
325325
OUT:
326326
spinlock_irqrestore_release(&desc->irq_lock);
327327
return vr;

hypervisor/arch/x86/mmu.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct invept_desc {
6262
uint64_t _res;
6363
};
6464

65-
static inline void _invvpid(uint64_t type, uint16_t vpid, uint64_t gva)
65+
static inline void local_invvpid(uint64_t type, uint16_t vpid, uint64_t gva)
6666
{
6767
int error = 0;
6868

@@ -82,7 +82,7 @@ static inline void _invvpid(uint64_t type, uint16_t vpid, uint64_t gva)
8282
ASSERT(error == 0, "invvpid error");
8383
}
8484

85-
static inline void _invept(uint64_t type, struct invept_desc desc)
85+
static inline void local_invept(uint64_t type, struct invept_desc desc)
8686
{
8787
int error = 0;
8888

@@ -159,12 +159,12 @@ void flush_vpid_single(uint16_t vpid)
159159
return;
160160
}
161161

162-
_invvpid(VMX_VPID_TYPE_SINGLE_CONTEXT, vpid, 0UL);
162+
local_invvpid(VMX_VPID_TYPE_SINGLE_CONTEXT, vpid, 0UL);
163163
}
164164

165165
void flush_vpid_global(void)
166166
{
167-
_invvpid(VMX_VPID_TYPE_ALL_CONTEXT, 0U, 0UL);
167+
local_invvpid(VMX_VPID_TYPE_ALL_CONTEXT, 0U, 0UL);
168168
}
169169

170170
void invept(struct vcpu *vcpu)
@@ -174,15 +174,15 @@ void invept(struct vcpu *vcpu)
174174
if (cpu_has_vmx_ept_cap(VMX_EPT_INVEPT_SINGLE_CONTEXT)) {
175175
desc.eptp = HVA2HPA(vcpu->vm->arch_vm.nworld_eptp) |
176176
(3UL << 3U) | 6UL;
177-
_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
177+
local_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
178178
if (vcpu->vm->sworld_control.sworld_enabled &&
179179
vcpu->vm->arch_vm.sworld_eptp != NULL) {
180180
desc.eptp = HVA2HPA(vcpu->vm->arch_vm.sworld_eptp)
181181
| (3UL << 3U) | 6UL;
182-
_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
182+
local_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
183183
}
184184
} else if (cpu_has_vmx_ept_cap(VMX_EPT_INVEPT_GLOBAL_CONTEXT)) {
185-
_invept(INVEPT_TYPE_ALL_CONTEXTS, desc);
185+
local_invept(INVEPT_TYPE_ALL_CONTEXTS, desc);
186186
} else {
187187
/* Neither type of INVEPT is supported. Skip. */
188188
}

hypervisor/arch/x86/timer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static inline void update_physical_timer(struct per_cpu_timers *cpu_timer)
4545
}
4646
}
4747

48-
static void __add_timer(struct per_cpu_timers *cpu_timer,
48+
static void local_add_timer(struct per_cpu_timers *cpu_timer,
4949
struct hv_timer *timer,
5050
bool *need_update)
5151
{
@@ -90,7 +90,7 @@ int add_timer(struct hv_timer *timer)
9090

9191
pcpu_id = get_cpu_id();
9292
cpu_timer = &per_cpu(cpu_timers, pcpu_id);
93-
__add_timer(cpu_timer, timer, &need_update);
93+
local_add_timer(cpu_timer, timer, &need_update);
9494

9595
if (need_update) {
9696
update_physical_timer(cpu_timer);
@@ -165,7 +165,7 @@ static void timer_softirq(uint16_t pcpu_id)
165165

166166
/* This is to make sure we are not blocked due to delay inside func()
167167
* force to exit irq handler after we serviced >31 timers
168-
* caller used to __add_timer() for periodic timer, if there is a delay
168+
* caller used to local_add_timer() for periodic timer, if there is a delay
169169
* inside func(), it will infinitely loop here, because new added timer
170170
* already passed due to previously func()'s delay.
171171
*/
@@ -181,7 +181,7 @@ static void timer_softirq(uint16_t pcpu_id)
181181
if (timer->mode == TICK_MODE_PERIODIC) {
182182
/* update periodic timer fire tsc */
183183
timer->fire_tsc += timer->period_in_cycle;
184-
__add_timer(cpu_timer, timer, NULL);
184+
local_add_timer(cpu_timer, timer, NULL);
185185
}
186186
} else {
187187
break;

hypervisor/boot/acpi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static void *get_acpi_tbl(const char *sig)
221221
return HPA2HVA(addr);
222222
}
223223

224-
static uint16_t _parse_madt(void *madt, uint8_t lapic_id_array[MAX_PCPU_NUM])
224+
static uint16_t local_parse_madt(void *madt, uint8_t lapic_id_array[MAX_PCPU_NUM])
225225
{
226226
uint16_t pcpu_id = 0;
227227
struct acpi_madt_local_apic *processor;
@@ -274,7 +274,7 @@ uint16_t parse_madt(uint8_t lapic_id_array[MAX_PCPU_NUM])
274274
madt = get_acpi_tbl(ACPI_SIG_MADT);
275275
ASSERT(madt != NULL, "fail to get madt");
276276

277-
return _parse_madt(madt, lapic_id_array);
277+
return local_parse_madt(madt, lapic_id_array);
278278
}
279279

280280
void *get_dmar_table(void)

0 commit comments

Comments
 (0)