From patchwork Wed Oct 25 02:29:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sundeep subbaraya X-Patchwork-Id: 10025753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 165B0601E8 for ; Wed, 25 Oct 2017 02:30:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F068E28AD1 for ; Wed, 25 Oct 2017 02:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4D9928AD6; Wed, 25 Oct 2017 02:30:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7B73B28AD2 for ; Wed, 25 Oct 2017 02:30:03 +0000 (UTC) Received: from localhost ([::1]:46241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7BSE-0006HV-Mv for patchwork-qemu-devel@patchwork.kernel.org; Tue, 24 Oct 2017 22:30:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7BRZ-0006HE-GF for qemu-devel@nongnu.org; Tue, 24 Oct 2017 22:29:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7BRW-0007Cl-Bp for qemu-devel@nongnu.org; Tue, 24 Oct 2017 22:29:21 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:52654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7BRW-0007CB-5p; Tue, 24 Oct 2017 22:29:18 -0400 Received: by mail-pf0-x241.google.com with SMTP id e64so21104552pfk.9; Tue, 24 Oct 2017 19:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=X1R6BR3c2quFfhE8WTfL1T5OX3rKqyjuMf6ZDBBUE4Q=; b=l2NGtsJbQcnOxDiDGsaQ9/O+gkERzm4cZiVf3eWzA1WVrzq8bZwyFq6otZ9BxbUiA1 LLDWzhE6sVyFZdof9kzmT6pJLeTs6F+66Afa4EpKHaEEVbTfUu3cpD90vNxYp+5UmbcV cr2AOL6A6AVgV/6GhEZNqwzXa3MDN/yK39ufbw+h4wodWFYXVY2ExT7eBGn+nRNx95Fx 5Uk41cFWNt0vW5VJ3oqDzwz4ii/HxaaJUgk+vjrOBTlbsfDQwnuYQ+tdBo7f2OGjzmbZ /9N1gP2zomsDT0jGLz5c5dN5hhOGfDT0xhdGRr2tMl0SNG354Ln+3idmSJx45ZvMHGTy ne/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=X1R6BR3c2quFfhE8WTfL1T5OX3rKqyjuMf6ZDBBUE4Q=; b=GffQMZFEn9AZGV9IDGwiTy/48R6QmuZJ+mLIjM/ZYA3DFbwVrCPdDLEhFeMZaDLcyr eZ59MJJ7P+vXQHqS9YP2PNZLyIjMx7y+QC0BgF8bjspK7KmgNvRABbGHW9WyRUvqTUbl wjSyQ/FZgLl2XXzsCTBslBzZJo7D4LJ21K+34d4z2Bfp38kCzcOOU1C/gIZUc8rjnDNq UQeTWQJZW5hOyjP2Q2TybGBN3jdFE3yrt9iFhxuTmqRMp8NKDl2sQb87BXQg6zzmHaEf 3YdnpEDJQsYXCugI3/+i6ZUAHor6MHRhYPSIIMPogmQaU2OKMLRpYNSTxLdDIEFyelS4 DxYQ== X-Gm-Message-State: AMCzsaVCzMpkVfwnwPcxRzFKaZz1vy/jlhS/0m78eBU+jznh2BGSQC4D X/FsLN5G7aHMKXNB6PmrdAo7EA== X-Google-Smtp-Source: ABhQp+SjuV149tRy5C7KH4VTwhBMIOmoOSiFnLKntgycvyqRNYyveSlw+0FSCh2Swn96T4kq/JeUPw== X-Received: by 10.84.131.1 with SMTP id 1mr529204pld.120.1508898556666; Tue, 24 Oct 2017 19:29:16 -0700 (PDT) Received: from localhost.localdomain ([183.82.194.3]) by smtp.gmail.com with ESMTPSA id x4sm2326142pfx.124.2017.10.24.19.29.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 19:29:16 -0700 (PDT) From: Subbaraya Sundeep To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 25 Oct 2017 07:59:04 +0530 Message-Id: <1508898544-10307-1-git-send-email-sundeep.lkml@gmail.com> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [Qemu devel V4 PATCH] msf2: Remove dead code reported by Coverity X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, crosthwaite.peter@gmail.com, f4bug@amsat.org, alistair23@gmail.com, Subbaraya Sundeep , darren.kenny@oracle.com, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fixed incorrect frame size mask, validated maximum frame size in spi_write and removed dead code. Signed-off-by: Subbaraya Sundeep Reviewed-by: Darren Kenny Reviewed-by: Alistair Francis --- v4: changed %d to %u while logging frame size error. v3: Added comment that [31:6] bits are reserved in R_SPI_DFSIZE register and logged incorrect value too in guest error(suggested by Darren). v2: else if -> else in set_fifodepth log guest error when frame size is more than 32 hw/ssi/mss-spi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c index 5a8e308..d60daba 100644 --- a/hw/ssi/mss-spi.c +++ b/hw/ssi/mss-spi.c @@ -76,9 +76,10 @@ #define C_BIGFIFO (1 << 29) #define C_RESET (1 << 31) -#define FRAMESZ_MASK 0x1F +#define FRAMESZ_MASK 0x3F #define FMCOUNT_MASK 0x00FFFF00 #define FMCOUNT_SHIFT 8 +#define FRAMESZ_MAX 32 static void txfifo_reset(MSSSpiState *s) { @@ -104,10 +105,8 @@ static void set_fifodepth(MSSSpiState *s) s->fifo_depth = 32; } else if (size <= 16) { s->fifo_depth = 16; - } else if (size <= 32) { - s->fifo_depth = 8; } else { - s->fifo_depth = 4; + s->fifo_depth = 8; } } @@ -301,6 +300,17 @@ static void spi_write(void *opaque, hwaddr addr, if (s->enabled) { break; } + /* + * [31:6] bits are reserved bits and for future use. + * [5:0] are for frame size. Only [5:0] bits are validated + * during write, [31:6] bits are untouched. + */ + if ((value & FRAMESZ_MASK) > FRAMESZ_MAX) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: Incorrect size %u provided." + "Maximum frame size is %u\n", + __func__, value & FRAMESZ_MASK, FRAMESZ_MAX); + break; + } s->regs[R_SPI_DFSIZE] = value; break;