mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
HV: treewide: fix violations of coding guideline C-TY-27 & C-TY-28
The coding guideline rules C-TY-27 and C-TY-28, combined, requires that assignment and arithmetic operations shall be applied only on operands of the same kind. This patch either adds explicit type casts or adjust types of variables to align the types of operands. The only semantic change introduced by this patch is the promotion of the second argument of set_vmcs_bit() and clear_vmcs_bit() to uint64_t (formerly uint32_t). This avoids clear_vmcs_bit() to accidentally clears the upper 32 bits of the requested VMCS field. Other than that, this patch has no semantic change. Specifically this patch is not meant to fix buggy narrowing operations, only to make these operations explicit. Tracked-On: #6776 Signed-off-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -16,7 +16,7 @@ static bool is_allocated_to_prelaunched_vm(struct pci_pdev *pdev)
|
||||
{
|
||||
bool found = false;
|
||||
uint16_t vmid;
|
||||
uint32_t pci_idx;
|
||||
uint16_t pci_idx;
|
||||
struct acrn_vm_config *vm_config;
|
||||
struct acrn_vm_pci_dev_config *dev_config;
|
||||
|
||||
|
@@ -833,7 +833,7 @@ void ptirq_remove_msix_remapping(const struct acrn_vm *vm, uint16_t phys_bdf,
|
||||
void ptirq_remove_configured_intx_remappings(const struct acrn_vm *vm)
|
||||
{
|
||||
const struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
uint32_t i;
|
||||
uint16_t i;
|
||||
|
||||
for (i = 0; i < vm_config->pt_intx_num; i++) {
|
||||
ptirq_remove_intx_remapping(vm, vm_config->pt_intx[i].virt_gsi, false);
|
||||
|
@@ -207,7 +207,7 @@ static int32_t local_gva2gpa_pae(struct acrn_vcpu *vcpu, struct page_walk_info *
|
||||
addr = get_pae_pdpt_addr(pw_info->top_entry);
|
||||
base = (uint64_t *)gpa2hva(vcpu->vm, addr);
|
||||
if (base != NULL) {
|
||||
index = (gva >> 30U) & 0x3UL;
|
||||
index = (uint32_t)gva >> 30U;
|
||||
stac();
|
||||
entry = base[index];
|
||||
clac();
|
||||
|
@@ -342,7 +342,7 @@ static bool prelaunched_vm_sleep_io_write(struct acrn_vcpu *vcpu, uint16_t addr,
|
||||
* SLP_TYPx fields programmed with the values from the \_S5 object
|
||||
*/
|
||||
slp_type = (v >> 2U) & 0x7U;
|
||||
slp_en = (v >> 5U) & 0x1U;
|
||||
slp_en = ((v >> 5U) & 0x1U) != 0U;
|
||||
|
||||
if (slp_en && (slp_type == 5U)) {
|
||||
get_vm_lock(vm);
|
||||
|
@@ -37,7 +37,7 @@ uint64_t find_space_from_ve820(struct acrn_vm *vm, uint32_t size, uint64_t min_a
|
||||
end = round_page_down(entry->baseaddr + entry->length);
|
||||
length = (end > start) ? (end - start) : 0UL;
|
||||
|
||||
if ((entry->type == E820_TYPE_RAM) && (length >= round_size)
|
||||
if ((entry->type == E820_TYPE_RAM) && (length >= (uint64_t)round_size)
|
||||
&& (end > round_min_addr) && (start < round_max_addr)) {
|
||||
if (((start >= min_addr) && ((start + round_size) <= min(end, round_max_addr)))
|
||||
|| ((start < min_addr) && ((min_addr + round_size) <= min(end, round_max_addr)))) {
|
||||
@@ -137,7 +137,8 @@ static void filter_mem_from_service_vm_e820(struct acrn_vm *vm, uint64_t start_p
|
||||
*/
|
||||
void create_service_vm_e820(struct acrn_vm *vm)
|
||||
{
|
||||
uint16_t vm_id, i;
|
||||
uint16_t vm_id;
|
||||
uint32_t i;
|
||||
uint64_t hv_start_pa = hva2hpa((void *)(get_hv_image_base()));
|
||||
uint64_t hv_end_pa = hv_start_pa + get_hv_ram_size();
|
||||
uint32_t entries_count = get_e820_entries_count();
|
||||
|
@@ -671,8 +671,8 @@ int32_t create_vm(uint16_t vm_id, uint64_t pcpu_bitmap, struct acrn_vm_config *v
|
||||
}
|
||||
|
||||
if (status == 0) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < vm_config->pt_intx_num; i++) {
|
||||
uint16_t i;
|
||||
for (i = 0U; i < vm_config->pt_intx_num; i++) {
|
||||
status = ptirq_add_intx_remapping(vm, vm_config->pt_intx[i].virt_gsi,
|
||||
vm_config->pt_intx[i].phys_gsi, false);
|
||||
if (status != 0) {
|
||||
|
@@ -291,7 +291,7 @@ static void enable_msr_interception(uint8_t *bitmap, uint32_t msr_arg, uint32_t
|
||||
}
|
||||
|
||||
msr &= 0x1FFFU;
|
||||
msr_bit = 1U << (msr & 0x7U);
|
||||
msr_bit = (uint8_t)(1U << (msr & 0x7U));
|
||||
msr_index = msr >> 3U;
|
||||
|
||||
if ((mode & INTERCEPT_READ) == INTERCEPT_READ) {
|
||||
|
@@ -275,8 +275,8 @@ static inline void fixup_idt(const struct host_idt_descriptor *idtd)
|
||||
entry_hi_32 = idt_desc[i].rsvd;
|
||||
idt_desc[i].rsvd = 0U;
|
||||
idt_desc[i].offset_63_32 = entry_hi_32;
|
||||
idt_desc[i].high32.bits.offset_31_16 = entry_lo_32 >> 16U;
|
||||
idt_desc[i].low32.bits.offset_15_0 = entry_lo_32 & 0xffffUL;
|
||||
idt_desc[i].high32.bits.offset_31_16 = (uint16_t)(entry_lo_32 >> 16U);
|
||||
idt_desc[i].low32.bits.offset_15_0 = (uint16_t)entry_lo_32;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include <logmsg.h>
|
||||
#include <misc_cfg.h>
|
||||
|
||||
static uint32_t hv_ram_size;
|
||||
static uint64_t hv_ram_size;
|
||||
static void *ppt_mmu_pml4_addr;
|
||||
static uint8_t sanitized_page[PAGE_SIZE] __aligned(PAGE_SIZE);
|
||||
|
||||
@@ -152,7 +152,7 @@ void invept(const void *eptp)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_hv_ram_size(void)
|
||||
uint64_t get_hv_ram_size(void)
|
||||
{
|
||||
return hv_ram_size;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ void init_paging(void)
|
||||
const struct abi_mmap *p_mmap = abi->mmap_entry;
|
||||
|
||||
pr_dbg("HV MMU Initialization");
|
||||
hv_ram_size = (uint32_t)(uint64_t)&ld_ram_size;
|
||||
hv_ram_size = (uint64_t)&ld_ram_size;
|
||||
|
||||
init_sanitized_page((uint64_t *)sanitized_page, hva2hpa_early(sanitized_page));
|
||||
|
||||
|
@@ -500,7 +500,7 @@ static struct dmar_drhd_rt *ioapic_to_dmaru(uint16_t ioapic_id, union pci_bdf *s
|
||||
dmar_unit = &dmar_drhd_units[j];
|
||||
for (i = 0U; i < dmar_unit->drhd->dev_cnt; i++) {
|
||||
if ((dmar_unit->drhd->devices[i].type == ACPI_DMAR_SCOPE_TYPE_IOAPIC) &&
|
||||
(dmar_unit->drhd->devices[i].id == ioapic_id)) {
|
||||
((uint16_t)dmar_unit->drhd->devices[i].id == ioapic_id)) {
|
||||
sid->fields.devfun = dmar_unit->drhd->devices[i].devfun;
|
||||
sid->fields.bus = dmar_unit->drhd->devices[i].bus;
|
||||
found = true;
|
||||
@@ -815,7 +815,7 @@ static void dmar_fault_handler(uint32_t irq, void *data)
|
||||
{
|
||||
struct dmar_drhd_rt *dmar_unit = (struct dmar_drhd_rt *)data;
|
||||
uint32_t fsr;
|
||||
uint32_t index;
|
||||
uint16_t index;
|
||||
uint32_t record_reg_offset;
|
||||
struct dmar_entry fault_record;
|
||||
int32_t loop = 0;
|
||||
|
Reference in New Issue
Block a user