mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-07 09:41:30 +00:00
HV:x86:fix "expression is not Boolean"
MISRA C explicit required expression should be boolean when in branch statements (if,while...). Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -60,7 +60,7 @@ static int is_guest_irq_enabled(struct vcpu *vcpu)
|
||||
/* Read the RFLAGS of the guest */
|
||||
guest_rflags = cur_context->rflags;
|
||||
/* Check the RFLAGS[IF] bit first */
|
||||
if (guest_rflags & HV_ARCH_VCPU_RFLAGS_IF) {
|
||||
if ((guest_rflags & HV_ARCH_VCPU_RFLAGS_IF) != 0U) {
|
||||
/* Interrupts are allowed */
|
||||
/* Check for temporarily disabled interrupts */
|
||||
guest_state = exec_vmread(VMX_GUEST_INTERRUPTIBILITY_INFO);
|
||||
@@ -157,7 +157,7 @@ static int vcpu_do_pending_extint(struct vcpu *vcpu)
|
||||
/* check if there is valid interrupt from vPIC, if yes just inject it */
|
||||
/* PIC only connect with primary CPU */
|
||||
primary = get_primary_vcpu(vm);
|
||||
if (vm->vpic && vcpu == primary) {
|
||||
if ((vm->vpic != NULL) && vcpu == primary) {
|
||||
|
||||
vpic_pending_intr(vcpu->vm, &vector);
|
||||
if (vector <= NR_MAX_VECTOR) {
|
||||
@@ -234,7 +234,7 @@ int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector,
|
||||
|
||||
vcpu->arch_vcpu.exception_info.exception = vector;
|
||||
|
||||
if (exception_type[vector] & EXCEPTION_ERROR_CODE_VALID)
|
||||
if ((exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) != 0U)
|
||||
vcpu->arch_vcpu.exception_info.error = err_code;
|
||||
else
|
||||
vcpu->arch_vcpu.exception_info.error = 0;
|
||||
@@ -244,7 +244,7 @@ int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector,
|
||||
|
||||
static void _vcpu_inject_exception(struct vcpu *vcpu, uint32_t vector)
|
||||
{
|
||||
if (exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) {
|
||||
if ((exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) != 0U) {
|
||||
exec_vmwrite(VMX_ENTRY_EXCEPTION_ERROR_CODE,
|
||||
vcpu->arch_vcpu.exception_info.error);
|
||||
}
|
||||
@@ -314,7 +314,7 @@ int interrupt_window_vmexit_handler(struct vcpu *vcpu)
|
||||
|
||||
TRACE_2L(TRC_VMEXIT_INTERRUPT_WINDOW, 0, 0);
|
||||
|
||||
if (!vcpu)
|
||||
if (vcpu == NULL)
|
||||
return -1;
|
||||
|
||||
if (vcpu_pending_request(vcpu)) {
|
||||
@@ -341,7 +341,7 @@ int external_interrupt_vmexit_handler(struct vcpu *vcpu)
|
||||
struct intr_excp_ctx ctx;
|
||||
|
||||
intr_info = exec_vmread(VMX_EXIT_INT_INFO);
|
||||
if ((!(intr_info & VMX_INT_INFO_VALID)) ||
|
||||
if (((intr_info & VMX_INT_INFO_VALID) == 0U) ||
|
||||
(((intr_info & VMX_INT_TYPE_MASK) >> 8)
|
||||
!= VMX_INT_TYPE_EXT_INT)) {
|
||||
pr_err("Invalid VM exit interrupt info:%x", intr_info);
|
||||
@@ -383,7 +383,8 @@ int acrn_handle_pending_request(struct vcpu *vcpu)
|
||||
|
||||
/* handling cancelled event injection when vcpu is switched out */
|
||||
if (vcpu->arch_vcpu.inject_event_pending) {
|
||||
if (vcpu->arch_vcpu.inject_info.intr_info & (EXCEPTION_ERROR_CODE_VALID << 8))
|
||||
if ((vcpu->arch_vcpu.inject_info.intr_info &
|
||||
(EXCEPTION_ERROR_CODE_VALID << 8)) != 0U)
|
||||
exec_vmwrite(VMX_ENTRY_EXCEPTION_ERROR_CODE,
|
||||
vcpu->arch_vcpu.inject_info.error_code);
|
||||
|
||||
@@ -396,7 +397,7 @@ int acrn_handle_pending_request(struct vcpu *vcpu)
|
||||
|
||||
/* SDM Vol 3 - table 6-2, inject high priority exception before
|
||||
* maskable hardware interrupt */
|
||||
if (vcpu_inject_hi_exception(vcpu))
|
||||
if (vcpu_inject_hi_exception(vcpu) != 0)
|
||||
goto INTR_WIN;
|
||||
|
||||
/* inject NMI before maskable hardware interrupt */
|
||||
@@ -415,14 +416,14 @@ int acrn_handle_pending_request(struct vcpu *vcpu)
|
||||
* - external interrupt, if IF clear, will keep in IDT_VEC_INFO_FIELD
|
||||
* at next vm exit?
|
||||
*/
|
||||
if (vcpu->arch_vcpu.idt_vectoring_info & VMX_INT_INFO_VALID) {
|
||||
if ((vcpu->arch_vcpu.idt_vectoring_info & VMX_INT_INFO_VALID) != 0U) {
|
||||
exec_vmwrite(VMX_ENTRY_INT_INFO_FIELD,
|
||||
vcpu->arch_vcpu.idt_vectoring_info);
|
||||
goto INTR_WIN;
|
||||
}
|
||||
|
||||
/* Guest interruptable or not */
|
||||
if (is_guest_irq_enabled(vcpu)) {
|
||||
if (is_guest_irq_enabled(vcpu) != 0) {
|
||||
/* Inject external interrupt first */
|
||||
if (bitmap_test_and_clear(ACRN_REQUEST_EXTINT,
|
||||
pending_req_bits)) {
|
||||
@@ -441,7 +442,7 @@ int acrn_handle_pending_request(struct vcpu *vcpu)
|
||||
}
|
||||
|
||||
/* SDM Vol3 table 6-2, inject lowpri exception */
|
||||
if (vcpu_inject_lo_exception(vcpu))
|
||||
if (vcpu_inject_lo_exception(vcpu) != 0)
|
||||
goto INTR_WIN;
|
||||
|
||||
INTR_WIN:
|
||||
@@ -471,10 +472,10 @@ void cancel_event_injection(struct vcpu *vcpu)
|
||||
* The event will be re-injected in next acrn_handle_pending_request
|
||||
* call.
|
||||
*/
|
||||
if (intinfo & VMX_INT_INFO_VALID) {
|
||||
if ((intinfo & VMX_INT_INFO_VALID) != 0U) {
|
||||
vcpu->arch_vcpu.inject_event_pending = true;
|
||||
|
||||
if (intinfo & (EXCEPTION_ERROR_CODE_VALID << 8))
|
||||
if ((intinfo & (EXCEPTION_ERROR_CODE_VALID << 8)) != 0U)
|
||||
vcpu->arch_vcpu.inject_info.error_code =
|
||||
exec_vmread(VMX_ENTRY_EXCEPTION_ERROR_CODE);
|
||||
|
||||
@@ -502,13 +503,13 @@ int exception_vmexit_handler(struct vcpu *vcpu)
|
||||
|
||||
/* Obtain VM-Exit information field pg 2912 */
|
||||
intinfo = exec_vmread(VMX_EXIT_INT_INFO);
|
||||
if (intinfo & VMX_INT_INFO_VALID) {
|
||||
if ((intinfo & VMX_INT_INFO_VALID) != 0U) {
|
||||
exception_vector = intinfo & 0xFF;
|
||||
/* Check if exception caused by the guest is a HW exception.
|
||||
* If the exit occurred due to a HW exception obtain the
|
||||
* error code to be conveyed to get via the stack
|
||||
*/
|
||||
if (intinfo & VMX_INT_INFO_ERR_CODE_VALID) {
|
||||
if ((intinfo & VMX_INT_INFO_ERR_CODE_VALID) != 0U) {
|
||||
int_err_code = exec_vmread(VMX_EXIT_INT_ERROR_CODE);
|
||||
|
||||
/* get current privilege level and fault address */
|
||||
|
||||
Reference in New Issue
Block a user