mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-09 12:49:24 +00:00
HV: Add const qualifiers where required
V1: In order to better comply with MISRA C, add const qualifiers whereeven required. In the patch, these are being added to pointers which are normally used in "get" functions. V2: Corrected the issues in the patch pointed by Junjie in his review comments. Moved the const qualifiers to the correct places. Removed some changes which are not needed. V3: Updated patch comment. This modifies a subset of all the functions which might need constant qualifiers for the their parameters. This is not and exhaustive patch. This only targets obvious places where we can use the const qualifier. More changes will be submitted in future patches, if required. Signed-off-by: Arindam Roy <arindam.roy@intel.com>
This commit is contained in:
@@ -89,7 +89,7 @@ static const struct cpu_state_table {
|
||||
}
|
||||
};
|
||||
|
||||
static int get_state_tbl_idx(char *cpuname)
|
||||
static int get_state_tbl_idx(const char *cpuname)
|
||||
{
|
||||
int i;
|
||||
int count = ARRAY_SIZE(cpu_state_tbl);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
extern bool x2apic_enabled;
|
||||
|
||||
static inline struct vcpuid_entry *find_vcpuid_entry(struct vcpu *vcpu,
|
||||
static inline struct vcpuid_entry *find_vcpuid_entry(const struct vcpu *vcpu,
|
||||
uint32_t leaf_arg, uint32_t subleaf)
|
||||
{
|
||||
uint32_t i = 0U, nr, half;
|
||||
@@ -66,7 +66,7 @@ static inline struct vcpuid_entry *find_vcpuid_entry(struct vcpu *vcpu,
|
||||
}
|
||||
|
||||
static inline int set_vcpuid_entry(struct vm *vm,
|
||||
struct vcpuid_entry *entry)
|
||||
const struct vcpuid_entry *entry)
|
||||
{
|
||||
struct vcpuid_entry *tmp;
|
||||
size_t entry_size = sizeof(struct vcpuid_entry);
|
||||
@@ -293,7 +293,7 @@ int set_vcpuid_entries(struct vm *vm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void guest_cpuid(struct vcpu *vcpu,
|
||||
void guest_cpuid(const struct vcpu *vcpu,
|
||||
uint32_t *eax, uint32_t *ebx,
|
||||
uint32_t *ecx, uint32_t *edx)
|
||||
{
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#define ACRN_DBG_EPT 6U
|
||||
|
||||
static uint64_t find_next_table(uint32_t table_offset, void *table_base)
|
||||
static uint64_t find_next_table(uint32_t table_offset, const void *table_base)
|
||||
{
|
||||
uint64_t table_entry;
|
||||
uint64_t table_present;
|
||||
@@ -100,7 +100,7 @@ void destroy_ept(struct vm *vm)
|
||||
free_ept_mem(vm->arch_vm.m2p);
|
||||
}
|
||||
|
||||
uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size)
|
||||
uint64_t local_gpa2hpa(const struct vm *vm, uint64_t gpa, uint32_t *size)
|
||||
{
|
||||
uint64_t hpa = 0UL;
|
||||
uint64_t *pgentry, pg_size = 0UL;
|
||||
@@ -124,12 +124,12 @@ uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size)
|
||||
}
|
||||
|
||||
/* using return value 0 as failure, make sure guest will not use hpa 0 */
|
||||
uint64_t gpa2hpa(struct vm *vm, uint64_t gpa)
|
||||
uint64_t gpa2hpa(const struct vm *vm, uint64_t gpa)
|
||||
{
|
||||
return local_gpa2hpa(vm, gpa, NULL);
|
||||
}
|
||||
|
||||
uint64_t hpa2gpa(struct vm *vm, uint64_t hpa)
|
||||
uint64_t hpa2gpa(const struct vm *vm, uint64_t hpa)
|
||||
{
|
||||
uint64_t *pgentry, pg_size = 0UL;
|
||||
|
||||
@@ -251,7 +251,7 @@ int ept_misconfig_vmexit_handler(__unused struct vcpu *vcpu)
|
||||
return status;
|
||||
}
|
||||
|
||||
int ept_mr_add(struct vm *vm, uint64_t hpa_arg,
|
||||
int ept_mr_add(const struct vm *vm, uint64_t hpa_arg,
|
||||
uint64_t gpa_arg, uint64_t size, uint32_t prot_arg)
|
||||
{
|
||||
struct mem_map_params map_params;
|
||||
@@ -290,7 +290,7 @@ int ept_mr_add(struct vm *vm, uint64_t hpa_arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ept_mr_modify(struct vm *vm, uint64_t *pml4_page,
|
||||
int ept_mr_modify(const struct vm *vm, uint64_t *pml4_page,
|
||||
uint64_t gpa, uint64_t size,
|
||||
uint64_t prot_set, uint64_t prot_clr)
|
||||
{
|
||||
@@ -308,7 +308,7 @@ int ept_mr_modify(struct vm *vm, uint64_t *pml4_page,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ept_mr_del(struct vm *vm, uint64_t *pml4_page,
|
||||
int ept_mr_del(const struct vm *vm, uint64_t *pml4_page,
|
||||
uint64_t gpa, uint64_t size)
|
||||
{
|
||||
struct vcpu *vcpu;
|
||||
|
@@ -46,7 +46,7 @@ uint64_t vcpumask2pcpumask(struct vm *vm, uint64_t vdmask)
|
||||
return dmask;
|
||||
}
|
||||
|
||||
bool vm_lapic_disabled(struct vm *vm)
|
||||
bool vm_lapic_disabled(const struct vm *vm)
|
||||
{
|
||||
uint16_t i;
|
||||
struct vcpu *vcpu;
|
||||
@@ -276,7 +276,7 @@ int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t local_copy_gpa(struct vm *vm, void *h_ptr, uint64_t gpa,
|
||||
static inline uint32_t local_copy_gpa(const struct vm *vm, void *h_ptr, uint64_t gpa,
|
||||
uint32_t size, uint32_t fix_pg_size, bool cp_from_vm)
|
||||
{
|
||||
uint64_t hpa;
|
||||
@@ -308,7 +308,7 @@ static inline uint32_t local_copy_gpa(struct vm *vm, void *h_ptr, uint64_t gpa,
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline int copy_gpa(struct vm *vm, void *h_ptr_arg, uint64_t gpa_arg,
|
||||
static inline int copy_gpa(const struct vm *vm, void *h_ptr_arg, uint64_t gpa_arg,
|
||||
uint32_t size_arg, bool cp_from_vm)
|
||||
{
|
||||
void *h_ptr = h_ptr_arg;
|
||||
@@ -385,12 +385,12 @@ static inline int copy_gva(struct vcpu *vcpu, void *h_ptr_arg, uint64_t gva_arg,
|
||||
* - some other gpa from hypercall parameters, VHM should make sure it's
|
||||
* continuous
|
||||
*/
|
||||
int copy_from_gpa(struct vm *vm, void *h_ptr, uint64_t gpa, uint32_t size)
|
||||
int copy_from_gpa(const struct vm *vm, void *h_ptr, uint64_t gpa, uint32_t size)
|
||||
{
|
||||
return copy_gpa(vm, h_ptr, gpa, size, 1);
|
||||
}
|
||||
|
||||
int copy_to_gpa(struct vm *vm, void *h_ptr, uint64_t gpa, uint32_t size)
|
||||
int copy_to_gpa(const struct vm *vm, void *h_ptr, uint64_t gpa, uint32_t size)
|
||||
{
|
||||
return copy_gpa(vm, h_ptr, gpa, size, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user