Skip to content

Commit 8787c06

Browse files
shiqingglijinxia
authored andcommitted
hv: arch: fix 'Unused procedure parameter'
MISRA-C requires that there should be no unused parameters in functions. In some cases, we will keep the unused parameters. vmexit handler is one example. It is used as function pointer. Some of the vmexit handlers use the input parameter 'vcpu', some of them don't. We still need to keep the unused parameters 'vcpu' for those handlers don't use 'vcpu'. This patch removes the unused parameters that is not being used unconditionally. v1 -> v2: * remove the non-implemented API 'vlapic_id_write_handler' Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 2908f09 commit 8787c06

File tree

17 files changed

+68
-91
lines changed

17 files changed

+68
-91
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,8 @@ int ptdev_intx_pin_remap(struct vm *vm, uint8_t virt_pin,
678678
* - currently, one phys_pin can only be held by one pin source (vPIC or
679679
* vIOAPIC)
680680
*/
681-
int ptdev_add_intx_remapping(struct vm *vm,
682-
__unused uint16_t virt_bdf, __unused uint16_t phys_bdf,
683-
uint8_t virt_pin, uint8_t phys_pin, bool pic_pin)
681+
int ptdev_add_intx_remapping(struct vm *vm, uint8_t virt_pin, uint8_t phys_pin,
682+
bool pic_pin)
684683
{
685684
struct ptdev_remapping_info *entry;
686685

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ void stop_cpus(void)
688688
}
689689
}
690690

691-
void cpu_do_idle(__unused uint16_t pcpu_id)
691+
void cpu_do_idle(void)
692692
{
693693
__asm __volatile("pause" ::: "memory");
694694
}

