diff mbox

[5/5] KVM: PPC: Book3S: Eliminate some unnecessary checks

Message ID 1511427665-21660-6-git-send-email-paulus@ozlabs.org (mailing list archive)
State New, archived
Headers show

Commit Message

Paul Mackerras Nov. 23, 2017, 9:01 a.m. UTC
In an excess of caution, commit 6f63e81bda98 ("KVM: PPC: Book3S: Add
MMIO emulation for FP and VSX instructions", 2017-02-21) included
checks for the case that vcpu->arch.mmio_vsx_copy_nums is less than
zero, even though its type is u8.  This causes a Coverity warning,
so we remove the check for < 0.  We also adjust the associated
comment to be more accurate ("4 or less" rather than "less than 4").

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 arch/powerpc/kvm/powerpc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Darren Kenny Nov. 23, 2017, 10:14 a.m. UTC | #1
Makes sense to me.

On Thu, Nov 23, 2017 at 08:01:05PM +1100, Paul Mackerras wrote:
>In an excess of caution, commit 6f63e81bda98 ("KVM: PPC: Book3S: Add
>MMIO emulation for FP and VSX instructions", 2017-02-21) included
>checks for the case that vcpu->arch.mmio_vsx_copy_nums is less than
>zero, even though its type is u8.  This causes a Coverity warning,
>so we remove the check for < 0.  We also adjust the associated
>comment to be more accurate ("4 or less" rather than "less than 4").
>
>Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

>---
> arch/powerpc/kvm/powerpc.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
>diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
>index 6b6c53c..c2c7ef3 100644
>--- a/arch/powerpc/kvm/powerpc.c
>+++ b/arch/powerpc/kvm/powerpc.c
>@@ -1101,11 +1101,9 @@ int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> {
> 	enum emulation_result emulated = EMULATE_DONE;
>
>-	/* Currently, mmio_vsx_copy_nums only allowed to be less than 4 */
>-	if ( (vcpu->arch.mmio_vsx_copy_nums > 4) ||
>-		(vcpu->arch.mmio_vsx_copy_nums < 0) ) {
>+	/* Currently, mmio_vsx_copy_nums only allowed to be 4 or less */
>+	if (vcpu->arch.mmio_vsx_copy_nums > 4)
> 		return EMULATE_FAIL;
>-	}
>
> 	while (vcpu->arch.mmio_vsx_copy_nums) {
> 		emulated = __kvmppc_handle_load(run, vcpu, rt, bytes,
>@@ -1247,11 +1245,9 @@ int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>
> 	vcpu->arch.io_gpr = rs;
>
>-	/* Currently, mmio_vsx_copy_nums only allowed to be less than 4 */
>-	if ( (vcpu->arch.mmio_vsx_copy_nums > 4) ||
>-		(vcpu->arch.mmio_vsx_copy_nums < 0) ) {
>+	/* Currently, mmio_vsx_copy_nums only allowed to be 4 or less */
>+	if (vcpu->arch.mmio_vsx_copy_nums > 4)
> 		return EMULATE_FAIL;
>-	}
>
> 	while (vcpu->arch.mmio_vsx_copy_nums) {
> 		if (kvmppc_get_vsr_data(vcpu, rs, &val) == -1)
>-- 
>2.7.4
>
diff mbox

Patch

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6b6c53c..c2c7ef3 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1101,11 +1101,9 @@  int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
 {
 	enum emulation_result emulated = EMULATE_DONE;
 
-	/* Currently, mmio_vsx_copy_nums only allowed to be less than 4 */
-	if ( (vcpu->arch.mmio_vsx_copy_nums > 4) ||
-		(vcpu->arch.mmio_vsx_copy_nums < 0) ) {
+	/* Currently, mmio_vsx_copy_nums only allowed to be 4 or less */
+	if (vcpu->arch.mmio_vsx_copy_nums > 4)
 		return EMULATE_FAIL;
-	}
 
 	while (vcpu->arch.mmio_vsx_copy_nums) {
 		emulated = __kvmppc_handle_load(run, vcpu, rt, bytes,
@@ -1247,11 +1245,9 @@  int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
 
 	vcpu->arch.io_gpr = rs;
 
-	/* Currently, mmio_vsx_copy_nums only allowed to be less than 4 */
-	if ( (vcpu->arch.mmio_vsx_copy_nums > 4) ||
-		(vcpu->arch.mmio_vsx_copy_nums < 0) ) {
+	/* Currently, mmio_vsx_copy_nums only allowed to be 4 or less */
+	if (vcpu->arch.mmio_vsx_copy_nums > 4)
 		return EMULATE_FAIL;
-	}
 
 	while (vcpu->arch.mmio_vsx_copy_nums) {
 		if (kvmppc_get_vsr_data(vcpu, rs, &val) == -1)