Skip to content

Commit 111f972

Browse files
shiqingglijinxia
authored andcommitted
hv: fix integer violations
The operands to shift operations (<<, >>) shall be unsigned integers. Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 4c1cb60 commit 111f972

File tree

8 files changed

+38
-38
lines changed

8 files changed

+38
-38
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ static uint64_t x86_arch_capabilities;
3030

3131
/* TODO: add more capability per requirement */
3232
/* APICv features */
33-
#define VAPIC_FEATURE_VIRT_ACCESS (1U << 0)
34-
#define VAPIC_FEATURE_VIRT_REG (1U << 1)
35-
#define VAPIC_FEATURE_INTR_DELIVERY (1U << 2)
36-
#define VAPIC_FEATURE_TPR_SHADOW (1U << 3)
37-
#define VAPIC_FEATURE_POST_INTR (1U << 4)
38-
#define VAPIC_FEATURE_VX2APIC_MODE (1U << 5)
33+
#define VAPIC_FEATURE_VIRT_ACCESS (1U << 0U)
34+
#define VAPIC_FEATURE_VIRT_REG (1U << 1U)
35+
#define VAPIC_FEATURE_INTR_DELIVERY (1U << 2U)
36+
#define VAPIC_FEATURE_TPR_SHADOW (1U << 3U)
37+
#define VAPIC_FEATURE_POST_INTR (1U << 4U)
38+
#define VAPIC_FEATURE_VX2APIC_MODE (1U << 5U)
3939