hypervisor/arch/x86/cpuid.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ static inline int set_vcpuid_entry(struct vm *vm,
8686
/**
8787
* initialization of virtual CPUID leaf
8888
*/
89-
static void init_vcpuid_entry(__unused struct vm *vm,
90-
uint32_t leaf, uint32_t subleaf,
89+
static void init_vcpuid_entry(uint32_t leaf, uint32_t subleaf,
9190
uint32_t flags, struct vcpuid_entry *entry)
9291
{
9392
entry->leaf = leaf;
@@ -180,7 +179,7 @@ int set_vcpuid_entries(struct vm *vm)
180179
uint32_t limit;
181180
uint32_t i, j;
182181

183-
init_vcpuid_entry(vm, 0U, 0U, 0U, &entry);
182+
init_vcpuid_entry(0U, 0U, 0U, &entry);
184183
if (boot_cpu_data.cpuid_level < 0x16U) {
185184
/* The cpuid with zero leaf returns the max level.
186185
* Emulate that the 0x16U is supported */
@@ -204,17 +203,16 @@ int set_vcpuid_entries(struct vm *vm)
204203
{
205204
uint32_t times;
206205

207-
init_vcpuid_entry(vm, i, 0U,
208-
CPUID_CHECK_SUBLEAF, &entry);
206+
init_vcpuid_entry(i, 0U, CPUID_CHECK_SUBLEAF, &entry);
209207
result = set_vcpuid_entry(vm, &entry);
210208
if (result != 0) {
211209
return result;
212210
}
213211

214212
times = entry.eax & 0xffUL;
215213
for (j = 1U; j < times; j++) {
216-
init_vcpuid_entry(vm, i, j,
217-
CPUID_CHECK_SUBLEAF, &entry);
214+
init_vcpuid_entry(i, j, CPUID_CHECK_SUBLEAF,
215+
&entry);
218216
result = set_vcpuid_entry(vm, &entry);
219217
if (result != 0) {
220218
return result;
@@ -230,8 +228,8 @@ int set_vcpuid_entries(struct vm *vm)
230228
break;
231229
}
232230

233-
init_vcpuid_entry(vm, i, j,
234-
CPUID_CHECK_SUBLEAF, &entry);
231+
init_vcpuid_entry(i, j, CPUID_CHECK_SUBLEAF,
232+
&entry);
235233
if ((i == 0x04U) && (entry.eax == 0U)) {
236234
break;
237235
}
@@ -257,7 +255,7 @@ int set_vcpuid_entries(struct vm *vm)
257255
case 0x14U:
258256
break;
259257
default:
260-
init_vcpuid_entry(vm, i, 0U, 0U, &entry);
258+
init_vcpuid_entry(i, 0U, 0U, &entry);
261259
result = set_vcpuid_entry(vm, &entry);
262260
if (result != 0) {
263261
return result;
@@ -266,19 +264,19 @@ int set_vcpuid_entries(struct vm *vm)
266264
}
267265
}
268266

269-
init_vcpuid_entry(vm, 0x40000000U, 0U, 0U, &entry);
267+
init_vcpuid_entry(0x40000000U, 0U, 0U, &entry);
270268
result = set_vcpuid_entry(vm, &entry);
271269
if (result != 0) {
272270
return result;
273271
}
274272

275-
init_vcpuid_entry(vm, 0x40000010U, 0U, 0U, &entry);
273+
init_vcpuid_entry(0x40000010U, 0U, 0U, &entry);
276274
result = set_vcpuid_entry(vm, &entry);
277275
if (result != 0) {
278276
return result;
279277
}
280278

281-
init_vcpuid_entry(vm, 0x80000000U, 0U, 0U, &entry);
279+
init_vcpuid_entry(0x80000000U, 0U, 0U, &entry);
282280
result = set_vcpuid_entry(vm, &entry);
283281
if (result != 0) {
284282
return result;
@@ -287,7 +285,7 @@ int set_vcpuid_entries(struct vm *vm)
287285
limit = entry.eax;
288286
vm->vcpuid_xlevel = limit;
289287
for (i = 0x80000001U; i <= limit; i++) {
290-
init_vcpuid_entry(vm, i, 0U, 0U, &entry);
288+
init_vcpuid_entry(i, 0U, 0U, &entry);
291289
result = set_vcpuid_entry(vm, &entry);
292290
if (result != 0) {
293291
return result;

hypervisor/arch/x86/guest/pm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ static inline uint8_t get_slp_typx(uint32_t pm1_cnt)
134134
return (uint8_t)((pm1_cnt & 0x1fffU) >> BIT_SLP_TYPx);
135135
}
136136

137-
static uint32_t pm1ab_io_read(__unused struct vm_io_handler *hdlr,
138-
__unused struct vm *vm, uint16_t addr, size_t width)
137+
static uint32_t pm1ab_io_read(__unused struct vm *vm, uint16_t addr,
138+
size_t width)
139139
{
140140
uint32_t val = pio_read(addr, width);
141141

@@ -150,9 +150,8 @@ static uint32_t pm1ab_io_read(__unused struct vm_io_handler *hdlr,
150150
return val;
151151
}
152152

153-
static void pm1ab_io_write(__unused struct vm_io_handler *hdlr,
154-
__unused struct vm *vm, uint16_t addr, size_t width,
155-
uint32_t v)
153+
static void pm1ab_io_write(__unused struct vm *vm, uint16_t addr, size_t width,
154+
uint32_t v)
156155
{
157156
static uint32_t pm1a_cnt_ready = 0U;
158157

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ vlapic_dump_isr(__unused struct acrn_vlapic *vlapic, __unused char *msg) {}
8585
static uint8_t apicv_apic_access_addr[CPU_PAGE_SIZE] __aligned(CPU_PAGE_SIZE);
8686

8787
static int
88-
apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector,
89-
__unused bool level);
88+
apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector);
9089

9190
static int
92-
apicv_pending_intr(struct acrn_vlapic *vlapic, __unused uint32_t *vecptr);
91+
apicv_pending_intr(struct acrn_vlapic *vlapic);
9392

9493
static void
9594
apicv_batch_set_tmr(struct acrn_vlapic *vlapic);
@@ -229,13 +228,6 @@ vlapic_ldr_write_handler(struct acrn_vlapic *vlapic)
229228
dev_dbg(ACRN_DBG_LAPIC, "vlapic LDR set to %#x", lapic->ldr);
230229
}
231230

232-
static void
233-
vlapic_id_write_handler(__unused struct acrn_vlapic *vlapic)
234-
{
235-
/* Force APIC ID as readonly */
236-
return;
237-
}
238-
239231
static inline uint32_t
240232
vlapic_timer_divisor_shift(uint32_t dcr)
241233
{
@@ -490,7 +482,7 @@ vlapic_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector, bool level)
490482
}
491483

492484
if (is_apicv_intr_delivery_supported()) {
493-
return apicv_set_intr_ready(vlapic, vector, level);
485+
return apicv_set_intr_ready(vlapic, vector);
494486
}
495487

496488
idx = vector >> 5U;
@@ -1239,7 +1231,7 @@ vlapic_pending_intr(struct acrn_vlapic *vlapic, uint32_t *vecptr)
12391231
struct lapic_reg *irrptr;
12401232

12411233
if (is_apicv_intr_delivery_supported()) {
1242-
return apicv_pending_intr(vlapic, vecptr);
1234+
return apicv_pending_intr(vlapic);
12431235
}
12441236

12451237
irrptr = &lapic->irr[0];
@@ -1492,7 +1484,7 @@ vlapic_write(struct acrn_vlapic *vlapic, uint32_t offset,
14921484
retval = 0;
14931485
switch (offset) {
14941486
case APIC_OFFSET_ID:
1495-
vlapic_id_write_handler(vlapic);
1487+
/* Force APIC ID as read only */
14961488
break;
14971489
case APIC_OFFSET_TPR:
14981490
vlapic_set_tpr(vlapic, data32 & 0xffU);
@@ -1995,7 +1987,7 @@ int vlapic_create(struct vcpu *vcpu)
19951987
DEFAULT_APIC_BASE, CPU_PAGE_SIZE);
19961988

19971989
ept_mr_add(vcpu->vm, pml4_page,
1998-
vlapic_apicv_get_apic_access_addr(vcpu->vm),
1990+
vlapic_apicv_get_apic_access_addr(),
19991991
DEFAULT_APIC_BASE, CPU_PAGE_SIZE,
20001992
EPT_WR | EPT_RD | EPT_UNCACHED);
20011993
}
@@ -2022,8 +2014,7 @@ void vlapic_free(struct vcpu *vcpu)
20222014
* APIC-v functions
20232015
* **/
20242016
static int
2025-
apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector,
2026-
__unused bool level)
2017+
apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector)
20272018
{
20282019
struct vlapic_pir_desc *pir_desc;
20292020
uint64_t mask;
@@ -2041,7 +2032,7 @@ apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector,
20412032
}
20422033

20432034
static int
2044-
apicv_pending_intr(struct acrn_vlapic *vlapic, __unused uint32_t *vecptr)
2035+
apicv_pending_intr(struct acrn_vlapic *vlapic)
20452036
{
20462037
struct vlapic_pir_desc *pir_desc;
20472038
struct lapic_regs *lapic;
@@ -2104,7 +2095,7 @@ apicv_batch_set_tmr(struct acrn_vlapic *vlapic)
21042095
*APIC-v: Get the HPA to APIC-access page
21052096
* **/
21062097
uint64_t
2107-
vlapic_apicv_get_apic_access_addr(__unused struct vm *vm)
2098+
vlapic_apicv_get_apic_access_addr(void)
21082099
{
21092100
return hva2hpa(apicv_apic_access_addr);
21102101
}
@@ -2278,7 +2269,7 @@ int apic_write_vmexit_handler(struct vcpu *vcpu)
22782269

22792270
switch (offset) {
22802271
case APIC_OFFSET_ID:
2281-
vlapic_id_write_handler(vlapic);
2272+
/* Force APIC ID as read only */
22822273
break;
22832274
case APIC_OFFSET_EOI:
22842275
vlapic_process_eoi(vlapic);

hypervisor/arch/x86/io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ hv_emulate_pio(struct vcpu *vcpu, struct io_request *io_req)
200200
break;
201201
} else {
202202
if (pio_req->direction == REQUEST_WRITE) {
203-
handler->desc.io_write(handler, vm, port, size,
204-
pio_req->value & mask);
203+
handler->desc.io_write(vm, port, size,
204+
pio_req->value & mask);
205205

206206
pr_dbg("IO write on port %04x, data %08x", port,
207207
pio_req->value & mask);
208208
} else {
209-
pio_req->value = handler->desc.io_read(handler,
210-
vm, port, size);
209+
pio_req->value = handler->desc.io_read(vm, port,
210+
size);
211211

212212
pr_dbg("IO read on port %04x, data %08x",
213213
port, pio_req->value);

hypervisor/arch/x86/vmx.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void exec_vmwrite16(uint32_t field, uint16_t value)
203203
exec_vmwrite64(field, (uint64_t)value);
204204
}
205205

206-
static void init_cr0_cr4_host_mask(__unused struct vcpu *vcpu)
206+
static void init_cr0_cr4_host_mask(void)
207207
{
208208
static bool inited = false;
209209
uint64_t fixed0, fixed1;
@@ -692,7 +692,7 @@ static void init_guest_state(struct vcpu *vcpu)
692692
}
693693
}
694694

695-
static void init_host_state(__unused struct vcpu *vcpu)
695+
static void init_host_state(void)
696696
{
697697
uint16_t value16;
698698
uint64_t value64;
@@ -968,7 +968,7 @@ static void init_exec_ctrl(struct vcpu *vcpu)
968968
pr_dbg("VMX_PROC_VM_EXEC_CONTROLS2: 0x%x ", value32);
969969

970970
/*APIC-v, config APIC-access address*/
971-
value64 = vlapic_apicv_get_apic_access_addr(vcpu->vm);
971+
value64 = vlapic_apicv_get_apic_access_addr();
972972
exec_vmwrite64(VMX_APIC_ACCESS_ADDR_FULL, value64);
973973

974974
/*APIC-v, config APIC virtualized page address*/
@@ -1043,7 +1043,7 @@ static void init_exec_ctrl(struct vcpu *vcpu)
10431043
/* Natural-width */
10441044
pr_dbg("Natural-width*********");
10451045

1046-
init_cr0_cr4_host_mask(vcpu);
1046+
init_cr0_cr4_host_mask();
10471047

10481048
/* The CR3 target registers work in concert with VMX_CR3_TARGET_COUNT
10491049
* field. Using these registers guest CR3 access can be managed. i.e.,
@@ -1097,7 +1097,7 @@ static void init_entry_ctrl(__unused struct vcpu *vcpu)
10971097
exec_vmwrite32(VMX_ENTRY_INSTR_LENGTH, 0U);
10981098
}
10991099

1100-
static void init_exit_ctrl(__unused struct vcpu *vcpu)
1100+
static void init_exit_ctrl(void)
11011101
{
11021102
uint32_t value32;
11031103

@@ -1156,10 +1156,10 @@ void init_vmcs(struct vcpu *vcpu)
11561156
exec_vmptrld((void *)&vmcs_pa);
11571157

11581158
/* Initialize the Virtual Machine Control Structure (VMCS) */
1159-
init_host_state(vcpu);
1159+
init_host_state();
11601160
/* init exec_ctrl needs to run before init_guest_state */
11611161
init_exec_ctrl(vcpu);
11621162
init_guest_state(vcpu);
11631163
init_entry_ctrl(vcpu);
1164-
init_exit_ctrl(vcpu);
1164+
init_exit_ctrl();
11651165
}

hypervisor/common/hypercall.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,8 @@ int32_t hcall_set_ptdev_intr_info(struct vm *vm, uint16_t vmid, uint64_t param)
783783
}
784784

785785
if (irq.type == IRQ_INTX) {
786-
ret = ptdev_add_intx_remapping(target_vm,
787-
irq.virt_bdf, irq.phys_bdf,
788-
irq.is.intx.virt_pin, irq.is.intx.phys_pin,
789-
irq.is.intx.pic_pin);
786+
ret = ptdev_add_intx_remapping(target_vm, irq.is.intx.virt_pin,
787+
irq.is.intx.phys_pin, irq.is.intx.pic_pin);
790788
} else if ((irq.type == IRQ_MSI) || (irq.type == IRQ_MSIX)) {
791789
ret = ptdev_add_msix_remapping(target_vm,
792790
irq.virt_bdf, irq.phys_bdf,

hypervisor/common/schedule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void default_idle(void)
178178
cpu_dead(pcpu_id);
179179
} else {
180180
CPU_IRQ_ENABLE();
181-
cpu_do_idle(pcpu_id);
181+
cpu_do_idle();
182182
CPU_IRQ_DISABLE();
183183
}
184184
}

hypervisor/debug/vuart.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static void vuart_toggle_intr(struct acrn_vuart *vu)
133133
}
134134
}
135135

136-
static void vuart_write(__unused struct vm_io_handler *hdlr, struct vm *vm,
137-
uint16_t offset_arg, __unused size_t width, uint32_t value)
136+
static void vuart_write(struct vm *vm, uint16_t offset_arg,
137+
__unused size_t width, uint32_t value)
138138
{
139139
uint16_t offset = offset_arg;
140140
struct acrn_vuart *vu = vm_vuart(vm);
@@ -219,8 +219,8 @@ static void vuart_write(__unused struct vm_io_handler *hdlr, struct vm *vm,
219219
vuart_unlock(vu);
220220
}
221221

222-
static uint32_t vuart_read(__unused struct vm_io_handler *hdlr, struct vm *vm,
223-
uint16_t offset_arg, __unused size_t width)
222+
static uint32_t vuart_read(struct vm *vm, uint16_t offset_arg,
223+
__unused size_t width)
224224
{
225225
uint16_t offset = offset_arg;
226226
uint8_t iir, reg, intr_reason;

0 commit comments

Comments
 (0)