Skip to content

Commit 96372ed

Browse files
Shawnshhlijinxia
authored andcommitted
HV:misc:add suffix U to the numeric constant
Add suffix U to the numeric constant Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent d3ad411 commit 96372ed

File tree

14 files changed

+123
-123
lines changed

14 files changed

+123
-123
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,8 @@ static void get_entry_info(struct ptdev_remapping_info *entry, char *type,
947947
} else {
948948
strcpy_s(type, 16, "NONE");
949949
*irq = IRQ_INVALID;
950-
*vector = 0;
951-
*dest = 0;
950+
*vector = 0U;
951+
*dest = 0UL;
952952
*lvl_tm = 0;
953953
*pin = -1;
954954
*vpin = -1;

hypervisor/arch/x86/cpu.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
#endif
1414

1515
spinlock_t trampoline_spinlock = {
16-
.head = 0,
17-
.tail = 0
16+
.head = 0U,
17+
.tail = 0U
1818
};
1919

2020
spinlock_t up_count_spinlock = {
21-
.head = 0,
22-
.tail = 0
21+
.head = 0U,
22+
.tail = 0U
2323
};
2424

2525
struct per_cpu_region *per_cpu_data_base_ptr;
@@ -87,7 +87,7 @@ static inline bool get_monitor_cap(void)
8787
* in hypervisor, but still expose it to the guests and
8888
* let them handle it correctly
8989
*/
90-
if (boot_cpu_data.x86 != 0x6 || boot_cpu_data.x86_model != 0x5c)
90+
if (boot_cpu_data.x86 != 0x6U || boot_cpu_data.x86_model != 0x5cU)
9191
return true;
9292
}
9393

