Skip to content

Commit e1564ed

Browse files
shiqinggwenlingz
authored andcommitted
hv: fix type conversion violations
This patch fixes the following violations: 1. Implicit conversion: actual to formal param 2. Value is not of appropriate type 3. No cast for widening complex int expression 4. Widening cast on complex integer expression 5. Narrower int conversion without cast. Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
1 parent a0582c9 commit e1564ed

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ set_expiration(struct acrn_vlapic *vlapic)
317317
if ((tmicr == 0U) || (divisor_shift > 8U)) {
318318
ret = false;
319319
} else {
320-
delta = tmicr << divisor_shift;
320+
delta = (uint64_t)tmicr << divisor_shift;
321321
timer = &vtimer->timer;
322322

323323
if (vlapic_lvtt_period(vlapic)) {
@@ -1163,7 +1163,7 @@ vlapic_get_cr8(const struct acrn_vlapic *vlapic)
11631163
uint32_t tpr;
11641164

11651165
tpr = vlapic_get_tpr(vlapic);
1166-
return (uint64_t)(tpr >> 4U);
1166+
return ((uint64_t)tpr >> 4UL);
11671167
}
11681168

11691169
static void

hypervisor/arch/x86/ioapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ create_rte_for_gsi_irq(uint32_t irq, uint32_t vr)
189189
rte.full |= IOAPIC_RTE_INTAHI;
190190

191191
/* Dest field */
192-
rte.full |= ((uint64_t)ALL_CPUS_MASK << IOAPIC_RTE_DEST_SHIFT);
192+
rte.full |= (ALL_CPUS_MASK << IOAPIC_RTE_DEST_SHIFT);
193193
}
194194

195195
return rte;

