Skip to content

Commit aa2b2d8

Browse files
mingqiangchiwenlingz
authored andcommitted
hv: change several APIs to void type
Change these 6 APIs to void type: init_default_irqs interrupt_init early_init_lapic init_lapic init_iommu destroy_iommu_domain It has checked the argument of destroy_iommu_domain in shutdown_vm, then no need to check it again inside destroy_iommu_domain. Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 8017ebd commit aa2b2d8

File tree

8 files changed

+24
-58
lines changed

8 files changed

+24
-58
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,7 @@ static void bsp_boot_post(void)
544544

545545
ASSERT(get_cpu_id() == BOOT_CPU_ID, "");
546546

547-
if (init_iommu() != 0) {
548-
pr_fatal("%s, init iommu failed\n", __func__);
549-
return;
550-
}
547+
init_iommu();
551548

552549
console_setup_timer();
553550

hypervisor/arch/x86/irq.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@ uint32_t dev_to_vector(struct dev_handler_node *node)
365365
return node->desc->vector;
366366
}
367367

368-
int init_default_irqs(uint16_t cpu_id)
368+
void init_default_irqs(uint16_t cpu_id)
369369
{
370370
if (cpu_id != BOOT_CPU_ID) {
371-
return 0;
371+
return;
372372
}
373373

374374
init_irq_desc();
@@ -377,8 +377,6 @@ int init_default_irqs(uint16_t cpu_id)
377377
disable_pic_irq();
378378
setup_ioapic_irq();
379379
init_softirq();
380-
381-
return 0;
382380
}
383381

384382
void dispatch_exception(struct intr_excp_ctx *ctx)
@@ -731,28 +729,14 @@ void get_cpu_interrupt_info(char *str, int str_max)
731729
}
732730
#endif /* HV_DEBUG */
733731

734-
int interrupt_init(uint16_t pcpu_id)
732+
void interrupt_init(uint16_t pcpu_id)
735733
{
736734
struct host_idt_descriptor *idtd = &HOST_IDTR;
737-
int status;
738735

739736
set_idt(idtd);
740-
741-
status = init_lapic(pcpu_id);
742-
ASSERT(status == 0, "lapic init failed");
743-
if (status != 0) {
744-
return -ENODEV;
745-
}
746-
747-
status = init_default_irqs(pcpu_id);
748-
ASSERT(status == 0, "irqs init failed");
749-
if (status != 0) {
750-
return -ENODEV;
751-
}
752-
737+
init_lapic(pcpu_id);
738+
init_default_irqs(pcpu_id);
753739
#ifndef CONFIG_EFI_STUB
754740
CPU_IRQ_ENABLE();
755741
#endif
756-
757-
return status;
758742
}

hypervisor/arch/x86/lapic.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void map_lapic(void)
180180
lapic_info.xapic.vaddr = HPA2HVA(lapic_info.xapic.paddr);
181181
}
182182

183-
int early_init_lapic(void)
183+
void early_init_lapic(void)
184184
{
185185
/* Get local APIC base address */
186186
lapic_base_msr.value = msr_read(MSR_IA32_APIC_BASE);
@@ -207,11 +207,9 @@ int early_init_lapic(void)
207207
ASSERT(lapic_base_msr.fields.x2APIC_enable == 0U,
208208
"Disable X2APIC in BIOS");
209209
}
210-
211-
return 0;
212210
}
213211

214-
int init_lapic(uint16_t pcpu_id)
212+
void init_lapic(uint16_t pcpu_id)
215213
{
216214
/* Set the Logical Destination Register */
217215
write_lapic_reg32(LAPIC_LOGICAL_DESTINATION_REGISTER,
@@ -236,8 +234,6 @@ int init_lapic(uint16_t pcpu_id)
236234

237235
/* Ensure there are no ISR bits set. */
238236
clear_lapic_isr();
239-
240-
return 0;
241237
}
242238

243239
void save_lapic(struct lapic_regs *regs)

hypervisor/arch/x86/vtd.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,25 +169,18 @@ static struct list_head iommu_domains;
169169
static void dmar_register_hrhd(struct dmar_drhd_rt *drhd_rt);
170170
static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus,
171171
uint8_t devfun);
172-
static int register_hrhd_units(void)
172+
static void register_hrhd_units(void)
173173
{
174174
struct dmar_info *info = get_dmar_info();
175175
struct dmar_drhd_rt *drhd_rt;
176176
uint32_t i;
177177

178-
if (info == NULL) {
179-
pr_warn("vtd: no dmar units found");
180-
return -1;
181-
}
182-
183178
for (i = 0U; i < info->drhd_count; i++) {
184179
drhd_rt = calloc(1, sizeof(struct dmar_drhd_rt));
185180
ASSERT(drhd_rt != NULL, "");
186181
drhd_rt->drhd = &info->drhd_units[i];
187182
dmar_register_hrhd(drhd_rt);
188183
}
189-
190-
return 0;
191184
}
192185

