Skip to content

Commit 3bfa695

Browse files
taoyuhongwenlingz
authored andcommitted
hv: virq: refine vcpu_inject_vlapic_int() has more than one exit point
The MISRA-C Standards suggests procedures to be single exit. Tracked-On: #861 Acked-by: Eddie Dong <eddie.dong@intel.com> Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
1 parent 9c97f6b commit 3bfa695

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

hypervisor/arch/x86/virq.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,32 @@ static int32_t vcpu_inject_vlapic_int(struct acrn_vcpu *vcpu)
119119
* through vmcs.
120120
*/
121121
if (is_apicv_intr_delivery_supported()) {
122-
return -1;
123-
}
124-
125-
/* Query vLapic to get vector to inject */
126-
ret = vlapic_pending_intr(vlapic, &vector);
127-
128-
/*
129-
* From the Intel SDM, Volume 3, 6.3.2 Section "Maskable
130-
* Hardware Interrupts":
131-
* - maskable interrupt vectors [16,255] can be delivered
132-
* through the local APIC.
133-
*/
134-
if (ret == 0) {
135-
return 0;
136-
}
122+
ret = -1;
123+
} else {
124+
/* Query vLapic to get vector to inject */
125+
ret = vlapic_pending_intr(vlapic, &vector);
126+
if (ret != 0) {
127+
/*
128+
* From the Intel SDM, Volume 3, 6.3.2 Section "Maskable
129+
* Hardware Interrupts":
130+
* - maskable interrupt vectors [16,255] can be delivered
131+
* through the local APIC.
132+
*/
133+
134+
if (!(vector >= 16U && vector <= 255U)) {
135+
dev_dbg(ACRN_DBG_INTR, "invalid vector %d from local APIC", vector);
136+
ret = -1;
137+
} else {
138+
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, VMX_INT_INFO_VALID |
139+
(vector & 0xFFU));
137140

138-
if (!(vector >= 16U && vector <= 255U)) {
139-
dev_dbg(ACRN_DBG_INTR, "invalid vector %d from local APIC",
140-
vector);
141-
return -1;
141+
vlapic_intr_accepted(vlapic, vector);
142+
ret = 0;
143+
}
144+
}
142145
}
143146

144-
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, VMX_INT_INFO_VALID |
145-
(vector & 0xFFU));
146-
147-
vlapic_intr_accepted(vlapic, vector);
148-
return 0;
147+
return ret;
149148
}
150149

151150
static int32_t vcpu_do_pending_extint(const struct acrn_vcpu *vcpu)

0 commit comments

Comments
 (0)