Skip to content

Commit cfc3811

Browse files
junjiemao1lijinxia
authored andcommitted
HV: treewide: drop debug-only helpers in release build
There are multiple helpers for collecting info to be printed on the ACRN uart console. They are unreachable code in release builds in which the uart console is removed. To define a precise boundary for safety-related activities, this patch wraps the declarations and definitions to these helpers with "#ifdef HV_DEBUG" so that these unreachable APIs will be dropped in release builds. v1 -> v2: * Fix coding style: no empty lines between #ifdef and the wrapped code. * Also drop get_rte_info() in ioapic.c, which is solely used by get_ioapic_info(). Signed-off-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 8b1c5a7 commit cfc3811

File tree

12 files changed

+38
-6
lines changed

12 files changed

+38
-6
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ void ptdev_remove_msix_remapping(struct vm *vm, uint16_t virt_bdf,
902902
remove_msix_remapping(vm, virt_bdf, i);
903903
}
904904

905+
#ifdef HV_DEBUG
905906
static void get_entry_info(struct ptdev_remapping_info *entry, char *type,
906907
uint32_t *irq, uint32_t *vector, uint64_t *dest, bool *lvl_tm,
907908
int *pin, int *vpin, int *bdf, int *vbdf)
@@ -1004,3 +1005,4 @@ void get_ptdev_info(char *str, int str_max)
10041005

10051006
snprintf(str, size, "\r\n");
10061007
}
1008+
#endif /* HV_DEBUG */

hypervisor/arch/x86/guest/vioapic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ bool vioapic_get_rte(struct vm *vm, int pin, void *rte)
608608
return false;
609609
}
610610

611+
#ifdef HV_DEBUG
611612
void get_vioapic_info(char *str, int str_max, int vmid)
612613
{
613614
int pin, len, size = str_max, vector, delmode;
@@ -653,3 +654,4 @@ void get_vioapic_info(char *str, int str_max, int vmid)
653654
END:
654655
snprintf(str, size, "\r\n");
655656
}
657+
#endif /* HV_DEBUG */

hypervisor/arch/x86/ioapic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ void resume_ioapic(void)
414414
}
415415
}
416416

417+
#ifdef HV_DEBUG
417418
void get_rte_info(struct ioapic_rte *rte, bool *mask, bool *irr,
418419
bool *phys, int *delmode, bool *level, int *vector, uint32_t *dest)
419420
{
@@ -469,3 +470,4 @@ int get_ioapic_info(char *str, int str_max_len)
469470
snprintf(str, size, "\r\n");
470471
return 0;
471472
}
473+
#endif /* HV_DEBUG */

hypervisor/arch/x86/irq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ pri_register_handler(uint32_t irq,
664664
return common_register_handler(irq, &info);
665665
}
666666

667+
#ifdef HV_DEBUG
667668
void get_cpu_interrupt_info(char *str, int str_max)
668669
{
669670
uint16_t pcpu_id;
@@ -706,6 +707,7 @@ void get_cpu_interrupt_info(char *str, int str_max)
706707
}
707708
snprintf(str, size, "\r\n");
708709
}
710+
#endif /* HV_DEBUG */
709711

710712
int interrupt_init(uint32_t cpu_id)
711713
{

hypervisor/common/hv_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int32_t hv_main(uint16_t cpu_id)
141141
return 0;
142142
}
143143

144+
#ifdef HV_DEBUG
144145
void get_vmexit_profile(char *str, int str_max)
145146
{
146147
uint16_t cpu, i;
@@ -175,3 +176,4 @@ void get_vmexit_profile(char *str, int str_max)
175176
}
176177
snprintf(str, size, "\r\n");
177178
}
179+
#endif /* HV_DEBUG */

hypervisor/common/io_request.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
9696
return 0;
9797
}
9898

99+
#ifdef HV_DEBUG
99100
static void _get_req_info_(struct vhm_request *req, int *id, char *type,
100101
char *state, char *dir, long *addr, long *val)
101102
{
@@ -191,3 +192,4 @@ void get_req_info(char *str, int str_max)
191192
spinlock_release(&vm_list_lock);
192193
snprintf(str, size, "\r\n");
193194
}
195+
#endif /* HV_DEBUG */

hypervisor/include/arch/x86/guest/guest.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ enum {
3636
struct vhm_request;
3737

3838
int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req);
39-
void get_req_info(char *str, int str_max);
4039

4140
/*
4241
* VCPU related APIs
@@ -130,6 +129,11 @@ int copy_to_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
130129
uint32_t size, uint32_t *err_code);
131130

132131
uint32_t create_guest_init_gdt(struct vm *vm, uint32_t *limit);
132+
133+
#ifdef HV_DEBUG
134+
void get_req_info(char *str, int str_max);
135+
#endif /* HV_DEBUG */
136+
133137
#endif /* !ASSEMBLER */
134138

135139
#endif /* GUEST_H*/

hypervisor/include/arch/x86/guest/vioapic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ bool vioapic_get_rte(struct vm *vm, int pin, void *rte);
5353
int vioapic_mmio_access_handler(struct vcpu *vcpu, struct mem_io *mmio,
5454
void *handler_private_data);
5555

56+
#ifdef HV_DEBUG
5657
void get_vioapic_info(char *str, int str_max, int vmid);
58+
#endif /* HV_DEBUG */
59+
5760
#endif

hypervisor/include/arch/x86/ioapic.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#define GSI_SET_RTE(irq, rte) ioapic_set_rte((irq), (rte))
2121

2222
void setup_ioapic_irq(void);
23-
int get_ioapic_info(char *str, int str_max_len);
2423

2524
bool irq_is_gsi(uint32_t irq);
2625
uint32_t irq_gsi_num(void);
@@ -36,4 +35,9 @@ void resume_ioapic(void);
3635

3736
extern uint16_t legacy_irq_to_pin[];
3837
extern uint16_t pic_ioapic_pin_map[];
38+
39+
#ifdef HV_DEBUG
40+
int get_ioapic_info(char *str, int str_max_len);
41+
#endif /* HV_DEBUG */
42+
3943
#endif /* IOAPIC_H */

hypervisor/include/arch/x86/irq.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ int init_default_irqs(uint16_t cpu);
7474

7575
void dispatch_interrupt(struct intr_excp_ctx *ctx);
7676

77-
void get_cpu_interrupt_info(char *str, int str_max);
78-
7977
void setup_notification(void);
8078

8179
typedef void (*spurious_handler_t)(uint32_t vector);
@@ -110,4 +108,9 @@ int acrn_handle_pending_request(struct vcpu *vcpu);
110108
int interrupt_init(uint32_t logical_id);
111109

112110
void cancel_event_injection(struct vcpu *vcpu);
111+
112+
#ifdef HV_DEBUG
113+
void get_cpu_interrupt_info(char *str, int str_max);
114+
#endif /* HV_DEBUG */
115+
113116
#endif /* ARCH_IRQ_H */

0 commit comments

Comments
 (0)