193186
static uint32_t iommu_read32(struct dmar_drhd_rt *dmar_uint, uint32_t offset)
@@ -910,12 +903,11 @@ struct iommu_domain *create_iommu_domain(uint16_t vm_id, uint64_t translation_ta
910903
return domain;
911904
}
912905

913-
int destroy_iommu_domain(struct iommu_domain *domain)
906+
/**
907+
* @pre domain != NULL
908+
*/
909+
void destroy_iommu_domain(struct iommu_domain *domain)
914910
{
915-
if (domain == NULL) {
916-
return 1;
917-
}
918-
919911
/* currently only support ept */
920912
if (!domain->is_tt_ept) {
921913
ASSERT(false, "translation_table is not EPT!");
@@ -929,8 +921,6 @@ int destroy_iommu_domain(struct iommu_domain *domain)
929921

930922
free_domain_id(domain->dom_id);
931923
free(domain);
932-
933-
return 0;
934924
}
935925

936926
static int add_iommu_device(struct iommu_domain *domain, uint16_t segment,
@@ -1258,7 +1248,7 @@ void resume_iommu(void)
12581248
}
12591249
}
12601250

1261-
int init_iommu(void)
1251+
void init_iommu(void)
12621252
{
12631253
uint16_t bus;
12641254
uint16_t devfun;
@@ -1268,9 +1258,7 @@ int init_iommu(void)
12681258

12691259
spinlock_init(&domain_lock);
12701260

1271-
if (register_hrhd_units() != 0) {
1272-
return -1;
1273-
}
1261+
register_hrhd_units();
12741262

12751263
host_domain = create_host_domain();
12761264

@@ -1282,6 +1270,4 @@ int init_iommu(void)
12821270
}
12831271

12841272
enable_iommu();
1285-
1286-
return 0;
12871273
}

hypervisor/boot/dmar_parse.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ int parse_dmar_table(void)
322322
return 0;
323323
}
324324

325+
/**
326+
* @post return != NULL
327+
*/
325328
struct dmar_info *get_dmar_info(void)
326329
{
327330
parse_dmar_table();

hypervisor/include/arch/x86/irq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int common_handler_edge(struct irq_desc *desc, void *handler_data);
7070
int common_dev_handler_level(struct irq_desc *desc, void *handler_data);
7171
int quick_handler_nolock(struct irq_desc *desc, void *handler_data);
7272

73-
int init_default_irqs(uint16_t cpu);
73+
void init_default_irqs(uint16_t cpu);
7474

7575
void dispatch_exception(struct intr_excp_ctx *ctx);
7676
void dispatch_interrupt(struct intr_excp_ctx *ctx);
@@ -106,7 +106,7 @@ int exception_vmexit_handler(struct vcpu *vcpu);
106106
int interrupt_window_vmexit_handler(struct vcpu *vcpu);
107107
int external_interrupt_vmexit_handler(struct vcpu *vcpu);
108108
int acrn_handle_pending_request(struct vcpu *vcpu);
109-
int interrupt_init(uint16_t pcpu_id);
109+
void interrupt_init(uint16_t pcpu_id);
110110

111111
void cancel_event_injection(struct vcpu *vcpu);
112112

hypervisor/include/arch/x86/lapic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ union lapic_id {
134134

135135
void write_lapic_reg32(uint32_t offset, uint32_t value);
136136
void save_lapic(struct lapic_regs *regs);
137-
int early_init_lapic(void);
138-
int init_lapic(uint16_t cpu_id);
137+
void early_init_lapic(void);
138+
void init_lapic(uint16_t cpu_id);
139139
void send_lapic_eoi(void);
140140
uint8_t get_cur_lapic_id(void);
141141
int send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,

hypervisor/include/arch/x86/vtd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ struct iommu_domain *create_iommu_domain(uint16_t vm_id,
480480
uint64_t translation_table, uint32_t addr_width);
481481

482482
/* Destroy the iommu domain */
483-
int destroy_iommu_domain(struct iommu_domain *domain);
483+
void destroy_iommu_domain(struct iommu_domain *domain);
484484

485485
/* Enable translation of iommu*/
486486
void enable_iommu(void);
@@ -495,5 +495,5 @@ void suspend_iommu(void);
495495
void resume_iommu(void);
496496

497497
/* iommu initialization */
498-
int init_iommu(void);
498+
void init_iommu(void);
499499
#endif

0 commit comments

Comments
 (0)