Skip to content

Commit b8384ea

Browse files
Shawnshhlijinxia
authored andcommitted
HV:common:transfer local variable type
The local variable type should be transfer to non-basic type, chaned it to length-prefix(uint32_t,int32_t ...) type. Char *type or char array type which used to pointer a string will be keeped. V1->V2 add extra comments. Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 4ec690f commit b8384ea

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed

hypervisor/common/hv_main.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bool x2apic_enabled;
1111

1212
static void run_vcpu_pre_work(struct vcpu *vcpu)
1313
{
14-
unsigned long *pending_pre_work = &vcpu->pending_pre_work;
14+
uint64_t *pending_pre_work = &vcpu->pending_pre_work;
1515

1616
if (bitmap_test_and_clear(ACRN_VCPU_MMIO_COMPLETE, pending_pre_work))
1717
dm_emulate_mmio_post(vcpu);
@@ -22,7 +22,7 @@ void vcpu_thread(struct vcpu *vcpu)
2222
uint64_t vmexit_begin = 0, vmexit_end = 0;
2323
uint16_t basic_exit_reason = 0;
2424
uint64_t tsc_aux_hyp_cpu = vcpu->pcpu_id;
25-
int ret = 0;
25+
int32_t ret = 0;
2626

2727
/* If vcpu is not launched, we need to do init_vmcs first */
2828
if (!vcpu->launched)
@@ -104,9 +104,9 @@ static bool is_vm0_bsp(uint16_t pcpu_id)
104104
return pcpu_id == vm0_desc.vm_hw_logical_core_ids[0];
105105
}
106106

