Skip to content

Commit ea32c34

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

39 files changed

+149
-149
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
static inline struct ptdev_remapping_info *
1919
ptdev_lookup_entry_by_sid(uint32_t intr_type,
20-
union source_id *sid,const struct vm *vm)
20+
const union source_id *sid,const struct vm *vm)
2121
{
2222
struct ptdev_remapping_info *entry;
2323
struct list_head *pos;
@@ -38,12 +38,12 @@ ptdev_lookup_entry_by_sid(uint32_t intr_type,
3838
}
3939

4040
static inline bool
41-
is_entry_active(struct ptdev_remapping_info *entry)
41+
is_entry_active(const struct ptdev_remapping_info *entry)
4242
{
4343
return atomic_load32(&entry->active) == ACTIVE_FLAG;
4444
}
4545

46-
static bool ptdev_hv_owned_intx(const struct vm *vm, union source_id *virt_sid)
46+
static bool ptdev_hv_owned_intx(const struct vm *vm, const union source_id *virt_sid)
4747
{
4848
/* vm0 vuart pin is owned by hypervisor under debug version */
4949
if (is_vm0(vm) && (virt_sid->intx_id.pin == COM1_IRQ)) {
@@ -377,9 +377,9 @@ static void remove_intx_remapping(const struct vm *vm, uint8_t virt_pin, bool pi
377377
}
378378

379379
static void ptdev_intr_handle_irq(struct vm *vm,
380-
struct ptdev_remapping_info *entry)
380+
const struct ptdev_remapping_info *entry)
381381
{
382-
union source_id *virt_sid = &entry->virt_sid;
382+
const union source_id *virt_sid = &entry->virt_sid;
383383
switch (virt_sid->intx_id.src) {
384384
case PTDEV_VPIN_IOAPIC:
385385
{
@@ -790,7 +790,7 @@ void ptdev_remove_msix_remapping(const struct vm *vm, uint16_t virt_bdf,
790790

791791
#ifdef HV_DEBUG
792792
#define PTDEV_INVALID_PIN 0xffU
793-
static void get_entry_info(struct ptdev_remapping_info *entry, char *type,
793+
static void get_entry_info(const struct ptdev_remapping_info *entry, char *type,
794794
uint32_t *irq, uint32_t *vector, uint64_t *dest, bool *lvl_tm,
795795
uint8_t *pin, uint8_t *vpin, uint32_t *bdf, uint32_t *vbdf)
796796
{

hypervisor/arch/x86/guest/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ enum vm_paging_mode get_vcpu_paging_mode(struct vcpu *vcpu)
7272

7373
/* TODO: Add code to check for Revserved bits, SMAP and PKE when do translation
7474
* during page walk */
75-
static int local_gva2gpa_common(struct vcpu *vcpu, struct page_walk_info *pw_info,
75+
static int local_gva2gpa_common(struct vcpu *vcpu, const struct page_walk_info *pw_info,
7676
uint64_t gva, uint64_t *gpa, uint32_t *err_code)
7777
{
7878
uint32_t i;

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static int mmio_write(struct vcpu *vcpu, uint64_t wval)
512512
return 0;
513513
}
514514

515-
static void vie_calc_bytereg(struct instr_emul_vie *vie,
515+
static void vie_calc_bytereg(const struct instr_emul_vie *vie,
516516
enum cpu_reg_name *reg, int *lhbr)
517517
{
518518
*lhbr = 0;
@@ -538,7 +538,7 @@ static void vie_calc_bytereg(struct instr_emul_vie *vie,
538538
}
539539
}
540540

541-
static uint8_t vie_read_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie)
541+
static uint8_t vie_read_bytereg(struct vcpu *vcpu, const struct instr_emul_vie *vie)
542542
{
543543
int lhbr;
544544
uint64_t val;
@@ -561,7 +561,7 @@ static uint8_t vie_read_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie)
561561
return reg_val;
562562
}
563563

564-
static void vie_write_bytereg(struct vcpu *vcpu, struct instr_emul_vie *vie,
564+
static void vie_write_bytereg(struct vcpu *vcpu, const struct instr_emul_vie *vie,
565565
uint8_t byte)
566566
{
567567
uint64_t origval, val, mask;
@@ -664,7 +664,7 @@ static uint64_t getcc(uint8_t opsize, uint64_t x, uint64_t y)
664664
}
665665
}
666666

667-
static int emulate_mov(struct vcpu *vcpu, struct instr_emul_vie *vie)
667+
static int emulate_mov(struct vcpu *vcpu, const struct instr_emul_vie *vie)
668668
{
669669
int error;
670670
uint8_t size;
@@ -780,7 +780,7 @@ static int emulate_mov(struct vcpu *vcpu, struct instr_emul_vie *vie)
780780
return error;
781781
}
782782

783-
static int emulate_movx(struct vcpu *vcpu, struct instr_emul_vie *vie)
783+
static int emulate_movx(struct vcpu *vcpu, const struct instr_emul_vie *vie)
784784
{
785785
int error;
786786
uint8_t size;
@@ -980,7 +980,7 @@ static int get_gva_di_check(struct vcpu *vcpu, struct instr_emul_vie *vie,
980980
* For MOVs instruction, we always check RDI during instruction decoding phase.
981981
* And access RSI without any check during instruction emulation phase.
982982
*/
983-
static int emulate_movs(struct vcpu *vcpu, struct instr_emul_vie *vie)
983+
static int emulate_movs(struct vcpu *vcpu, const struct instr_emul_vie *vie)
984984
{
985985
uint64_t src_gva, gpa, val = 0UL;
986986
uint64_t *dst_hva, *src_hva;
@@ -1067,7 +1067,7 @@ static int emulate_movs(struct vcpu *vcpu, struct instr_emul_vie *vie)
10671067
return error;
10681068
}
10691069

1070-
static int emulate_stos(struct vcpu *vcpu, struct instr_emul_vie *vie)
1070+
static int emulate_stos(struct vcpu *vcpu, const struct instr_emul_vie *vie)
10711071
{
10721072
int error, repeat;
10731073
uint8_t opsize = vie->opsize;
@@ -1121,7 +1121,7 @@ static int emulate_stos(struct vcpu *vcpu, struct instr_emul_vie *vie)
11211121
return 0;
11221122
}
11231123

1124-
static int emulate_test(struct vcpu *vcpu, struct instr_emul_vie *vie)
1124+
static int emulate_test(struct vcpu *vcpu, const struct instr_emul_vie *vie)
11251125
{
11261126
int error;
11271127
uint8_t size;
@@ -1187,7 +1187,7 @@ static int emulate_test(struct vcpu *vcpu, struct instr_emul_vie *vie)
11871187
return error;
11881188
}
11891189

1190-
static int emulate_and(struct vcpu *vcpu, struct instr_emul_vie *vie)
1190+
static int emulate_and(struct vcpu *vcpu, const struct instr_emul_vie *vie)
11911191
{
11921192
int error;
11931193
uint8_t size;
@@ -1275,7 +1275,7 @@ static int emulate_and(struct vcpu *vcpu, struct instr_emul_vie *vie)
12751275
return error;
12761276
}
12771277

1278-
static int emulate_or(struct vcpu *vcpu, struct instr_emul_vie *vie)
1278+
static int emulate_or(struct vcpu *vcpu, const struct instr_emul_vie *vie)
12791279
{
12801280
int error;
12811281
uint8_t size;
@@ -1366,7 +1366,7 @@ static int emulate_or(struct vcpu *vcpu, struct instr_emul_vie *vie)
13661366
return error;
13671367
}
13681368

1369-
static int emulate_cmp(struct vcpu *vcpu, struct instr_emul_vie *vie)
1369+
static int emulate_cmp(struct vcpu *vcpu, const struct instr_emul_vie *vie)
13701370
{
13711371
int error;
13721372
uint8_t size;
@@ -1458,7 +1458,7 @@ static int emulate_cmp(struct vcpu *vcpu, struct instr_emul_vie *vie)
14581458
return error;
14591459
}
14601460

1461-
static int emulate_sub(struct vcpu *vcpu, struct instr_emul_vie *vie)
1461+
static int emulate_sub(struct vcpu *vcpu, const struct instr_emul_vie *vie)
14621462
{
14631463
int error;
14641464
uint8_t size;
@@ -1512,7 +1512,7 @@ static int emulate_sub(struct vcpu *vcpu, struct instr_emul_vie *vie)
15121512
return error;
15131513
}
15141514

1515-
static int emulate_group1(struct vcpu *vcpu, struct instr_emul_vie *vie)
1515+
static int emulate_group1(struct vcpu *vcpu, const struct instr_emul_vie *vie)
15161516
{
15171517
int error;
15181518

@@ -1534,7 +1534,7 @@ static int emulate_group1(struct vcpu *vcpu, struct instr_emul_vie *vie)
15341534
return error;
15351535
}
15361536

1537-
static int emulate_bittest(struct vcpu *vcpu, struct instr_emul_vie *vie)
1537+
static int emulate_bittest(struct vcpu *vcpu, const struct instr_emul_vie *vie)
15381538
{
15391539
uint64_t val, rflags, bitmask;
15401540
int error;
@@ -1664,7 +1664,7 @@ static int vie_init(struct instr_emul_vie *vie, struct vcpu *vcpu)
16641664
return 0;
16651665
}
16661666

1667-
static int vie_peek(struct instr_emul_vie *vie, uint8_t *x)
1667+
static int vie_peek(const struct instr_emul_vie *vie, uint8_t *x)
16681668
{
16691669

16701670
if (vie->num_processed < vie->num_valid) {

hypervisor/arch/x86/guest/pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void pm1ab_io_write(__unused struct vm *vm, uint16_t addr, size_t width,
187187
}
188188

189189
static void
190-
register_gas_io_handler(struct vm *vm, struct acpi_generic_address *gas)
190+
register_gas_io_handler(struct vm *vm, const struct acpi_generic_address *gas)
191191
{
192192
uint8_t io_len[5] = {0, 1, 2, 4, 8};
193193
struct vm_io_range gas_io;

hypervisor/arch/x86/guest/ucode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ uint64_t get_microcode_version(void)
2727
* According to SDM vol 3 Table 9-7. If data_size field of uCode
2828
* header is zero, the ucode length is 2000
2929
*/
30-
static inline size_t get_ucode_data_size(struct ucode_header *uhdr)
30+
static inline size_t get_ucode_data_size(const struct ucode_header *uhdr)
3131
{
3232
return ((uhdr->data_size != 0U) ? uhdr->data_size : 2000U);
3333
}

0 commit comments

Comments
 (0)