@@ -188,8 +188,8 @@ static int hardware_detect_support(void)
188188
pr_fatal("%s, LM not supported\n", __func__);
189189
return -ENODEV;
190190
}
191-
if ((boot_cpu_data.x86_phys_bits == 0) ||
192-
(boot_cpu_data.x86_virt_bits == 0)) {
191+
if ((boot_cpu_data.x86_phys_bits == 0U) ||
192+
(boot_cpu_data.x86_virt_bits == 0U)) {
193193
pr_fatal("%s, can't detect Linear/Physical Address size\n",
194194
__func__);
195195
return -ENODEV;
@@ -255,7 +255,7 @@ uint16_t __attribute__((weak)) parse_madt(uint8_t *lapic_id_base)
255255
static const uint8_t lapic_id[] = {0U, 2U, 4U, 6U};
256256
uint32_t i;
257257

258-
for (i = 0; i < ARRAY_SIZE(lapic_id); i++)
258+
for (i = 0U; i < ARRAY_SIZE(lapic_id); i++)
259259
*lapic_id_base++ = lapic_id[i];
260260

261261
return ARRAY_SIZE(lapic_id);
@@ -729,7 +729,7 @@ void start_cpus()
729729
* configured time-out has expired
730730
*/
731731
timeout = CONFIG_CPU_UP_TIMEOUT * 1000;
732-
while ((up_count != expected_up) && (timeout != 0)) {
732+
while ((up_count != expected_up) && (timeout != 0U)) {
733733
/* Delay 10us */
734734
udelay(10);
735735

@@ -762,7 +762,7 @@ void stop_cpus()
762762
}
763763

764764
expected_up = 1;
765-
while ((up_count != expected_up) && (timeout !=0)) {
765+
while ((up_count != expected_up) && (timeout != 0U)) {
766766
/* Delay 10us */
767767
udelay(10);
768768

@@ -875,11 +875,11 @@ static void vapic_cap_detect(void)
875875
uint8_t features;
876876
uint64_t msr_val;
877877

878-
features = 0;
878+
features = 0U;
879879

880880
msr_val = msr_read(MSR_IA32_VMX_PROCBASED_CTLS);
881881
if (!is_ctrl_setting_allowed(msr_val, VMX_PROCBASED_CTLS_TPR_SHADOW)) {
882-
cpu_caps.vapic_features = 0;
882+
cpu_caps.vapic_features = 0U;
883883
return;
884884
}
885885
features |= VAPIC_FEATURE_TPR_SHADOW;

hypervisor/arch/x86/ept.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ void free_ept_mem(void *pml4_addr)
5757
return;
5858
}
5959

60-
for (pml4_index = 0; pml4_index < IA32E_NUM_ENTRIES; pml4_index++) {
60+
for (pml4_index = 0U; pml4_index < IA32E_NUM_ENTRIES; pml4_index++) {
6161
/* Walk from the PML4 table to the PDPT table */
6262
pdpt_addr = HPA2HVA(find_next_table(pml4_index, pml4_addr));
6363
if (pdpt_addr == NULL)
6464
continue;
6565

66-
for (pdpt_index = 0; pdpt_index < IA32E_NUM_ENTRIES;
66+
for (pdpt_index = 0U; pdpt_index < IA32E_NUM_ENTRIES;
6767
pdpt_index++) {
6868
/* Walk from the PDPT table to the PD table */
6969
pde_addr = HPA2HVA(find_next_table(pdpt_index,
@@ -72,7 +72,7 @@ void free_ept_mem(void *pml4_addr)
7272
if (pde_addr == NULL)
7373
continue;
7474

75-
for (pde_index = 0; pde_index < IA32E_NUM_ENTRIES;
75+
for (pde_index = 0U; pde_index < IA32E_NUM_ENTRIES;
7676
pde_index++) {
7777
/* Walk from the PD table to the page table */
7878
pte_addr = HPA2HVA(find_next_table(pde_index,
@@ -105,7 +105,7 @@ void destroy_ept(struct vm *vm)
105105
*/
106106
if (vm->sworld_control.sworld_enabled && (vm->arch_vm.sworld_eptp != 0U)) {
107107
free_ept_mem(HPA2HVA(vm->arch_vm.sworld_eptp));
108-
vm->arch_vm.sworld_eptp = 0;
108+
vm->arch_vm.sworld_eptp = 0UL;
109109
}
110110
}
111111

@@ -319,7 +319,7 @@ static int dm_emulate_mmio_pre(struct vcpu *vcpu, uint64_t exit_qual)
319319
vcpu->req.type = REQ_WP;
320320
}
321321

322-
if (vcpu->req.type == 0)
322+
if (vcpu->req.type == 0U)
323323
vcpu->req.type = REQ_MMIO;
324324
vcpu->req.reqs.mmio_request.direction = vcpu->mmio.read_write;
325325
vcpu->req.reqs.mmio_request.address = (long)vcpu->mmio.paddr;
@@ -349,7 +349,7 @@ int ept_violation_vmexit_handler(struct vcpu *vcpu)
349349
/* TODO: Need to figure out how to determine value being
350350
* written
351351
*/
352-
mmio->value = 0;
352+
mmio->value = 0UL;
353353
} else {
354354
/* Read operation */
355355
mmio->read_write = HV_MEM_IO_READ;
@@ -358,7 +358,7 @@ int ept_violation_vmexit_handler(struct vcpu *vcpu)
358358
/* TODO: Need to determine how sign extension is determined for
359359
* reads
360360
*/
361-
mmio->sign_extend_read = 0;
361+
mmio->sign_extend_read = 0U;
362362
}
363363

364364
/* Get the guest physical address */

hypervisor/arch/x86/gdt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ void load_gdtr_and_tr(void)
3737
tss->ist1 = (uint64_t)get_cpu_var(mc_stack) + CONFIG_STACK_SIZE;
3838
tss->ist2 = (uint64_t)get_cpu_var(df_stack) + CONFIG_STACK_SIZE;
3939
tss->ist3 = (uint64_t)get_cpu_var(sf_stack) + CONFIG_STACK_SIZE;
40-
tss->ist4 = 0L;
40+
tss->ist4 = 0UL;
4141

4242
/* tss descriptor */
4343
set_tss_desc(&gdt->host_gdt_tss_descriptors,
4444
(void *)tss, sizeof(struct tss_64), TSS_AVAIL);
4545

46-
gdtr.len = sizeof(struct host_gdt) - 1;
46+
gdtr.len = sizeof(struct host_gdt) - 1U;
4747
gdtr.gdt = gdt;
4848

4949
asm volatile ("lgdt %0" ::"m"(gdtr));

hypervisor/arch/x86/io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int dm_emulate_pio_post(struct vcpu *vcpu)
1212
int cur_context = vcpu->arch_vcpu.cur_context;
1313
union vhm_request_buffer *req_buf = NULL;
1414
uint32_t mask =
15-
0xFFFFFFFFul >> (32 - 8 * vcpu->req.reqs.pio_request.size);
15+
0xFFFFFFFFUL >> (32 - 8 * vcpu->req.reqs.pio_request.size);
1616
uint64_t *rax;
1717

1818
req_buf = (union vhm_request_buffer *)(vcpu->vm->sw.io_shared_page);
@@ -164,7 +164,7 @@ void allow_guest_io_access(struct vm *vm, uint32_t address, uint32_t nbytes)
164164
uint32_t a;
165165

166166
b = vm->arch_vm.iobitmap[0];
167-
for (i = 0; i < nbytes; i++) {
167+
for (i = 0U; i < nbytes; i++) {
168168
if ((address & 0x8000U) != 0U)
169169
b = vm->arch_vm.iobitmap[1];
170170
a = address & 0x7fffU;
@@ -180,11 +180,11 @@ static void deny_guest_io_access(struct vm *vm, uint32_t address, uint32_t nbyte
180180
uint32_t a;
181181

182182
b = vm->arch_vm.iobitmap[0];
183-
for (i = 0; i < nbytes; i++) {
183+
for (i = 0U; i < nbytes; i++) {
184184
if ((address & 0x8000U) != 0U)
185185
b = vm->arch_vm.iobitmap[1];
186186
a = address & 0x7fffU;
187-
b[a >> 5] |= (1 << (a & 0x1fU));
187+
b[a >> 5U] |= (1U << (a & 0x1fU));
188188
address++;
189189
}
190190
}

hypervisor/arch/x86/mmu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,13 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
296296
default:
297297

298298
/* Set mapping size to 0 - can't map memory in PML4 */
299-
mapped_size = 0;
299+
mapped_size = 0U;
300300

301301
break;
302302
}
303303

304304
/* Check to see if mapping should occur */
305-
if (mapped_size != 0) {
305+
if (mapped_size != 0U) {
306306
/* Get current table entry */
307307
uint64_t entry = MEM_READ64(table_base + table_offset);
308308
bool prev_entry_present = false;
@@ -415,7 +415,7 @@ static uint32_t map_mem_region(void *vaddr, void *paddr,
415415
* TODO: add shootdown APs operation if MMU will be
416416
* modified after AP start in the future.
417417
*/
418-
if ((phys_cpu_num != 0) &&
418+
if ((phys_cpu_num != 0U) &&
419419
((pcpu_active_bitmap &
420420
((1UL << phys_cpu_num) - 1))
421421
!= (1UL << CPU_BOOT_ID))) {
@@ -620,7 +620,7 @@ void init_paging(void)
620620
attr_uc);
621621

622622
/* Modify WB attribute for E820_TYPE_RAM */
623-
for (i = 0, entry = &e820[0];
623+
for (i = 0U, entry = &e820[0];
624624
i < e820_entries;
625625
i++, entry = &e820[i]) {
626626
if (entry->type == E820_TYPE_RAM) {
@@ -864,10 +864,10 @@ static uint64_t update_page_table_entry(struct map_params *map_params,
864864
static uint64_t break_page_table(struct map_params *map_params, void *paddr,
865865
void *vaddr, uint64_t page_size, bool direct)
866866
{
867-
uint32_t i = 0;
867+
uint32_t i = 0U;
868868
uint64_t pa;
869-
uint64_t attr = 0x00;
870-
uint64_t next_page_size = 0x00;
869+
uint64_t attr = 0x0UL;
870+
uint64_t next_page_size = 0x0UL;
871871
void *sub_tab_addr = NULL;
872872
struct entry_params entry;
873873

@@ -930,7 +930,7 @@ static uint64_t break_page_table(struct map_params *map_params, void *paddr,
930930
attr |= (entry.entry_val & 0x7fUL);
931931
}
932932
/* write all entries and keep original attr*/
933-
for (i = 0; i < IA32E_NUM_ENTRIES; i++) {
933+
for (i = 0U; i < IA32E_NUM_ENTRIES; i++) {
934934
MEM_WRITE64(sub_tab_addr + (i * IA32E_COMM_ENTRY_SIZE),
935935
(attr | (pa + (i * next_page_size))));
936936
}
@@ -1033,7 +1033,7 @@ static int modify_paging(struct map_params *map_params, void *paddr,
10331033
*/
10341034
page_size = break_page_table(map_params,
10351035
paddr, vaddr, page_size, direct);
1036-
if (page_size == 0)
1036+
if (page_size == 0UL)
10371037
return -EINVAL;
10381038
}
10391039
} else {
@@ -1043,7 +1043,7 @@ static int modify_paging(struct map_params *map_params, void *paddr,
10431043
/* The function return the memory size that one entry can map */
10441044
adjust_size = update_page_table_entry(map_params, paddr, vaddr,
10451045
page_size, attr, request_type, direct);
1046-
if (adjust_size == 0)
1046+
if (adjust_size == 0UL)
10471047
return -EINVAL;
10481048
vaddr += adjust_size;
10491049
paddr += adjust_size;

hypervisor/arch/x86/notify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void setup_notification(void)
4646
char name[32] = {0};
4747

4848
cpu = get_cpu_id();
49-
if (cpu > 0)
49+
if (cpu > 0U)
5050
return;
5151

5252
/* support IPI notification, VM0 will register all CPU */

hypervisor/arch/x86/softirq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void init_softirq(void)
2121
uint16_t pcpu_id;
2222

2323
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) {
24-
per_cpu(softirq_pending, pcpu_id) = 0;
24+
per_cpu(softirq_pending, pcpu_id) = 0UL;
2525
bitmap_set(SOFTIRQ_ATOMIC, &per_cpu(softirq_pending, pcpu_id));
2626
}
2727
}

hypervisor/arch/x86/trusty.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ struct trusty_mem {
2828

2929
static struct key_info g_key_info = {
3030
.size_of_this_struct = sizeof(g_key_info),
31-
.version = 0,
32-
.platform = 3,
33-
.num_seeds = 1
31+
.version = 0U,
32+
.platform = 3U,
33+
.num_seeds = 1U
3434
};
3535

3636
#define save_segment(seg, SEG_NAME) \
@@ -71,7 +71,7 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
7171
}
7272

7373
if (!vm->sworld_control.sworld_enabled
74-
|| vm->arch_vm.sworld_eptp != 0) {
74+
|| vm->arch_vm.sworld_eptp != 0UL) {
7575
pr_err("Sworld is not enabled or Sworld eptp is not NULL");
7676
return;
7777
}
@@ -323,7 +323,7 @@ static bool setup_trusty_info(struct vcpu *vcpu,
323323
sizeof(mem->first_page.data.key_info.dseed_list));
324324
/* Derive dvseed from dseed for Trusty */
325325
key_info = &mem->first_page.data.key_info;
326-
for (i = 0; i < g_key_info.num_seeds; i++) {
326+
for (i = 0U; i < g_key_info.num_seeds; i++) {
327327
if (hkdf_sha256(key_info->dseed_list[i].seed,
328328
BUP_MKHI_BOOTLOADER_SEED_LEN,
329329
g_key_info.dseed_list[i].seed,
@@ -364,11 +364,11 @@ static bool init_secure_world_env(struct vcpu *vcpu,
364364
uint64_t base_hpa,
365365
uint32_t size)
366366
{
367-
vcpu->arch_vcpu.inst_len = 0;
367+
vcpu->arch_vcpu.inst_len = 0U;
368368
vcpu->arch_vcpu.contexts[SECURE_WORLD].rip = entry_gpa;
369369
vcpu->arch_vcpu.contexts[SECURE_WORLD].rsp =
370370
TRUSTY_EPT_REBASE_GPA + size;
371-
vcpu->arch_vcpu.contexts[SECURE_WORLD].tsc_offset = 0;
371+
vcpu->arch_vcpu.contexts[SECURE_WORLD].tsc_offset = 0UL;
372372

373373
vcpu->arch_vcpu.contexts[SECURE_WORLD].cr0 =
374374
vcpu->arch_vcpu.contexts[NORMAL_WORLD].cr0;
@@ -412,12 +412,12 @@ bool initialize_trusty(struct vcpu *vcpu, uint64_t param)
412412
return false;
413413
}
414414

415-
if (boot_param->entry_point == 0) {
415+
if (boot_param->entry_point == 0U) {
416416
pr_err("%s: Invalid entry point\n", __func__);
417417
return false;
418418
}
419419

420-
if (boot_param->base_addr == 0) {
420+
if (boot_param->base_addr == 0U) {
421421
pr_err("%s: Invalid memory base address\n", __func__);
422422
return false;
423423
}
@@ -451,7 +451,7 @@ bool initialize_trusty(struct vcpu *vcpu, uint64_t param)
451451
void trusty_set_dseed(void *dseed, uint8_t dseed_num)
452452
{
453453
/* Use fake seed if input param is invalid */
454-
if ((dseed == NULL) || (dseed_num == 0) ||
454+
if ((dseed == NULL) || (dseed_num == 0U) ||
455455
(dseed_num > BOOTLOADER_SEED_MAX_ENTRIES)) {
456456

457457
g_key_info.num_seeds = 1;

hypervisor/arch/x86/vmexit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
307307

308308
val64 = exec_vmread(VMX_GUEST_CR4);
309309
if ((val64 & CR4_OSXSAVE) == 0U) {
310-
vcpu_inject_gp(vcpu, 0);
310+
vcpu_inject_gp(vcpu, 0U);
311311
return -1;
312312
}
313313

0 commit comments

Comments
 (0)