107-
int hv_main(uint16_t cpu_id)
107+
int32_t hv_main(uint16_t cpu_id)
108108
{
109-
int ret;
109+
int32_t ret;
110110

111111
pr_info("%s, Starting common entry point for CPU %d",
112112
__func__, cpu_id);
@@ -143,7 +143,8 @@ int hv_main(uint16_t cpu_id)
143143

144144
void get_vmexit_profile(char *str, int str_max)
145145
{
146-
int cpu, i, len, size = str_max;
146+
uint16_t cpu, i;
147+
int len, size = str_max;
147148

148149
len = snprintf(str, size, "\r\nNow(us) = %16lld\r\n",
149150
TICKS_TO_US(rdtsc()));
@@ -155,7 +156,7 @@ void get_vmexit_profile(char *str, int str_max)
155156
str += len;
156157

157158
for (cpu = 0; cpu < phys_cpu_num; cpu++) {
158-
len = snprintf(str, size, "\t CPU%d\t US", cpu);
159+
len = snprintf(str, size, "\t CPU%hu\t US", cpu);
159160
size -= len;
160161
str += len;
161162
}

hypervisor/common/hypercall.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int64_t hcall_get_api_version(struct vm *vm, uint64_t param)
4343

4444
static int handle_vpic_irqline(struct vm *vm, int irq, enum irq_mode mode)
4545
{
46-
int ret = -1;
46+
int32_t ret = -1;
4747

4848
if (vm == NULL)
4949
return ret;
@@ -67,7 +67,7 @@ static int handle_vpic_irqline(struct vm *vm, int irq, enum irq_mode mode)
6767
static int
6868
handle_vioapic_irqline(struct vm *vm, int irq, enum irq_mode mode)
6969
{
70-
int ret = -1;
70+
int32_t ret = -1;
7171

7272
if (vm == NULL)
7373
return ret;
@@ -91,8 +91,8 @@ handle_vioapic_irqline(struct vm *vm, int irq, enum irq_mode mode)
9191
static int handle_virt_irqline(struct vm *vm, uint64_t target_vmid,
9292
struct acrn_irqline *param, enum irq_mode mode)
9393
{
94-
int ret = 0;
95-
long intr_type;
94+
int32_t ret = 0;
95+
uint32_t intr_type;
9696
struct vm *target_vm = get_vm_from_vmid(target_vmid);
9797

9898
if ((vm == NULL) || (param == NULL))
@@ -205,7 +205,7 @@ int64_t hcall_pause_vm(uint64_t vmid)
205205

206206
int64_t hcall_create_vcpu(struct vm *vm, uint64_t vmid, uint64_t param)
207207
{
208-
int ret;
208+
int32_t ret;
209209
uint16_t pcpu_id;
210210
struct acrn_create_vcpu cv;
211211

@@ -274,7 +274,7 @@ int64_t hcall_pulse_irqline(struct vm *vm, uint64_t vmid, uint64_t param)
274274

275275
int64_t hcall_inject_msi(struct vm *vm, uint64_t vmid, uint64_t param)
276276
{
277-
int ret = 0;
277+
int32_t ret = 0;
278278
struct acrn_msi_entry msi;
279279
struct vm *target_vm = get_vm_from_vmid(vmid);
280280

@@ -474,7 +474,7 @@ int64_t hcall_set_vm_memmaps(struct vm *vm, uint64_t param)
474474
struct set_memmaps set_memmaps;
475475
struct memory_map *regions;
476476
struct vm *target_vm;
477-
unsigned int idx;
477+
uint32_t idx;
478478

479479
if (!is_vm0(vm)) {
480480
pr_err("%s: ERROR! Not coming from service vm",
@@ -496,7 +496,7 @@ int64_t hcall_set_vm_memmaps(struct vm *vm, uint64_t param)
496496
return -1;
497497
}
498498

499-
idx = 0;
499+
idx = 0U;
500500
/*TODO: use copy_from_gpa for this buffer page */
501501
regions = GPA2HVA(vm, set_memmaps.memmaps_gpa);
502502
while (idx < set_memmaps.memmaps_num) {
@@ -711,7 +711,7 @@ int64_t hcall_setup_sbuf(struct vm *vm, uint64_t param)
711711

712712
int64_t hcall_get_cpu_pm_state(struct vm *vm, uint64_t cmd, uint64_t param)
713713
{
714-
int target_vm_id;
714+
int32_t target_vm_id;
715715
struct vm *target_vm;
716716

717717
target_vm_id = (cmd & PMCMD_VMID_MASK) >> PMCMD_VMID_SHIFT;
@@ -736,7 +736,7 @@ int64_t hcall_get_cpu_pm_state(struct vm *vm, uint64_t cmd, uint64_t param)
736736
return 0;
737737
}
738738
case PMCMD_GET_PX_DATA: {
739-
int pn;
739+
int32_t pn;
740740
struct cpu_px_data *px_data;
741741

742742
/* For now we put px data as per-vm,

hypervisor/common/io_request.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ static void acrn_print_request(int vcpu_id, struct vhm_request *req)
5555
}
5656
}
5757

58-
int acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
58+
int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
5959
{
6060
union vhm_request_buffer *req_buf = NULL;
61-
long cur;
61+
uint16_t cur;
6262

6363
ASSERT(sizeof(*req) == (4096/VHM_REQUEST_MAX),
6464
"vhm_request page broken!");
@@ -148,11 +148,12 @@ static void _get_req_info_(struct vhm_request *req, int *id, char *type,
148148

149149
void get_req_info(char *str, int str_max)
150150
{
151-
int i, len, size = str_max, client_id;
151+
uint32_t i;
152+
int32_t len, size = str_max, client_id;
152153
union vhm_request_buffer *req_buf;
153154
struct vhm_request *req;
154155
char type[16], state[16], dir[16];
155-
long addr, val;
156+
int64_t addr, val;
156157
struct list_head *pos;
157158
struct vm *vm;
158159

hypervisor/common/schedule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static unsigned long pcpu_used_bitmap;
1111

1212
void init_scheduler(void)
1313
{
14-
int i;
14+
uint32_t i;
1515

1616
for (i = 0; i < phys_cpu_num; i++) {
1717
spinlock_init(&per_cpu(sched_ctx, i).runqueue_lock);

hypervisor/common/trusty_hypercall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
int64_t hcall_world_switch(struct vcpu *vcpu)
1414
{
15-
int next_world_id = !(vcpu->arch_vcpu.cur_context);
15+
int32_t next_world_id = !(vcpu->arch_vcpu.cur_context);
1616

1717
if (next_world_id >= NR_WORLD) {
1818
pr_err("%s world_id %d exceed max number of Worlds\n",

hypervisor/common/vm_load.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static uint64_t create_zero_page(struct vm *vm)
7171

7272
int load_guest(struct vm *vm, struct vcpu *vcpu)
7373
{
74-
int ret = 0;
74+
int32_t ret = 0;
7575
void *hva;
7676
struct run_context *cur_context =
7777
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context];
@@ -102,7 +102,7 @@ int load_guest(struct vm *vm, struct vcpu *vcpu)
102102

103103
int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
104104
{
105-
int ret = 0;
105+
int32_t ret = 0;
106106
void *hva;
107107
struct run_context *cur_context =
108108
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context];
@@ -127,7 +127,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
127127
kernel_entry_offset += 512;
128128

129129
vm->sw.kernel_info.kernel_entry_addr =
130-
(void *)((unsigned long)vm->sw.kernel_info.kernel_load_addr
130+
(void *)((uint64_t)vm->sw.kernel_info.kernel_load_addr
131131
+ kernel_entry_offset);
132132
if (is_vcpu_bsp(vcpu)) {
133133
/* Set VCPU entry point to kernel entry */
@@ -176,7 +176,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
176176
* remained 1G pages" for reserving.
177177
*/
178178
if (is_vm0(vm) && check_mmu_1gb_support(PTT_HOST)) {
179-
int reserving_1g_pages;
179+
int32_t reserving_1g_pages;
180180

181181
#ifdef CONFIG_REMAIN_1G_PAGES
182182
reserving_1g_pages = (e820_mem.total_mem_size >> 30) -

hypervisor/include/arch/x86/cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ extern struct cpuinfo_x86 boot_cpu_data;
257257
/* Function prototypes */
258258
void cpu_dead(uint32_t logical_id);
259259
void trampoline_start16(void);
260-
int hv_main(uint16_t cpu_id);
260+
int32_t hv_main(uint16_t cpu_id);
261261
bool is_vapic_supported(void);
262262
bool is_vapic_intr_delivery_supported(void);
263263
bool is_vapic_virt_reg_supported(void);

hypervisor/include/arch/x86/guest/guest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum {
3434

3535
struct vhm_request;
3636

37-
int acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req);
37+
int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req);
3838
void get_req_info(char *str, int str_max);
3939

4040
/*

0 commit comments

Comments
 (0)