Skip to content

Commit 46d1982

Browse files
Shawnshhwenlingz
authored andcommitted
HV:vcpu fix "Pointer param should be declared pointer to const"
Fix violations whose parameter can be read-only. This patch only fix the parameter whose name is vcpu. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent ea32c34 commit 46d1982

File tree

15 files changed

+31
-31
lines changed

15 files changed

+31
-31
lines changed

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static uint32_t get_vmcs_field(enum cpu_reg_name ident)
322322
* @pre ((reg <= CPU_REG_LAST) && (reg >= CPU_REG_FIRST))
323323
* @pre ((reg != CPU_REG_CR2) && (reg != CPU_REG_IDTR) && (reg != CPU_REG_GDTR))
324324
*/
325-
static uint64_t vm_get_register(struct vcpu *vcpu, enum cpu_reg_name reg)
325+
static uint64_t vm_get_register(const struct vcpu *vcpu, enum cpu_reg_name reg)
326326
{
327327
uint64_t reg_val = 0UL;
328328

@@ -492,7 +492,7 @@ static int vie_calculate_gla(enum vm_cpu_mode cpu_mode, enum cpu_reg_name seg,
492492
return 0;
493493
}
494494

495-
static int mmio_read(struct vcpu *vcpu, uint64_t *rval)
495+
static int mmio_read(const struct vcpu *vcpu, uint64_t *rval)
496496
{
497497
if (vcpu == NULL) {
498498
return -EINVAL;
@@ -538,7 +538,7 @@ static void vie_calc_bytereg(const struct instr_emul_vie *vie,
538538
}
539539
}
540540

541-
static uint8_t vie_read_bytereg(struct vcpu *vcpu, const struct instr_emul_vie *vie)
541+
static uint8_t vie_read_bytereg(const struct vcpu *vcpu, const struct instr_emul_vie *vie)
542542
{
543543
int lhbr;
544544
uint64_t val;
@@ -883,7 +883,7 @@ static int emulate_movx(struct vcpu *vcpu, const struct instr_emul_vie *vie)
883883
*
884884
* It's only used by MOVS/STO
885885
*/
886-
static void get_gva_si_nocheck(struct vcpu *vcpu, uint8_t addrsize,
886+
static void get_gva_si_nocheck(const struct vcpu *vcpu, uint8_t addrsize,
887887
enum cpu_reg_name seg, uint64_t *gva)
888888
{
889889
uint64_t val;
@@ -2343,7 +2343,7 @@ int decode_instruction(struct vcpu *vcpu)
23432343
return (int)(emul_ctxt->vie.opsize);
23442344
}
23452345

2346-
int emulate_instruction(struct vcpu *vcpu)
2346+
int emulate_instruction(const struct vcpu *vcpu)
23472347
{
23482348
struct instr_emul_ctxt *ctxt = &per_cpu(g_inst_ctxt, vcpu->pcpu_id);
23492349

hypervisor/arch/x86/guest/instr_emul.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct instr_emul_ctxt {
193193
struct vcpu *vcpu;
194194
};
195195

196-
int emulate_instruction(struct vcpu *vcpu);
196+
int emulate_instruction(const struct vcpu *vcpu);
197197
int decode_instruction(struct vcpu *vcpu);
198198

199199
#endif

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
vm_sw_loader_t vm_sw_loader;
1212

13-
inline uint64_t vcpu_get_gpreg(struct vcpu *vcpu, uint32_t reg)
13+
inline uint64_t vcpu_get_gpreg(const struct vcpu *vcpu, uint32_t reg)
1414
{
15-
struct run_context *ctx =
15+
const struct run_context *ctx =
1616
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].run_ctx;
1717

1818
return ctx->guest_cpu_regs.longs[reg];
@@ -146,7 +146,7 @@ inline void vcpu_set_cr4(struct vcpu *vcpu, uint64_t val)
146146
vmx_write_cr4(vcpu, val);
147147
}
148148

149-
inline uint64_t vcpu_get_pat_ext(struct vcpu *vcpu)
149+
inline uint64_t vcpu_get_pat_ext(const struct vcpu *vcpu)
150150
{
151151
return vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].
152152
ext_ctx.ia32_pat;

hypervisor/arch/x86/io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void dm_emulate_pio_post(struct vcpu *vcpu)
6868
* either a previous call to emulate_io() returning 0 or the corresponding VHM
6969
* request having transferred to the COMPLETE state.
7070
*/
71-
void emulate_mmio_post(struct vcpu *vcpu, const struct io_request *io_req)
71+
void emulate_mmio_post(const struct vcpu *vcpu, const struct io_request *io_req)
7272
{
7373
const struct mmio_request *mmio_req = &io_req->reqs.mmio;
7474

@@ -173,7 +173,7 @@ void emulate_io_post(struct vcpu *vcpu)
173173
* @return -EIO - The request spans multiple devices and cannot be emulated.
174174
*/
175175
int32_t
176-
hv_emulate_pio(struct vcpu *vcpu, struct io_request *io_req)
176+
hv_emulate_pio(const struct vcpu *vcpu, struct io_request *io_req)
177177
{
178178
int32_t status = -ENODEV;
179179
uint16_t port, size;

hypervisor/arch/x86/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void flush_vpid_global(void)
167167
local_invvpid(VMX_VPID_TYPE_ALL_CONTEXT, 0U, 0UL);
168168
}
169169

170-
void invept(struct vcpu *vcpu)
170+
void invept(const struct vcpu *vcpu)
171171
{
172172
struct invept_desc desc = {0};
173173

hypervisor/arch/x86/mtrr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ get_subrange_start_of_fixed_mtrr(uint32_t index, uint32_t subrange_id)
6363
get_subrange_size_of_fixed_mtrr(index));
6464
}
6565

66-
static inline bool is_mtrr_enabled(struct vcpu *vcpu)
66+
static inline bool is_mtrr_enabled(const struct vcpu *vcpu)
6767
{
6868
return (vcpu->mtrr.def_type.bits.enable != 0U);
6969
}
7070

71-
static inline bool is_fixed_range_mtrr_enabled(struct vcpu *vcpu)
71+
static inline bool is_fixed_range_mtrr_enabled(const struct vcpu *vcpu)
7272
{
7373
return ((vcpu->mtrr.cap.bits.fix != 0U) &&
7474
(vcpu->mtrr.def_type.bits.fixed_enable != 0U));
7575
}
7676

77-
static inline uint8_t get_default_memory_type(struct vcpu *vcpu)
77+
static inline uint8_t get_default_memory_type(const struct vcpu *vcpu)
7878
{
7979
return (uint8_t)(vcpu->mtrr.def_type.bits.type);
8080
}
@@ -154,7 +154,7 @@ static uint32_t update_ept(struct vm *vm, uint64_t start,
154154
return attr;
155155
}
156156

157-
static void update_ept_mem_type(struct vcpu *vcpu)
157+
static void update_ept_mem_type(const struct vcpu *vcpu)
158158
{
159159
uint8_t type;
160160
uint64_t start, size;
@@ -236,9 +236,9 @@ void mtrr_wrmsr(struct vcpu *vcpu, uint32_t msr, uint64_t value)
236236
}
237237
}
238238

239-
uint64_t mtrr_rdmsr(struct vcpu *vcpu, uint32_t msr)
239+
uint64_t mtrr_rdmsr(const struct vcpu *vcpu, uint32_t msr)
240240
{
241-
struct mtrr_state *mtrr = &vcpu->mtrr;
241+
const struct mtrr_state *mtrr = &vcpu->mtrr;
242242
uint64_t ret = 0UL;
243243
uint32_t index;
244244

hypervisor/arch/x86/virq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int vcpu_inject_vlapic_int(struct vcpu *vcpu)
148148
return 0;
149149
}
150150

151-
static int vcpu_do_pending_extint(struct vcpu *vcpu)
151+
static int vcpu_do_pending_extint(const struct vcpu *vcpu)
152152
{
153153
struct vm *vm;
154154
struct vcpu *primary;

hypervisor/arch/x86/vmx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static void init_cr0_cr4_host_mask(void)
250250
pr_dbg("CR4 mask value: 0x%016llx", cr4_host_mask);
251251
}
252252

253-
uint64_t vmx_rdmsr_pat(struct vcpu *vcpu)
253+
uint64_t vmx_rdmsr_pat(const struct vcpu *vcpu)
254254
{
255255
/*
256256
* note: if context->cr0.CD is set, the actual value in guest's
@@ -288,7 +288,7 @@ int vmx_wrmsr_pat(struct vcpu *vcpu, uint64_t value)
288288
return 0;
289289
}
290290

291-
static void load_pdptrs(struct vcpu *vcpu)
291+
static void load_pdptrs(const struct vcpu *vcpu)
292292
{
293293
uint64_t guest_cr3 = exec_vmread(VMX_GUEST_CR3);
294294
/* TODO: check whether guest cr3 is valid */
@@ -945,7 +945,7 @@ static void init_exec_ctrl(struct vcpu *vcpu)
945945
exec_vmwrite(VMX_CR3_TARGET_3, 0UL);
946946
}
947947

948-
static void init_entry_ctrl(__unused struct vcpu *vcpu)
948+
static void init_entry_ctrl(__unused const struct vcpu *vcpu)
949949
{
950950
uint32_t value32;
951951

hypervisor/common/schedule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static struct vcpu *select_next_vcpu(uint16_t pcpu_id)
9696
return vcpu;
9797
}
9898

99-
void make_reschedule_request(struct vcpu *vcpu)
99+
void make_reschedule_request(const struct vcpu *vcpu)
100100
{
101101
struct sched_context *ctx = &per_cpu(sched_ctx, vcpu->pcpu_id);
102102

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ struct vcpu_dump {
248248
int str_max;
249249
};
250250

251-
static inline bool is_vcpu_bsp(struct vcpu *vcpu)
251+
static inline bool is_vcpu_bsp(const struct vcpu *vcpu)
252252
{
253253
return (vcpu->vcpu_id == BOOT_CPU_ID);
254254
}
@@ -266,7 +266,7 @@ vcpu_vlapic(struct vcpu *vcpu)
266266
}
267267

268268
/* External Interfaces */
269-
uint64_t vcpu_get_gpreg(struct vcpu *vcpu, uint32_t reg);
269+
uint64_t vcpu_get_gpreg(const struct vcpu *vcpu, uint32_t reg);
270270
void vcpu_set_gpreg(struct vcpu *vcpu, uint32_t reg, uint64_t val);
271271
uint64_t vcpu_get_rip(struct vcpu *vcpu);
272272
void vcpu_set_rip(struct vcpu *vcpu, uint64_t val);
@@ -282,7 +282,7 @@ uint64_t vcpu_get_cr2(struct vcpu *vcpu);
282282
void vcpu_set_cr2(struct vcpu *vcpu, uint64_t val);
283283
uint64_t vcpu_get_cr4(struct vcpu *vcpu);
284284
void vcpu_set_cr4(struct vcpu *vcpu, uint64_t val);
285-
uint64_t vcpu_get_pat_ext(struct vcpu *vcpu);
285+
uint64_t vcpu_get_pat_ext(const struct vcpu *vcpu);
286286
void vcpu_set_pat_ext(struct vcpu *vcpu, uint64_t val);
287287
void set_vcpu_regs(struct vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs);
288288
void reset_vcpu_regs(struct vcpu *vcpu);

0 commit comments

Comments
 (0)