Skip to content

Commit bdcc3ae

Browse files
mingqiangchilijinxia
authored andcommitted
hv: fixed compiling warning
removed some unnecessary variables and functions. v1-->v2: Replace div-by-zero with an inline ASM code Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 40745d9 commit bdcc3ae

File tree

12 files changed

+13
-72
lines changed

12 files changed

+13
-72
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static void cpu_xsave_init(void);
5454
static void set_current_cpu_id(uint16_t pcpu_id);
5555
static void print_hv_banner(void);
5656
static uint16_t get_cpu_id_from_lapic_id(uint8_t lapic_id);
57-
static void pcpu_sync_sleep(uint64_t *sync, uint64_t mask_bit);
5857
int ibrs_type;
5958
static uint64_t start_tsc __attribute__((__section__(".bss_noinit")));
6059

@@ -533,7 +532,6 @@ void cpu_secondary_init(void)
533532

534533
static void cpu_secondary_post(void)
535534
{
536-
int ret;
537535

538536
/* Release secondary boot spin-lock to allow one of the next CPU(s) to
539537
* perform this common initialization

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static uint32_t get_vmcs_field(enum cpu_reg_name ident)
310310
*/
311311
static uint64_t vm_get_register(struct vcpu *vcpu, enum cpu_reg_name reg)
312312
{
313-
uint64_t reg_val;
313+
uint64_t reg_val = 0UL;
314314

315315
if ((reg >= CPU_REG_GENERAL_FIRST) && (reg <= CPU_REG_GENERAL_LAST)) {
316316
reg_val = vcpu_get_gpreg(vcpu, reg);
@@ -363,7 +363,7 @@ static void vm_set_register(struct vcpu *vcpu, enum cpu_reg_name reg,
363363
*/
364364
static void vm_get_seg_desc(enum cpu_reg_name seg, struct seg_desc *desc)
365365
{
366-
struct seg_desc tdesc;
366+
struct seg_desc tdesc = {0UL, 0U, 0U};
367367

368368
/* tdesc->access != 0xffffffffU in this function */
369369
encode_vmcs_seg_desc(seg, &tdesc);

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,6 @@ static void enable_msr_interception(uint8_t *bitmap, uint32_t msr_arg)
5151
write_map[(msr>>3U)] = value;
5252
}
5353

54-
/* not used now just leave it for some cases it may be used as API*/
55-
static void disable_msr_interception(uint8_t *bitmap, uint32_t msr_arg)
56-
{
57-
uint8_t *read_map;
58-
uint8_t *write_map;
59-
uint8_t value;
60-
uint32_t msr = msr_arg;
61-
/* low MSR */
62-
if (msr < 0x1FFFU) {
63-
read_map = bitmap;
64-
write_map = bitmap + 2048;
65-
} else if ((msr >= 0xc0000000U) && (msr <= 0xc0001fffU)) {
66-
read_map = bitmap + 1024;
67-
write_map = bitmap + 3072;
68-
} else {
69-
pr_err("Invalid MSR");
70-
return;
71-
}
72-
73-
msr &= 0x1FFFU;
74-
value = read_map[(msr>>3U)];
75-
value &= ~(1U<<(msr%8U));
76-
/* right now we trap for both r/w */
77-
read_map[(msr>>3U)] = value;
78-
write_map[(msr>>3U)] = value;
79-
}
80-
8154
void init_msr_emulation(struct vcpu *vcpu)
8255
{
8356
uint32_t i;

hypervisor/arch/x86/ioapic.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,6 @@ void setup_ioapic_irq(void)
391391
ASSERT(nr_gsi <= NR_MAX_GSI, "GSI table overflow");
392392
}
393393

394-
static void dump_ioapic(void)
395-
{
396-
uint32_t irq;
397-
398-
for (irq = 0U; irq < nr_gsi; irq++) {
399-
void *addr = gsi_table[irq].addr;
400-
uint8_t pin = gsi_table[irq].pin;
401-
union ioapic_rte rte;
402-
403-
ioapic_get_rte_entry(addr, pin, &rte);
404-
dev_dbg(ACRN_DBG_IRQ, "DUMP: irq:%d pin:%hhu rte:%lx",
405-
irq, pin, rte.full);
406-
}
407-
}
408-
409394
void suspend_ioapic(void)
410395
{
411396
uint8_t ioapic_id, ioapic_pin;

hypervisor/arch/x86/notify.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
static uint32_t notification_irq = IRQ_INVALID;
1010

11-
static volatile uint64_t smp_call_mask = 0UL;
11+
static uint64_t smp_call_mask = 0UL;
1212

1313
/* run in interrupt context */
1414
static int kick_notification(__unused uint32_t irq, __unused void *data)
@@ -98,11 +98,3 @@ void setup_notification(void)
9898
dev_dbg(ACRN_DBG_PTIRQ, "NOTIFY: irq[%d] setup vector %x",
9999
notification_irq, irq_to_vector(notification_irq));
100100
}
101-
102-
static void cleanup_notification(void)
103-
{
104-
if (notification_irq != IRQ_INVALID) {
105-
free_irq(notification_irq);
106-
}
107-
notification_irq = IRQ_INVALID;
108-
}

hypervisor/arch/x86/timer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void timer_init(void)
194194
if (pcpu_id == BOOT_CPU_ID) {
195195
register_softirq(SOFTIRQ_TIMER, timer_softirq);
196196

197-
if (request_timer_irq(tsc_deadline_handler, name) < 0) {
197+
if (request_timer_irq((irq_action_t)tsc_deadline_handler, name)
198+
< 0) {
198199
pr_err("Timer setup failed");
199200
return;
200201
}

hypervisor/arch/x86/vmx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ static void init_guest_state(struct vcpu *vcpu)
741741
static void init_host_state(__unused struct vcpu *vcpu)
742742
{
743743
uint16_t value16;
744-
uint32_t value32;
745744
uint64_t value64;
746745
uint64_t value;
747746
uint64_t trbase;
@@ -800,7 +799,6 @@ static void init_host_state(__unused struct vcpu *vcpu)
800799
/* TODO: Should guest GDTB point to host GDTB ? */
801800
/* Obtain the current global descriptor table base */
802801
asm volatile ("sgdt %0":"=m"(gdtb)::"memory");
803-
value32 = gdtb.limit;
804802

805803
if (((gdtb.base >> 47U) & 0x1UL) != 0UL) {
806804
gdtb.base |= 0xffff000000000000UL;

hypervisor/boot/acpi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ biosacpi_search_rsdp(char *base, int length)
115115
if (strncmp(rsdp->signature, ACPI_SIG_RSDP,
116116
strnlen_s(ACPI_SIG_RSDP, 8)) == 0) {
117117
cp = (uint8_t *)rsdp;
118-
sum = NULL;
118+
sum = 0U;
119119
for (idx = 0; idx < RSDP_CHECKSUM_LENGTH; idx++) {
120120
sum += *(cp + idx);
121121
}
122122

123-
if (sum != NULL) {
123+
if (sum != 0U) {
124124
continue;
125125
}
126126

hypervisor/bsp/uefi/uefi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void efi_init(void)
104104

105105
vm_sw_loader = uefi_sw_loader;
106106

107-
spurious_handler = efi_spurious_handler;
107+
spurious_handler = (spurious_handler_t)efi_spurious_handler;
108108

109109
save_lapic(&uefi_lapic_regs);
110110

hypervisor/debug/shell.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,10 @@ static int shell_trigger_crash(int argc, char **argv)
916916
(void)argv;
917917
snprintf(str, MAX_STR_SIZE, "trigger crash, divide by 0 ...\r\n");
918918
shell_puts(str);
919-
snprintf(str, MAX_STR_SIZE, "%d\r", 1/0);
919+
920+
asm("movl $0x1, %eax");
921+
asm("movl $0x0, %ecx");
922+
asm("idiv %ecx");
920923

921924
return 0;
922925
}

0 commit comments

Comments
 (0)