hypervisor/arch/x86/trusty.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void create_secure_world_ept(struct acrn_vm *vm, uint64_t gpa_orig,
109109
*/
110110
dest_pdpte_p = pml4e_page_vaddr(sworld_pml4e);
111111
src_pdpte_p = pml4e_page_vaddr(nworld_pml4e);
112-
for (i = 0U; i < (PTRS_PER_PDPTE - 1UL); i++) {
112+
for (i = 0U; i < (uint16_t)(PTRS_PER_PDPTE - 1UL); i++) {
113113
pdpte = get_pgentry(src_pdpte_p);
114114
if ((pdpte & table_present) != 0UL) {
115115
pdpte &= ~EPT_EXE;
@@ -141,7 +141,7 @@ void destroy_secure_world(struct acrn_vm *vm, bool need_clr_mem)
141141

142142
if (need_clr_mem) {
143143
/* clear trusty memory space */
144-
(void)memset(hpa2hva(hpa), 0U, size);
144+
(void)memset(hpa2hva(hpa), 0U, (size_t)size);
145145
}
146146

147147
ept_mr_del(vm, vm->arch_vm.sworld_eptp, gpa_uos, size);
@@ -335,7 +335,7 @@ static bool derive_aek(uint8_t *attkb_key)
335335
max_svn_idx = get_max_svn_index();
336336
ikm = g_key_info.dseed_list[max_svn_idx].seed;
337337
/* only the low 32 bits of seed are valid */
338-
ikm_len = 32;
338+
ikm_len = 32U;
339339

340340
if (hmac_sha256(attkb_key, ikm, ikm_len,
341341
(const uint8_t *)salt, sizeof(salt)) != 1) {

hypervisor/arch/x86/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ static void init_exec_ctrl(struct acrn_vcpu *vcpu)
924924
value64 = hva2hpa(vm->arch_vm.io_bitmap);
925925
exec_vmwrite64(VMX_IO_BITMAP_A_FULL, value64);
926926
pr_dbg("VMX_IO_BITMAP_A: 0x%016llx ", value64);
927-
value64 = hva2hpa(&(vm->arch_vm.io_bitmap[CPU_PAGE_SIZE]));
927+
value64 = hva2hpa((void *)&(vm->arch_vm.io_bitmap[CPU_PAGE_SIZE]));
928928
exec_vmwrite64(VMX_IO_BITMAP_B_FULL, value64);
929929
pr_dbg("VMX_IO_BITMAP_B: 0x%016llx ", value64);
930930

hypervisor/boot/sbl/sbl_seed_parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static void parse_seed_list_sbl(struct seed_list_hob *seed_hob)
9494
dseed_index++;
9595

9696
/* erase original seed in seed entry */
97-
(void)memset(entry->seed, 0U, sizeof(struct seed_info));
97+
(void)memset((void *)entry->seed, 0U, sizeof(struct seed_info));
9898
}
9999

100100
entry = (struct seed_entry *)((uint8_t *)entry +

hypervisor/dm/hw/pci.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ void enable_disable_pci_intx(union pci_bdf bdf, bool enable)
123123
void pci_scan_bus(pci_enumeration_cb cb_func, void *cb_data)
124124
{
125125
union pci_bdf pbdf;
126-
uint8_t hdr_type, secondary_bus;
127-
uint32_t bus, dev, func, val;
126+
uint8_t hdr_type, secondary_bus, dev, func;
127+
uint32_t bus, val;
128128
uint8_t bus_to_scan[PCI_BUSMAX + 1] = { BUS_SCAN_SKIP };
129129

130130
/* start from bus 0 */
@@ -136,7 +136,7 @@ void pci_scan_bus(pci_enumeration_cb cb_func, void *cb_data)
136136
}
137137

138138
bus_to_scan[bus] = BUS_SCAN_COMPLETE;
139-
pbdf.bits.b = bus;
139+
pbdf.bits.b = (uint8_t)bus;
140140

141141
for (dev = 0U; dev <= PCI_SLOTMAX; dev++) {
142142
pbdf.bits.d = dev;

hypervisor/include/arch/x86/irq.h

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

5151
#define DEFAULT_DEST_MODE IOAPIC_RTE_DESTLOG
5252
#define DEFAULT_DELIVERY_MODE IOAPIC_RTE_DELLOPRI
53-
#define ALL_CPUS_MASK ((1U << phys_cpu_num) - 1U)
53+
#define ALL_CPUS_MASK ((1UL << (uint64_t)phys_cpu_num) - 1UL)
5454

5555
#define IRQ_ALLOC_BITMAP_SIZE INT_DIV_ROUNDUP(NR_IRQS, 64U)
5656

hypervisor/include/arch/x86/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PAGE_H
99

1010
#define PAGE_SHIFT 12U
11-
#define PAGE_SIZE (1UL << PAGE_SHIFT)
11+
#define PAGE_SIZE (1U << PAGE_SHIFT)
1212

1313
/* size of the low MMIO address space: 2GB */
1414
#define PLATFORM_LO_MMIO_SIZE 0x80000000UL

hypervisor/include/arch/x86/vtd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static inline uint8_t iommu_ecap_pds(uint64_t ecap)
291291
#define DMA_CCMD_DEVICE_INVL (3UL << 61U)
292292
static inline uint64_t dma_ccmd_fm(uint8_t fm)
293293
{
294-
return (((uint64_t)(fm & 0x3U)) << 32U);
294+
return (((uint64_t)fm & 0x3UL) << 32UL);
295295
}
296296

297297
#define DMA_CCMD_MASK_NOBIT 0UL
@@ -300,7 +300,7 @@ static inline uint64_t dma_ccmd_fm(uint8_t fm)
300300
#define DMA_CCMD_MASK_3BIT 3UL
301301
static inline uint64_t dma_ccmd_sid(uint16_t sid)
302302
{
303-
return (((uint64_t)(sid & 0xffffU)) << 16U);
303+
return (((uint64_t)sid & 0xffffUL) << 16UL);
304304
}
305305

306306
static inline uint16_t dma_ccmd_did(uint16_t did)
@@ -324,7 +324,7 @@ static inline uint8_t dma_ccmd_get_caig_32(uint32_t gaig)
324324
#define DMA_IOTLB_DW (((uint64_t)1UL) << 48U)
325325
static inline uint64_t dma_iotlb_did(uint16_t did)
326326
{
327-
return (((uint64_t)(did & 0xffffU)) << 32U);
327+
return (((uint64_t)did & 0xffffUL) << 32UL);
328328
}
329329

330330
static inline uint8_t dma_iotlb_get_iaig_32(uint32_t iai)

0 commit comments

Comments
 (0)