Skip to content

Commit 49d1dc1

Browse files
wuxyintellijinxia
authored andcommitted
HV:treewide: Clean up -1U or -1UL
According to C99 standard, -1 integer constant with 'U/UL' suffix has no type. To explicit the integer constant: Update -1U or -1UL as ~0U or ~0UL, or invalid number according to usage case. V1-->V2: Update parameter name and type of send_startup_ipi since the second parameter is used as pcpu_id; Update related comments for code clearity. V2-->V3: Update comments of struct acrn_irqline; rename cpu_startup_dest as dest_pcpu_id in the second parameter of send_startup_ipi. Tracked-on: ccm0001001-247033 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent de5bb50 commit 49d1dc1

File tree

9 files changed

+18
-15
lines changed

9 files changed

+18
-15
lines changed

devicemodel/include/public/acrn_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct acrn_irqline {
206206
uint64_t pic_irq;
207207

208208
/** ioapic IRQ for IOAPIC & ISA TYPE,
209-
* if -1 then this IRQ will not be injected
209+
* if ~0UL then this IRQ will not be injected
210210
*/
211211
uint64_t ioapic_irq;
212212
} __aligned(8);

hypervisor/arch/x86/cpu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,12 @@ void start_cpus()
713713
*/
714714
expected_up = phys_cpu_num;
715715

716-
/* Broadcast IPIs to all other CPUs */
716+
/* Broadcast IPIs to all other CPUs,
717+
* In this case, INTR_CPU_STARTUP_ALL_EX_SELF decides broadcasting
718+
* IPIs, INVALID_CPU_ID is parameter value to destination pcpu_id.
719+
*/
717720
send_startup_ipi(INTR_CPU_STARTUP_ALL_EX_SELF,
718-
-1U, startup_paddr);
721+
INVALID_CPU_ID, startup_paddr);
719722

720723
/* Wait until global count is equal to expected CPU up count or
721724
* configured time-out has expired

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ vlapic_set_intr_ready(struct vlapic *vlapic, uint32_t vector, bool level)
483483
static inline int
484484
lvt_off_to_idx(uint32_t offset)
485485
{
486-
uint32_t index = -1U;
486+
uint32_t index = ~0U;
487487

488488
switch (offset) {
489489
case APIC_OFFSET_CMCI_LVT:

hypervisor/arch/x86/lapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ uint8_t get_cur_lapic_id(void)
352352

353353
int
354354
send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
355-
uint32_t cpu_startup_dest, uint64_t cpu_startup_start_address)
355+
uint16_t dest_pcpu_id, uint64_t cpu_startup_start_address)
356356
{
357357
union apic_icr icr;
358358
uint8_t shorthand;
@@ -368,7 +368,7 @@ send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
368368

369369
if (cpu_startup_shorthand == INTR_CPU_STARTUP_USE_DEST) {
370370
shorthand = INTR_LAPIC_ICR_USE_DEST_ARRAY;
371-
icr.x_bits.dest_field = per_cpu(lapic_id, cpu_startup_dest);
371+
icr.x_bits.dest_field = per_cpu(lapic_id, dest_pcpu_id);
372372
} else { /* Use destination shorthand */
373373
shorthand = INTR_LAPIC_ICR_ALL_EX_SELF;
374374
icr.value_32.hi_32 = 0;

hypervisor/arch/x86/vmx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,10 +1280,10 @@ static void init_exec_ctrl(struct vcpu *vcpu)
12801280
* that support the 1-setting of the "virtual-interrupt
12811281
* delivery" VM-execution control
12821282
*/
1283-
exec_vmwrite64(VMX_EOI_EXIT0_FULL, -1UL);
1284-
exec_vmwrite64(VMX_EOI_EXIT1_FULL, -1UL);
1285-
exec_vmwrite64(VMX_EOI_EXIT2_FULL, -1UL);
1286-
exec_vmwrite64(VMX_EOI_EXIT3_FULL, -1UL);
1283+
exec_vmwrite64(VMX_EOI_EXIT0_FULL, ~0UL);
1284+
exec_vmwrite64(VMX_EOI_EXIT1_FULL, ~0UL);
1285+
exec_vmwrite64(VMX_EOI_EXIT2_FULL, ~0UL);
1286+
exec_vmwrite64(VMX_EOI_EXIT3_FULL, ~0UL);
12871287
}
12881288
}
12891289

hypervisor/common/hypercall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ static int handle_virt_irqline(struct vm *vm, uint64_t target_vmid,
105105
/* Call vpic for pic injection */
106106
ret = handle_vpic_irqline(target_vm, param->pic_irq, mode);
107107

108-
/* call vioapic for ioapic injection if ioapic_irq != -1*/
109-
if (param->ioapic_irq != -1UL) {
108+
/* call vioapic for ioapic injection if ioapic_irq != ~0UL*/
109+
if (param->ioapic_irq != (~0UL)) {
110110
/* handle IOAPIC irqline */
111111
ret = handle_vioapic_irqline(target_vm,
112112
param->ioapic_irq, mode);

hypervisor/include/arch/x86/lapic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int init_lapic(uint16_t cpu_id);
144144
void send_lapic_eoi(void);
145145
uint8_t get_cur_lapic_id(void);
146146
int send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
147-
uint32_t cpu_startup_dest,
147+
uint16_t dest_pcpu_id,
148148
uint64_t cpu_startup_start_address);
149149
/* API to send an IPI to a single guest */
150150
void send_single_ipi(uint16_t pcpu_id, uint32_t vector);

hypervisor/include/public/acrn_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct acrn_irqline {
186186
uint64_t pic_irq;
187187

188188
/** ioapic IRQ for IOAPIC & ISA TYPE,
189-
* if -1 then this IRQ will not be injected
189+
* if ~0UL then this IRQ will not be injected
190190
*/
191191
uint64_t ioapic_irq;
192192
} __aligned(8);

hypervisor/include/public/acrn_hv_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
#define ACRN_DOM0_VMID (0UL)
7979
#define ACRN_INVALID_VMID (-1)
80-
#define ACRN_INVALID_HPA (-1UL)
80+
#define ACRN_INVALID_HPA (~0UL)
8181

8282
/* Generic memory attributes */
8383
#define MEM_ACCESS_READ 0x00000001U

0 commit comments

Comments
 (0)