From patchwork Sun Oct 22 13:28:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sundeep subbaraya X-Patchwork-Id: 10021717 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 7015C60224 for ; Sun, 22 Oct 2017 14:01:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F114204BE for ; Sun, 22 Oct 2017 14:01:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 509A927BA5; Sun, 22 Oct 2017 14:01:54 +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 A3156204BE for ; Sun, 22 Oct 2017 14:01:52 +0000 (UTC) Received: from localhost ([::1]:32954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Gp3-0005I4-MX for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 Oct 2017 10:01:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6Go6-0005Ht-6x for qemu-devel@nongnu.org; Sun, 22 Oct 2017 10:00:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6Go3-0002b1-5d for qemu-devel@nongnu.org; Sun, 22 Oct 2017 10:00:50 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:55155) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e6Go2-0002ac-Vl; Sun, 22 Oct 2017 10:00:47 -0400 Received: by mail-pf0-x244.google.com with SMTP id n89so15236928pfk.11; Sun, 22 Oct 2017 07:00:45 -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=8cPop0IAYaRSzCmskltmb0oaTPzGwMod+kzjOI2nlrs=; b=f7Z2v/vrATyY54x6OzgG98ogyKj0yd6Y+bmBzqCjrxMVZqfnc98CVnnUPsSLwNywCQ mNibZYCqUtAPf3hbVNLIK/kqnlHwryM3u+8dVB5On3mxRz83wUwhJE52SRWnIad2s/gP t+zvXnAEqssUTwzwGQOhmOjXd3rezifABxtRwJikw4RJUDc/rkZ3Fznc8V7121ugNbG1 /RD+np4PHwzTC/ArR6znBrGfRAU45N7HKYCp9xsPulSkNKU/T9Y3Z2ql7c6YWf28jdNA L5LyKOgq53RI6OMwxM1WS7+SEXI1vli7aRNDSoXoQILE285g+BzIFRsRRwpTMBHzC8VB OFmQ== 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=8cPop0IAYaRSzCmskltmb0oaTPzGwMod+kzjOI2nlrs=; b=QnU7ogUWBwifXmo3TT+YUehcm0PS4iKxWCLzz9i7XrixLuqnDtbcrV7IUPSmyFMNoc OJfM6SFnUrXVW4SmMaqAU+Bp6dwnDzF47DXc6D0926xungFHjhdlZD52xsgdELoaL5T5 YKliHbsWgkYL00GD3oBwBBf+m6d6Xsu51TnHahR3XQCOHCi17HPq3BUqq+M3J5wu12Hd sHBqtRCeF/sEleWFaS+7fJAWXk8LjcR2+5gYLxstvIh3xDWsb7K/dCMk07+UoKjvNx86 HPvWY4me6O2wguClT1S80+HGOJFbNratzxOyPeEfmSkbTO9eWY6705mtQyZr5p+Qapq/ JxkA== X-Gm-Message-State: AMCzsaU7hK9DwR8Ofvj4/CpF5PTqHwq4bsDk8YioZ097yBiqosnXjsKP SggJLaFYSeVG05j1hORoI/IgLA== X-Google-Smtp-Source: ABhQp+SEJoIPQ/beHt9IbTYbfMB9XKCopgd7fEFSX/3fSMvQIBiTp/XYW3hEOWHJfT05sXe5vByXnQ== X-Received: by 10.98.80.21 with SMTP id e21mr10278913pfb.208.1508678896542; Sun, 22 Oct 2017 06:28:16 -0700 (PDT) Received: from localhost.localdomain ([183.82.194.3]) by smtp.gmail.com with ESMTPSA id q2sm7117171pgp.81.2017.10.22.06.28.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Oct 2017 06:28:15 -0700 (PDT) From: Subbaraya Sundeep To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Sun, 22 Oct 2017 18:58:02 +0530 Message-Id: <1508678882-4327-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::244 Subject: [Qemu-devel] [Qemu devel v3 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 --- 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..e1b6227 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 %d provided." + "Maximum frame size is %d\n", + __func__, value & FRAMESZ_MASK, FRAMESZ_MAX); + break; + } s->regs[R_SPI_DFSIZE] = value; break;