From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3971971034978166893==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: [PATCH] KVM: nVMX: fix boolreturn.cocci warnings Date: Fri, 25 Dec 2020 13:21:46 +0800 Message-ID: <20201225052146.GA10930@bfe89680bc64> In-Reply-To: <202012251312.US2x2MXz-lkp@intel.com> List-Id: --===============3971971034978166893== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: kernel test robot arch/x86/kvm/vmx.c:6902:10-11: WARNING: return of 0/1 in function 'nested_v= mx_check_io_bitmaps' with return type bool arch/x86/kvm/vmx.c:7061:9-10: WARNING: return of 0/1 in function 'nested_vm= x_exit_handled' with return type bool arch/x86/kvm/vmx.c:6978:11-12: WARNING: return of 0/1 in function 'nested_v= mx_exit_handled_cr' with return type bool arch/x86/kvm/vmx.c:6932:9-10: WARNING: return of 0/1 in function 'nested_vm= x_exit_handled_msr' with return type bool arch/x86/kvm/vmx.c:6436:9-10: WARNING: return of 0/1 in function 'vmcs12_re= ad_any' with return type bool Return statements in functions returning bool should use true/false instead of 1/0. Generated by: scripts/coccinelle/misc/boolreturn.cocci Fixes: 738e997121b6 ("KVM: nVMX: Refactor IO bitmap checks into helper func= tion") CC: Oliver Upton Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://android.googlesource.com/kernel/goldfish android-3.18 head: 44cdfba60e00fb12583fb922a00288fd5a82df33 commit: 738e997121b65e50c1d4681bfea0f288b6d89df2 [567/586] KVM: nVMX: Refac= tor IO bitmap checks into helper function vmx.c | 80 +++++++++++++++++++++++++++++++++----------------------------= ----- 1 file changed, 40 insertions(+), 40 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -6433,25 +6433,25 @@ static inline bool vmcs12_read_any(struc char *p; = if (offset < 0) - return 0; + return false; = p =3D ((char *)(get_vmcs12(vcpu))) + offset; = switch (vmcs_field_type(field)) { case VMCS_FIELD_TYPE_NATURAL_WIDTH: *ret =3D *((natural_width *)p); - return 1; + return true; case VMCS_FIELD_TYPE_U16: *ret =3D *((u16 *)p); - return 1; + return true; case VMCS_FIELD_TYPE_U32: *ret =3D *((u32 *)p); - return 1; + return true; case VMCS_FIELD_TYPE_U64: *ret =3D *((u64 *)p); - return 1; + return true; default: - return 0; /* can never happen. */ + return false; /* can never happen. */ } } = @@ -6899,21 +6899,21 @@ bool nested_vmx_check_io_bitmaps(struct else if (port < 0x10000) bitmap =3D vmcs12->io_bitmap_b; else - return 1; + return true; bitmap +=3D (port & 0x7fff) / 8; = if (last_bitmap !=3D bitmap) if (kvm_read_guest(vcpu->kvm, bitmap, &b, 1)) - return 1; + return true; if (b & (1 << (port & 7))) - return 1; + return true; = port++; size--; last_bitmap =3D bitmap; } = - return 0; + return false; } = /* @@ -6929,7 +6929,7 @@ static bool nested_vmx_exit_handled_msr( gpa_t bitmap; = if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS)) - return 1; + return true; = /* * The MSR_BITMAP page is divided into four 1024-byte bitmaps, @@ -6948,10 +6948,10 @@ static bool nested_vmx_exit_handled_msr( if (msr_index < 1024*8) { unsigned char b; if (kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1)) - return 1; + return true; return 1 & (b >> (msr_index & 7)); } else - return 1; /* let L1 handle the wrong parameter */ + return true; /* let L1 handle the wrong parameter */ } = /* @@ -6975,7 +6975,7 @@ static bool nested_vmx_exit_handled_cr(s case 0: if (vmcs12->cr0_guest_host_mask & (val ^ vmcs12->cr0_read_shadow)) - return 1; + return true; break; case 3: if ((vmcs12->cr3_target_count >=3D 1 && @@ -6986,37 +6986,37 @@ static bool nested_vmx_exit_handled_cr(s vmcs12->cr3_target_value2 =3D=3D val) || (vmcs12->cr3_target_count >=3D 4 && vmcs12->cr3_target_value3 =3D=3D val)) - return 0; + return false; if (nested_cpu_has(vmcs12, CPU_BASED_CR3_LOAD_EXITING)) - return 1; + return true; break; case 4: if (vmcs12->cr4_guest_host_mask & (vmcs12->cr4_read_shadow ^ val)) - return 1; + return true; break; case 8: if (nested_cpu_has(vmcs12, CPU_BASED_CR8_LOAD_EXITING)) - return 1; + return true; break; } break; case 2: /* clts */ if ((vmcs12->cr0_guest_host_mask & X86_CR0_TS) && (vmcs12->cr0_read_shadow & X86_CR0_TS)) - return 1; + return true; break; case 1: /* mov from cr */ switch (cr) { case 3: if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_CR3_STORE_EXITING) - return 1; + return true; break; case 8: if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_CR8_STORE_EXITING) - return 1; + return true; break; } break; @@ -7028,14 +7028,14 @@ static bool nested_vmx_exit_handled_cr(s val =3D (exit_qualification >> LMSW_SOURCE_DATA_SHIFT) & 0x0f; if (vmcs12->cr0_guest_host_mask & 0xe & (val ^ vmcs12->cr0_read_shadow)) - return 1; + return true; if ((vmcs12->cr0_guest_host_mask & 0x1) && !(vmcs12->cr0_read_shadow & 0x1) && (val & 0x1)) - return 1; + return true; break; } - return 0; + return false; } = /* @@ -7058,41 +7058,41 @@ static bool nested_vmx_exit_handled(stru KVM_ISA_VMX); = if (vmx->nested.nested_run_pending) - return 0; + return false; = if (unlikely(vmx->fail)) { pr_info_ratelimited("%s failed vm entry %x\n", __func__, vmcs_read32(VM_INSTRUCTION_ERROR)); - return 1; + return true; } = switch (exit_reason) { case EXIT_REASON_EXCEPTION_NMI: if (!is_exception(intr_info)) - return 0; + return false; else if (is_page_fault(intr_info)) return enable_ept; else if (is_no_device(intr_info) && !(vmcs12->guest_cr0 & X86_CR0_TS)) - return 0; + return false; return vmcs12->exception_bitmap & (1u << (intr_info & INTR_INFO_VECTOR_MASK)); case EXIT_REASON_EXTERNAL_INTERRUPT: - return 0; + return false; case EXIT_REASON_TRIPLE_FAULT: - return 1; + return true; case EXIT_REASON_PENDING_INTERRUPT: return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING); case EXIT_REASON_NMI_WINDOW: return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING); case EXIT_REASON_TASK_SWITCH: - return 1; + return true; case EXIT_REASON_CPUID: - return 1; + return true; case EXIT_REASON_HLT: return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING); case EXIT_REASON_INVD: - return 1; + return true; case EXIT_REASON_INVLPG: return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING); case EXIT_REASON_RDPMC: @@ -7109,7 +7109,7 @@ static bool nested_vmx_exit_handled(stru * VMX instructions trap unconditionally. This allows L1 to * emulate them for its L2 guest, i.e., allows 3-level nesting! */ - return 1; + return true; case EXIT_REASON_CR_ACCESS: return nested_vmx_exit_handled_cr(vcpu, vmcs12); case EXIT_REASON_DR_ACCESS: @@ -7120,7 +7120,7 @@ static bool nested_vmx_exit_handled(stru case EXIT_REASON_MSR_WRITE: return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason); case EXIT_REASON_INVALID_STATE: - return 1; + return true; case EXIT_REASON_MWAIT_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING); case EXIT_REASON_MONITOR_INSTRUCTION: @@ -7130,7 +7130,7 @@ static bool nested_vmx_exit_handled(stru nested_cpu_has2(vmcs12, SECONDARY_EXEC_PAUSE_LOOP_EXITING); case EXIT_REASON_MCE_DURING_VMENTRY: - return 0; + return false; case EXIT_REASON_TPR_BELOW_THRESHOLD: return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW); case EXIT_REASON_APIC_ACCESS: @@ -7143,7 +7143,7 @@ static bool nested_vmx_exit_handled(stru * missing in the guest EPT table (EPT12), the EPT violation * will be injected with nested_ept_inject_page_fault() */ - return 0; + return false; case EXIT_REASON_EPT_MISCONFIG: /* * L2 never uses directly L1's EPT, but rather L0's own EPT @@ -7151,13 +7151,13 @@ static bool nested_vmx_exit_handled(stru * (EPT on EPT). So any problems with the structure of the * table is L0's fault. */ - return 0; + return false; case EXIT_REASON_WBINVD: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING); case EXIT_REASON_XSETBV: - return 1; + return true; default: - return 1; + return true; } } =20 --===============3971971034978166893==--