Skip to content

Commit aa505a2

Browse files
junjiemao1lijinxia
authored andcommitted
HV: treewide: convert hexadecimals used in bitops to unsigned
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
1 parent cdd38d0 commit aa505a2

29 files changed

+258
-258
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static void ptdev_build_physical_msi(struct vm *vm, struct ptdev_msi_info *info,
202202
bool phys;
203203

204204
/* get physical destination cpu mask */
205-
dest = (info->vmsi_addr >> 12) & 0xff;
205+
dest = (info->vmsi_addr >> 12) & 0xffU;
206206
phys = ((info->vmsi_addr &
207207
(MSI_ADDR_RH | MSI_ADDR_LOG)) !=
208208
(MSI_ADDR_RH | MSI_ADDR_LOG));
@@ -216,12 +216,12 @@ static void ptdev_build_physical_msi(struct vm *vm, struct ptdev_msi_info *info,
216216

217217
/* update physical delivery mode & vector */
218218
info->pmsi_data = info->vmsi_data;
219-
info->pmsi_data &= ~0x7FF;
219+
info->pmsi_data &= ~0x7FFU;
220220
info->pmsi_data |= delmode | vector;
221221

222222
/* update physical dest mode & dest field */
223223
info->pmsi_addr = info->vmsi_addr;
224-
info->pmsi_addr &= ~0xFF00C;
224+
info->pmsi_addr &= ~0xFF00CU;
225225
info->pmsi_addr |= pdmask << 12 |
226226
MSI_ADDR_RH | MSI_ADDR_LOG;
227227

@@ -636,17 +636,17 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf,
636636
/* build physical config MSI, update to info->pmsi_xxx */
637637
ptdev_build_physical_msi(vm, info, dev_to_vector(entry->node));
638638
entry->ptdev_intr_info.msi = *info;
639-
entry->ptdev_intr_info.msi.virt_vector = info->vmsi_data & 0xFF;
639+
entry->ptdev_intr_info.msi.virt_vector = info->vmsi_data & 0xFFU;
640640
entry->ptdev_intr_info.msi.phys_vector = dev_to_vector(entry->node);
641641

642642
/* update irq handler according to info in guest */
643643
ptdev_update_irq_handler(vm, entry);
644644

645645
dev_dbg(ACRN_DBG_IRQ,
646646
"PCI %x:%x.%x MSI VR[%d] 0x%x->0x%x assigned to vm%d",
647-
(entry->virt_bdf >> 8) & 0xFF,
648-
(entry->virt_bdf >> 3) & 0x1F,
649-
(entry->virt_bdf) & 0x7,
647+
(entry->virt_bdf >> 8) & 0xFFU,
648+
(entry->virt_bdf >> 3) & 0x1FU,
649+
(entry->virt_bdf) & 0x7U,
650650
entry->ptdev_intr_info.msi.msix_entry_index,
651651
entry->ptdev_intr_info.msi.virt_vector,
652652
entry->ptdev_intr_info.msi.phys_vector,
@@ -920,7 +920,7 @@ static void get_entry_info(struct ptdev_remapping_info *entry, char *type,
920920
if (is_entry_active(entry)) {
921921
if (entry->type == PTDEV_INTR_MSI) {
922922
strcpy_s(type, 16, "MSI");
923-
*dest = (entry->ptdev_intr_info.msi.pmsi_addr & 0xFF000)
923+
*dest = (entry->ptdev_intr_info.msi.pmsi_addr & 0xFF000U)
924924
>> 12;
925925
if ((entry->ptdev_intr_info.msi.pmsi_data &
926926
APIC_TRIGMOD_LEVEL) != 0U)
@@ -1003,10 +1003,10 @@ void get_ptdev_info(char *str, int str_max)
10031003
is_entry_active(entry) ?
10041004
(lvl_tm ? "level" : "edge") : "none",
10051005
pin, vpin,
1006-
(bdf & 0xff00) >> 8,
1007-
(bdf & 0xf8) >> 3, bdf & 0x7,
1008-
(vbdf & 0xff00) >> 8,
1009-
(vbdf & 0xf8) >> 3, vbdf & 0x7);
1006+
(bdf & 0xff00U) >> 8,
1007+
(bdf & 0xf8U) >> 3, bdf & 0x7U,
1008+
(vbdf & 0xff00U) >> 8,
1009+
(vbdf & 0xf8U) >> 3, vbdf & 0x7U);
10101010
size -= len;
10111011
str += len;
10121012
}

hypervisor/arch/x86/guest/guest.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct page_walk_info {
3131
inline bool
3232
is_vm0(struct vm *vm)
3333
{
34-
return (vm->attr.boot_idx & 0x7F) == 0;
34+
return (vm->attr.boot_idx & 0x7FU) == 0;
3535
}
3636

3737
inline struct vcpu *vcpu_from_vid(struct vm *vm, int vcpu_id)
@@ -206,14 +206,14 @@ static int _gva2gpa_pae(struct vcpu *vcpu, struct page_walk_info *pw_info,
206206
uint64_t addr;
207207
int ret;
208208

209-
addr = pw_info->top_entry & 0xFFFFFFF0UL;
209+
addr = pw_info->top_entry & 0xFFFFFFF0U;
210210
base = GPA2HVA(vcpu->vm, addr);
211211
if (base == NULL) {
212212
ret = -EFAULT;
213213
goto out;
214214
}
215215

216-
index = (gva >> 30) & 0x3;
216+
index = (gva >> 30) & 0x3UL;
217217
entry = base[index];
218218

219219
if ((entry & MMU_32BIT_PDE_P) == 0U) {
@@ -264,7 +264,7 @@ int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa,
264264
pw_info.level = pm;
265265
pw_info.is_write_access = !!(*err_code & PAGE_FAULT_WR_FLAG);
266266
pw_info.is_inst_fetch = !!(*err_code & PAGE_FAULT_ID_FLAG);
267-
pw_info.is_user_mode = ((exec_vmread(VMX_GUEST_CS_SEL) & 0x3) == 3);
267+
pw_info.is_user_mode = ((exec_vmread(VMX_GUEST_CS_SEL) & 0x3UL) == 3UL);
268268
pw_info.pse = true;
269269
pw_info.nxe = cur_context->ia32_efer & MSR_IA32_EFER_NXE_BIT;
270270
pw_info.wp = !!(cur_context->cr0 & CR0_WP);
@@ -418,7 +418,7 @@ void init_e820(void)
418418
struct multiboot_info *mbi =
419419
(struct multiboot_info *)((uint64_t)boot_regs[1]);
420420
pr_info("Multiboot info detected\n");
421-
if ((mbi->mi_flags & 0x40) != 0U) {
421+
if ((mbi->mi_flags & 0x40U) != 0U) {
422422
struct multiboot_mmap *mmap =
423423
(struct multiboot_mmap *)
424424
((uint64_t)mbi->mi_mmap_addr);

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ enum {
5555
};
5656

5757
/* struct vie_op.op_flags */
58-
#define VIE_OP_F_IMM (1 << 0) /* 16/32-bit immediate operand */
59-
#define VIE_OP_F_IMM8 (1 << 1) /* 8-bit immediate operand */
60-
#define VIE_OP_F_MOFFSET (1 << 2) /* 16/32/64-bit immediate moffset */
61-
#define VIE_OP_F_NO_MODRM (1 << 3)
62-
#define VIE_OP_F_NO_GLA_VERIFICATION (1 << 4)
58+
#define VIE_OP_F_IMM (1U << 0) /* 16/32-bit immediate operand */
59+
#define VIE_OP_F_IMM8 (1U << 1) /* 8-bit immediate operand */
60+
#define VIE_OP_F_MOFFSET (1U << 2) /* 16/32/64-bit immediate moffset */
61+
#define VIE_OP_F_NO_MODRM (1U << 3)
62+
#define VIE_OP_F_NO_GLA_VERIFICATION (1U << 4)
6363

6464
static const struct vie_op two_byte_opcodes[256] = {
6565
[0xB6] = {
@@ -272,9 +272,9 @@ vie_calc_bytereg(struct vie *vie, enum vm_reg_name *reg, int *lhbr)
272272
* %ah, %ch, %dh and %bh respectively.
273273
*/
274274
if (vie->rex_present == 0U) {
275-
if ((vie->reg & 0x4) != 0U) {
275+
if ((vie->reg & 0x4U) != 0U) {
276276
*lhbr = 1;
277-
*reg = gpr_map[vie->reg & 0x3];
277+
*reg = gpr_map[vie->reg & 0x3U];
278278
}
279279
}
280280
}
@@ -1343,7 +1343,7 @@ emulate_push(struct vcpu *vcpu, uint64_t mmio_gpa, struct vie *vie,
13431343
* PUSH is part of the group 5 extended opcodes and is identified
13441344
* by ModRM:reg = b110.
13451345
*/
1346-
if ((vie->reg & 7) != 6)
1346+
if ((vie->reg & 7U) != 6)
13471347
return -EINVAL;
13481348

13491349
error = emulate_stack_op(vcpu, mmio_gpa, vie, paging, memread,
@@ -1364,7 +1364,7 @@ emulate_pop(struct vcpu *vcpu, uint64_t mmio_gpa, struct vie *vie,
13641364
* POP is part of the group 1A extended opcodes and is identified
13651365
* by ModRM:reg = b000.
13661366
*/
1367-
if ((vie->reg & 7) != 0)
1367+
if ((vie->reg & 7U) != 0)
13681368
return -EINVAL;
13691369

13701370
error = emulate_stack_op(vcpu, mmio_gpa, vie, paging, memread,
@@ -1380,16 +1380,16 @@ emulate_group1(struct vcpu *vcpu, uint64_t gpa, struct vie *vie,
13801380
{
13811381
int error;
13821382

1383-
switch (vie->reg & 7) {
1384-
case 0x1: /* OR */
1383+
switch (vie->reg & 7U) {
1384+
case 0x1U: /* OR */
13851385
error = emulate_or(vcpu, gpa, vie,
13861386
memread, memwrite, memarg);
13871387
break;
1388-
case 0x4: /* AND */
1388+
case 0x4U: /* AND */
13891389
error = emulate_and(vcpu, gpa, vie,
13901390
memread, memwrite, memarg);
13911391
break;
1392-
case 0x7: /* CMP */
1392+
case 0x7U: /* CMP */
13931393
error = emulate_cmp(vcpu, gpa, vie,
13941394
memread, memwrite, memarg);
13951395
break;
@@ -1415,7 +1415,7 @@ emulate_bittest(struct vcpu *vcpu, uint64_t gpa, struct vie *vie,
14151415
* Currently we only emulate the 'Bit Test' instruction which is
14161416
* identified by a ModR/M:reg encoding of 100b.
14171417
*/
1418-
if ((vie->reg & 7) != 4)
1418+
if ((vie->reg & 7U) != 4)
14191419
return -EINVAL;
14201420

14211421
error = vie_read_register(vcpu, VM_REG_GUEST_RFLAGS, &rflags);
@@ -1607,7 +1607,7 @@ vie_calculate_gla(enum vm_cpu_mode cpu_mode, enum vm_reg_name seg,
16071607

16081608
if ((prot & PROT_READ) != 0) {
16091609
/* #GP on a read access to a exec-only code segment */
1610-
if ((type & 0xA) == 0x8)
1610+
if ((type & 0xAU) == 0x8U)
16111611
return -1;
16121612
}
16131613

@@ -1616,18 +1616,18 @@ vie_calculate_gla(enum vm_cpu_mode cpu_mode, enum vm_reg_name seg,
16161616
* #GP on a write access to a code segment or a
16171617
* read-only data segment.
16181618
*/
1619-
if ((type & 0x8) != 0) /* code segment */
1619+
if ((type & 0x8U) != 0) /* code segment */
16201620
return -1;
16211621

1622-
if ((type & 0xA) == 0) /* read-only data seg */
1622+
if ((type & 0xAU) == 0) /* read-only data seg */
16231623
return -1;
16241624
}
16251625

16261626
/*
16271627
* 'desc->limit' is fully expanded taking granularity into
16281628
* account.
16291629
*/
1630-
if ((type & 0xC) == 0x4) {
1630+
if ((type & 0xCU) == 0x4U) {
16311631
/* expand-down data segment */
16321632
low_limit = desc->limit + 1;
16331633
high_limit = SEG_DESC_DEF32(desc->access) ?
@@ -1786,10 +1786,10 @@ decode_prefixes(struct vie *vie, enum vm_cpu_mode cpu_mode, int cs_d)
17861786
*/
17871787
if (cpu_mode == CPU_MODE_64BIT && x >= 0x40 && x <= 0x4F) {
17881788
vie->rex_present = 1;
1789-
vie->rex_w = (x & 0x8) != 0U ? 1 : 0;
1790-
vie->rex_r = (x & 0x4) != 0U ? 1 : 0;
1791-
vie->rex_x = (x & 0x2) != 0U ? 1 : 0;
1792-
vie->rex_b = (x & 0x1) != 0U ? 1 : 0;
1789+
vie->rex_w = (x & 0x8U) != 0U ? 1 : 0;
1790+
vie->rex_r = (x & 0x4U) != 0U ? 1 : 0;
1791+
vie->rex_x = (x & 0x2U) != 0U ? 1 : 0;
1792+
vie->rex_b = (x & 0x1U) != 0U ? 1 : 0;
17931793
vie_advance(vie);
17941794
}
17951795

@@ -1872,9 +1872,9 @@ decode_modrm(struct vie *vie, enum vm_cpu_mode cpu_mode)
18721872
if (vie_peek(vie, &x) != 0)
18731873
return -1;
18741874

1875-
vie->mod = (x >> 6) & 0x3;
1876-
vie->rm = (x >> 0) & 0x7;
1877-
vie->reg = (x >> 3) & 0x7;
1875+
vie->mod = (x >> 6) & 0x3U;
1876+
vie->rm = (x >> 0) & 0x7U;
1877+
vie->reg = (x >> 3) & 0x7U;
18781878

18791879
/*
18801880
* A direct addressing mode makes no sense in the context of an EPT
@@ -1954,9 +1954,9 @@ decode_sib(struct vie *vie)
19541954
return -1;
19551955

19561956
/* De-construct the SIB byte */
1957-
vie->ss = (x >> 6) & 0x3;
1958-
vie->index = (x >> 3) & 0x7;
1959-
vie->base = (x >> 0) & 0x7;
1957+
vie->ss = (x >> 6) & 0x3U;
1958+
vie->index = (x >> 3) & 0x7U;
1959+
vie->base = (x >> 0) & 0x7U;
19601960

19611961
/* Apply the REX prefix modifiers */
19621962
vie->index |= vie->rex_x << 3;

hypervisor/arch/x86/guest/instr_emul_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static void get_guest_paging_info(struct vcpu *vcpu, struct emul_cnx *emul_cnx)
259259
ASSERT(emul_cnx != NULL && vcpu != NULL, "Error in input arguments");
260260

261261
csar = exec_vmread(VMX_GUEST_CS_ATTR);
262-
cpl = (csar >> 5) & 3;
262+
cpl = (csar >> 5) & 3U;
263263
emul_cnx->paging.cr3 =
264264
vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].cr3;
265265
emul_cnx->paging.cpl = cpl;

hypervisor/arch/x86/guest/instr_emul_wrapper.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,23 @@ struct vie {
7979
struct vie_op op; /* opcode description */
8080
};
8181

82-
#define PSL_C 0x00000001 /* carry bit */
83-
#define PSL_PF 0x00000004 /* parity bit */
84-
#define PSL_AF 0x00000010 /* bcd carry bit */
85-
#define PSL_Z 0x00000040 /* zero bit */
86-
#define PSL_N 0x00000080 /* negative bit */
87-
#define PSL_T 0x00000100 /* trace enable bit */
88-
#define PSL_I 0x00000200 /* interrupt enable bit */
89-
#define PSL_D 0x00000400 /* string instruction direction bit */
90-
#define PSL_V 0x00000800 /* overflow bit */
91-
#define PSL_IOPL 0x00003000 /* i/o privilege level */
92-
#define PSL_NT 0x00004000 /* nested task bit */
93-
#define PSL_RF 0x00010000 /* resume flag bit */
94-
#define PSL_VM 0x00020000 /* virtual 8086 mode bit */
95-
#define PSL_AC 0x00040000 /* alignment checking */
96-
#define PSL_VIF 0x00080000 /* virtual interrupt enable */
97-
#define PSL_VIP 0x00100000 /* virtual interrupt pending */
98-
#define PSL_ID 0x00200000 /* identification bit */
82+
#define PSL_C 0x00000001U /* carry bit */
83+
#define PSL_PF 0x00000004U /* parity bit */
84+
#define PSL_AF 0x00000010U /* bcd carry bit */
85+
#define PSL_Z 0x00000040U /* zero bit */
86+
#define PSL_N 0x00000080U /* negative bit */
87+
#define PSL_T 0x00000100U /* trace enable bit */
88+
#define PSL_I 0x00000200U /* interrupt enable bit */
89+
#define PSL_D 0x00000400U /* string instruction direction bit */
90+
#define PSL_V 0x00000800U /* overflow bit */
91+
#define PSL_IOPL 0x00003000U /* i/o privilege level */
92+
#define PSL_NT 0x00004000U /* nested task bit */
93+
#define PSL_RF 0x00010000U /* resume flag bit */
94+
#define PSL_VM 0x00020000U /* virtual 8086 mode bit */
95+
#define PSL_AC 0x00040000U /* alignment checking */
96+
#define PSL_VIF 0x00080000U /* virtual interrupt enable */
97+
#define PSL_VIP 0x00100000U /* virtual interrupt pending */
98+
#define PSL_ID 0x00200000U /* identification bit */
9999

100100
/*
101101
* The 'access' field has the format specified in Table 21-2 of the Intel
@@ -114,13 +114,13 @@ struct seg_desc {
114114
/*
115115
* Protections are chosen from these bits, or-ed together
116116
*/
117-
#define PROT_NONE 0x00 /* no permissions */
118-
#define PROT_READ 0x01 /* pages can be read */
119-
#define PROT_WRITE 0x02 /* pages can be written */
120-
#define PROT_EXEC 0x04 /* pages can be executed */
117+
#define PROT_NONE 0x00U /* no permissions */
118+
#define PROT_READ 0x01U /* pages can be read */
119+
#define PROT_WRITE 0x02U /* pages can be written */
120+
#define PROT_EXEC 0x04U /* pages can be executed */
121121

122-
#define SEG_DESC_TYPE(access) ((access) & 0x001f)
123-
#define SEG_DESC_DPL(access) (((access) >> 5) & 0x3)
122+
#define SEG_DESC_TYPE(access) ((access) & 0x001fU)
123+
#define SEG_DESC_DPL(access) (((access) >> 5) & 0x3U)
124124
#define SEG_DESC_PRESENT(access) ((((access) & 0x0080U) != 0U) ? 1 : 0)
125125
#define SEG_DESC_DEF32(access) ((((access) & 0x4000U) != 0U) ? 1 : 0)
126126
#define SEG_DESC_GRANULARITY(access) ((((access) & 0x8000U) != 0U) ? 1 : 0)

hypervisor/arch/x86/guest/pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int validate_pstate(struct vm *vm, uint64_t perf_ctl)
2323
}
2424

2525
for (i = 0; i < px_cnt; i++) {
26-
if ((px_data + i)->control == (perf_ctl & 0xffff)) {
26+
if ((px_data + i)->control == (perf_ctl & 0xffffUL)) {
2727
return 0;
2828
}
2929
}

0 commit comments

Comments
 (0)