4040
struct cpu_capability {
4141
uint8_t apicv_features;

hypervisor/arch/x86/vtd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ remove_iommu_device(const struct iommu_domain *domain, uint16_t segment,
10771077
context_table_addr = dmar_get_bitslice(root_entry->lower,
10781078
ROOT_ENTRY_LOWER_CTP_MASK,
10791079
ROOT_ENTRY_LOWER_CTP_POS);
1080-
context_table_addr = context_table_addr << 12;
1080+
context_table_addr = context_table_addr << CPU_PAGE_SHIFT;
10811081
context_table =
10821082
(struct dmar_context_entry *)hpa2hva(context_table_addr);
10831083

hypervisor/boot/dmar_parse.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ static uint8_t get_secondary_bus(uint8_t bus, uint8_t dev, uint8_t func)
145145
{
146146
uint32_t data;
147147

148-
pio_write32(PCI_CFG_ENABLE | (bus << 16) | (dev << 11) |
149-
(func << 8) | 0x18, PCI_CONFIG_ADDR);
148+
pio_write32(PCI_CFG_ENABLE | (bus << 16U) | (dev << 11U) |
149+
(func << 8U) | 0x18U, PCI_CONFIG_ADDR);
150150

151151
data = pio_read32(PCI_CONFIG_DATA);
152152

153-
return (data >> 8) & 0xff;
153+
return (data >> 8U) & 0xffU;
154154
}
155155

156156
static uint16_t
@@ -173,7 +173,7 @@ dmar_path_bdf(int path_len, int busno,
173173
dev = path[i].device;
174174
fun = path[i].function;
175175
}
176-
return (bus << 8 | DEVFUN(dev, fun));
176+
return (bus << 8U | DEVFUN(dev, fun));
177177
}
178178

179179

@@ -267,8 +267,8 @@ handle_one_drhd(struct acpi_dmar_hardware_unit *acpi_drhd,
267267

268268
consumed = handle_dmar_devscope(dev_scope, cp, remaining);
269269

270-
if (((drhd->segment << 16) |
271-
(dev_scope->bus << 8) |
270+
if (((drhd->segment << 16U) |
271+
(dev_scope->bus << 8U) |
272272
dev_scope->devfun) == CONFIG_GPU_SBDF) {
273273
ASSERT(dev_count == 1, "no dedicated iommu for gpu");
274274
drhd->ignore = true;

hypervisor/bsp/uefi/efi/boot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
uint32_t msrl, msrh; \
6464
asm volatile ("rdmsr" : "=a"(msrl), \
6565
"=d"(msrh) : "c" (reg)); \
66-
*msr_val_ptr = ((uint64_t)msrh<<32) | msrl; \
66+
*msr_val_ptr = ((uint64_t)msrh << 32U) | msrl; \
6767
}
6868

6969
EFI_STATUS get_pe_section(CHAR8 *base, char *section, UINTN *vaddr, UINTN *size);

hypervisor/bsp/uefi/efi/efilinux.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#define EFILINUX_VERSION_MAJOR 1
4646
#define EFILINUX_VERSION_MINOR 0
4747

48-
#define MEM_ADDR_1MB (1 << 20)
49-
#define MEM_ADDR_4GB (0xFFFFFFFF)
48+
#define MEM_ADDR_1MB (1U << 20U)
49+
#define MEM_ADDR_4GB (0xFFFFFFFFU)
5050

5151

5252
extern EFI_SYSTEM_TABLE *sys_table;

hypervisor/debug/shell_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <spinlock.h>
1111

1212
#define SHELL_CMD_MAX_LEN 100U
13-
#define SHELL_STRING_MAX_LEN (CPU_PAGE_SIZE << 2)
13+
#define SHELL_STRING_MAX_LEN (CPU_PAGE_SIZE << 2U)
1414

1515
/* Shell Command Function */
1616
typedef int (*shell_cmd_fn_t)(int argc, char **argv);

hypervisor/debug/uart16550.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
/*enable/disable receive data read request interrupt*/
5353

5454
/* definition for LCR */
55-
#define LCR_DLAB (1U << 7) /*DLAB THR/RBR&IER or DLL&DLM= Bit 7*/
56-
#define LCR_SB (1U << 6) /*break control on/off= Bit 6*/
57-
#define LCR_SP (1U << 5) /*Specifies the operation of parity bit*/
58-
#define LCR_EPS (1U << 4) /*Specifies the logic of a parity bit*/
59-
#define LCR_PEN (1U << 3) /*Specifies whether to add a parity bit*/
60-
#define LCR_STB (1U << 2) /*stop bit length*/
55+
#define LCR_DLAB (1U << 7U) /*DLAB THR/RBR&IER or DLL&DLM= Bit 7*/
56+
#define LCR_SB (1U << 6U) /*break control on/off= Bit 6*/
57+
#define LCR_SP (1U << 5U) /*Specifies the operation of parity bit*/
58+
#define LCR_EPS (1U << 4U) /*Specifies the logic of a parity bit*/
59+
#define LCR_PEN (1U << 3U) /*Specifies whether to add a parity bit*/
60+
#define LCR_STB (1U << 2U) /*stop bit length*/
6161
#define LCR_WL8 (0x03U) /*number of bits of serial data*/
6262
#define LCR_WL7 (0x02U) /*number of bits of serial data*/
6363
#define LCR_WL6 (0x01U) /*number of bits of serial data*/
@@ -70,32 +70,32 @@
7070

7171
/* bit definitions for LSR */
7272
/* at least one error in data within fifo */
73-
#define LSR_ERR (1U << 7)
73+
#define LSR_ERR (1U << 7U)
7474
/* Transmit data Present */
75-
#define LSR_TEMT (1U << 6)
75+
#define LSR_TEMT (1U << 6U)
7676
/* Transmit data write request present */
77-
#define LSR_THRE (1U << 5)
77+
#define LSR_THRE (1U << 5U)
7878
/* Break interrupt data Present */
79-
#define LSR_BI (1U << 4)
79+
#define LSR_BI (1U << 4U)
8080
/* Framing Error Occurred */
81-
#define LSR_FE (1U << 3)
81+
#define LSR_FE (1U << 3U)
8282
/* Parity Error Occurred */
83-
#define LSR_PE (1U << 2)
83+
#define LSR_PE (1U << 2U)
8484
/* Overrun error */
85-
#define LSR_OE (1U << 1)
85+
#define LSR_OE (1U << 1U)
8686
/* Readable received data is present */
87-
#define LSR_DR (1U << 0)
87+
#define LSR_DR (1U << 0U)
8888

8989
/* definition for MCR */
90-
#define MCR_RTS (1U << 1) /* Request to Send */
91-
#define MCR_DTR (1U << 0) /* Data Terminal Ready */
90+
#define MCR_RTS (1U << 1U) /* Request to Send */
91+
#define MCR_DTR (1U << 0U) /* Data Terminal Ready */
9292

9393
/* definition for FCR */
9494
#define FCR_RX_MASK 0xc0U
95-
#define FCR_DMA (1U << 3)
96-
#define FCR_TFR (1U << 2) /* Reset Transmit Fifo */
97-
#define FCR_RFR (1U << 1) /* Reset Receive Fifo */
98-
#define FCR_FIFOE (1U << 0) /* Fifo Enable */
95+
#define FCR_DMA (1U << 3U)
96+
#define FCR_TFR (1U << 2U) /* Reset Transmit Fifo */
97+
#define FCR_RFR (1U << 1U) /* Reset Receive Fifo */
98+
#define FCR_FIFOE (1U << 0U) /* Fifo Enable */
9999

100100
#define UART_IER_DISABLE_ALL 0x00000000U
101101

hypervisor/include/public/acrn_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#endif
4848

4949
/* Generic VM flags from guest OS */
50-
#define SECURE_WORLD_ENABLED (1UL<<0U) /* Whether secure world is enabled */
50+
#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */
5151

5252
/**
5353
* @brief Hypercall

0 commit comments

Comments
 (0)